Beispiel #1
0
  @Override
  public void drawScreen(int mouseX, int mouseY, float ticks) {
    super.drawScreen(mouseX, mouseY, ticks);

    int i = 0;

    if (prevHover.checkHover(mouseX, mouseY)) {
      i = -1;
    } else if (nextHover.checkHover(mouseX, mouseY)) {
      i = 1;
    }

    if (container.isRecipes() && i != 0) {
      ItemStack stack = container.getNextRecipe(i);

      drawCreativeTabHoveringText(stack.getDisplayName(), mouseX, mouseY);
    }

    if (container.isRecipes()
        && mouseX >= guiLeft + recipesX - 5
        && mouseX <= guiLeft + xSize - 5
        && mouseY >= guiTop + recipesY - 4
        && mouseY <= guiTop + recipesY + 10) {
      tooltips.clear();

      for (ItemStack stack : container.getRecipes()) {
        tooltips.add(stack.getDisplayName());
      }

      drawHoveringText(tooltips, mouseX, mouseY);
    }
  }
  protected void handleMouseClick(
      Slot p_146984_1_, int p_146984_2_, int p_146984_3_, int p_146984_4_) {
    if (p_146984_1_ != null && p_146984_2_ != -999) {
      Debug.println("p_146984_1_", p_146984_1_.slotNumber + "");
      Debug.println("p_146984_2_", p_146984_2_ + "");
      Debug.println("p_146984_3_", p_146984_3_ + "");
      Debug.println("p_146984_4_", p_146984_4_ + "");

      if (p_146984_1_ != null && p_146984_1_.getHasStack()) {

        ItemStack itemstack = p_146984_1_.getStack();
        ItemStack itemstack2;

        List recipes = CustomCraftingManager.getInstance().getRecipeList();

        for (int j = 0; j < recipes.size(); ++j) {
          IRecipe irecipe = (IRecipe) recipes.get(j);
          itemstack2 = irecipe.getRecipeOutput();
          if (itemstack2 != null) {
            if (itemstack2.getItem() == itemstack.getItem()
                && itemstack.getItemDamage() == itemstack2.getItemDamage()) {

              ItemStack[][] RezeptAr = irecipe.getRecipe(itemstack2);

              Debug.println(
                  irecipe.getClass().getName(),
                  irecipe.getClass().getName() + " " + itemstack2.getItemDamage());

              if (irecipe.getRecipe(itemstack2) != null) {
                craftResult.setInventorySlotContents(0, itemstack2);
                // irecipe.
                for (int i = 0; i < RezeptAr.length; i++) {
                  for (int ii = 0; ii < RezeptAr[i].length; ii++) {
                    recipefield.setInventorySlotContents((i * 3) + ii, null);
                    ItemStack Rezeptitem = RezeptAr[i][ii];
                    if (Rezeptitem != null) {
                      Debug.println(
                          i + "/" + ii,
                          Rezeptitem.getDisplayName() + " " + Rezeptitem.getItemDamage());
                      Rezeptitem.stackSize = 1;
                      recipefield.setInventorySlotContents((i * 3) + ii, Rezeptitem);
                    }
                  }
                }

                Debug.println("itemstack", itemstack.getDisplayName() + "");

                break;
              }
            }
          }
        }
      }
      ((CreativeInv.ContainerCreative) this.inventorySlots).scrollTo(this.currentScroll);
      // this.scrollTo(0.0F);
    }
  }
    public void onMouseBetween(int mX, int mY) {
      int xSize = x + 16;
      int ySize = y + 16;

      if (mX > x && mX < xSize && mY > y && mY < ySize) {
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        if (stack != null && stack.getDisplayName() != null)
          Minecraft.getMinecraft()
              .fontRenderer
              .drawString(stack.getDisplayName(), mX + 6, mY, new Color(139, 137, 137).getRGB());
        GL11.glEnable(GL11.GL_DEPTH_TEST);
      }
    }
Beispiel #4
0
  @SubscribeEvent
  public void onPlayerTick(TickEvent.PlayerTickEvent event) {
    if (event.player.worldObj.isRemote) return;

    if (event.phase == TickEvent.Phase.END && event.side == Side.SERVER) {
      for (int i = 0; i < event.player.inventory.mainInventory.length; i++) {
        ItemStack stack = event.player.inventory.mainInventory[i];
        if (stack != null) {
          for (String bannedItem : config.get().bannedItems) {
            if (Item.itemRegistry.getNameForObject(stack.getItem()).equals(bannedItem)) {
              event.player.addChatMessage(
                  Messages.error(stack.getDisplayName() + " is forbidden. Removing..."));
              event.player.inventory.setInventorySlotContents(i, null);

              Slot slot =
                  event.player.openContainer.getSlotFromInventory(event.player.inventory, i);
              ((EntityPlayerMP) event.player)
                  .playerNetServerHandler.sendPacket(
                      new S2FPacketSetSlot(
                          event.player.openContainer.windowId, slot.slotNumber, null));
            }
          }
        }
      }
    }
  }
 public static String getBlockName(Block block, int meta) {
   ItemStack s = new ItemStack(block, 1, meta);
   if (s.getItem() == null) {
     return null;
   }
   return s.getDisplayName();
 }
  @Override
  public void tick() {
    Minecraft mc = Minecraft.getMinecraft();
    if (mc.thePlayer != null) {
      ItemStack currentItem = mc.thePlayer.inventory.getCurrentItem();
      String currentName = currentItem == null ? "" : currentItem.getDisplayName();

      resetFadeTimer = !currentName.equals(itemName);
      itemName = currentName;

      if (currentItem != null) {
        itemRarityColorCode = currentItem.getRarity().rarityColor.toString();
        stringColor = 16777215;
      }
    }

    if (resetFadeTimer) {
      alpha = 1.0F;

      int fadeSpeed = 8 * 20;

      updateCounter = HUDRegistry.updateCounter + fadeSpeed;
      resetFadeTimer = false;
    } else {
      alpha = (updateCounter - HUDRegistry.updateCounter) / 20.0F;
      alpha = Math.min(Math.max(alpha, 0.0F), 1.0F);
    }
  }
 @Override
 protected void drawSlot(int id, int x, int y, int var4, int var5, int var6) {
   Block block = blocks.get(id);
   ItemStack itemStack = new ItemStack(Item.getItemFromBlock(block));
   GlStateManager.enableRescaleNormal();
   GlStateManager.enableBlend();
   RenderHelper.enableGUIStandardItemLighting();
   GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
   if (itemStack.getItem() != null)
     try {
       Minecraft.getMinecraft()
           .getRenderItem()
           .renderItemAndEffectIntoGUI(itemStack, x + 4, y + 4);
     } catch (Exception e) {
       e.printStackTrace();
     }
   else mc.fontRendererObj.drawString("?", x + 10, y + 9, 10526880);
   Minecraft.getMinecraft()
       .getRenderItem()
       .func_175030_a(Minecraft.getMinecraft().fontRendererObj, itemStack, x + 4, y + 4);
   RenderHelper.disableStandardItemLighting();
   GlStateManager.disableRescaleNormal();
   GlStateManager.disableBlend();
   glDisable(GL_LIGHTING);
   mc.fontRendererObj.drawString(
       "Name: "
           + (itemStack.getItem() == null ? block.getLocalizedName() : itemStack.getDisplayName()),
       x + 31,
       y + 3,
       10526880);
   int blockID = Block.getIdFromBlock(block);
   mc.fontRendererObj.drawString("ID: " + blockID, x + 31, y + 15, 10526880);
 }
 protected void drawAuxGraphics(int posX, int posY) {
   ItemHashMap<Integer> items = this.getItemCounts();
   ArrayList<ItemStack> li = new ArrayList(items.keySet());
   Collections.sort(li, new AlphabeticItemComparator());
   for (int i = recipeTextOffset; i < li.size(); i++) {
     ItemStack is = li.get(i);
     int num = items.get(is);
     String s0 = is.getDisplayName();
     String s = String.format(": x%d", num);
     FontRenderer fr =
         s0.contains(FontType.OBFUSCATED.id) ? FontType.OBFUSCATED.renderer : fontRendererObj;
     s0 = DelegateFontRenderer.stripFlags(s0);
     fr.drawString(
         s0,
         posX + descX + 3,
         posY + descY + (fr.FONT_HEIGHT + 2) * (i - recipeTextOffset),
         0xffffff);
     fontRendererObj.drawString(
         s,
         posX + descX + 3 + fr.getStringWidth(s0),
         posY + descY + (fr.FONT_HEIGHT + 2) * (i - recipeTextOffset),
         0xffffff);
     if (i - recipeTextOffset > 9) break;
   }
 }
 @Override
 public String describe() {
   return "Removing "
       + item.getDisplayName()
       + " from ore dictionary entry "
       + OreDictionary.getOreName(id);
 }
Beispiel #10
0
  @Override
  public void render(boolean isTranslatable) {
    if (text != null) {
      if (isTranslatable) text = StatCollector.translateToLocal(text);
      drawCenteredString("\u00a7n" + text, 4);
      // manual.fonts.drawString("\u00a7n" + text, localWidth + 70, localHeight + 4, 0);
    }

    ItemStack ingred;
    if (icons[2] != null
        && icons[2].getItemDamage() == OreDictionary.WILDCARD_VALUE
        && icons[2].getItem() instanceof ArmorCore) {
      ArrayList<Integer> materials =
          new ArrayList<Integer>(TConstructRegistry.toolMaterials.keySet());
      int mat = materials.get(curTime() % materials.size());
      ingred = ((ArmorCore) icons[2].getItem()).createDefaultStack(mat);
    } else ingred = icons[2];

    startRenderingItem();

    renderStack(icons[0], 138, 110, 2);
    renderStack(icons[1], 70, 74, 2);
    renderStack(ingred, 70, 110, 2);

    stopRenderingItem();

    String ingr = StatCollector.translateToLocal("manual.page.casting1");
    if (isTranslatable) ingr = StatCollector.translateToLocal(ingr);
    int y = 32;
    y += drawTextBlock(ingr + ":", 110, y);
    y += drawTextBlock("- " + icons[1].getDisplayName(), 110, y);
    if (ingred != null) drawTextBlock("- " + ingred.getDisplayName(), 110, y);
  }
  @SideOnly(Side.CLIENT)
  @Override
  public void renderHUD(Minecraft mc, ScaledResolution res) {
    super.renderHUD(mc, res);

    IBlockState filter = getUnderlyingBlock();
    ItemStack recieverStack =
        new ItemStack(
            Item.getItemFromBlock(filter.getBlock()),
            1,
            filter.getBlock().getMetaFromState(filter));
    int color = getColor();

    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    if (recieverStack.getItem() != null) {
      String stackName = recieverStack.getDisplayName();
      int width = 16 + mc.fontRendererObj.getStringWidth(stackName) / 2;
      int x = res.getScaledWidth() / 2 - width;
      int y = res.getScaledHeight() / 2 + 30;

      mc.fontRendererObj.drawStringWithShadow(stackName, x + 20, y + 5, color);
      RenderHelper.enableGUIStandardItemLighting();
      mc.getRenderItem().renderItemAndEffectIntoGUI(recieverStack, x, y);
      RenderHelper.disableStandardItemLighting();
    }

    GlStateManager.disableLighting();
    GlStateManager.disableBlend();
  }
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 @SideOnly(Side.CLIENT)
 public void addInformation(ItemStack stack, EntityPlayer player, List info, boolean par4) {
   NBTTagCompound c = stack.getTagCompound();
   if (getBlockID() == Machine.DeepStorageUnit.getBlockId()
       && stack.getItemDamage() == Machine.DeepStorageUnit.getMeta()
       && c != null) {
     if (c.hasKey("storedStack")) {
       ItemStack storedItem = ItemStack.loadItemStackFromNBT(c.getCompoundTag("storedStack"));
       int storedQuantity = c.getInteger("storedQuantity");
       if (storedItem != null & storedQuantity > 0) {
         info.add(
             "Contains "
                 + storedQuantity
                 + " "
                 + storedItem.getDisplayName()
                 + " ("
                 + storedItem.itemID
                 + ":"
                 + storedItem.getItemDamageForDisplay()
                 + ")");
       } else {
         // info.add("Empty");
       }
     }
   } else if (getBlockID() == Machine.BioFuelGenerator.getBlockId()
       && stack.getItemDamage() == Machine.BioFuelGenerator.getMeta()) {
     info.add("Produces MJ only.");
   }
 }
  @SubscribeEvent
  public void onPlayerDrops(PlayerDropsEvent event) {
    Iterator<EntityItem> iterator = event.drops.iterator();
    while (iterator.hasNext()) {
      EntityItem entItem = iterator.next();
      ItemStack is = entItem.getEntityItem();

      if ((is != null) && (is.getItem() instanceof ItemEnderGlove)) {
        is.damageItem(2, event.entityPlayer);
        InventoryUtils.addItemStackToInventory(
            InventoryUtils.getPlayerEnderChest(event.entityPlayer), is);
        PlayerUtils.sendMessage(
            event.entityPlayer,
            EnumChatFormatting.DARK_PURPLE
                + is.getDisplayName()
                + " was succesfully saved to your Ender Chest!");
        boilerplate.common.utils.Utils.playSFX(
            event.entityPlayer.worldObj,
            (int) entItem.prevPosX,
            (int) entItem.prevPosY,
            (int) entItem.prevPosZ,
            "mob.endermen.portal");
        entItem.setDead();
      }
    }
  }
Beispiel #14
0
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) {
    int l = MathHelper.floor_double((double) (entityplayer.rotationYaw * 4.0F / 360.F) + 0.5D) & 3;

    if (l == 0) {
      world.setBlockMetadataWithNotify(x, y, z, 2, 2);
    }

    if (l == 1) {
      world.setBlockMetadataWithNotify(x, y, z, 5, 2);
    }

    if (l == 2) {
      world.setBlockMetadataWithNotify(x, y, z, 3, 2);
    }

    if (l == 3) {
      world.setBlockMetadataWithNotify(x, y, z, 4, 2);
    }

    if (itemstack.hasDisplayName()) {
      ((TileEntityIBROIFurnace) world.getTileEntity(x, y, z))
          .setGuiDisplayName(itemstack.getDisplayName());
    }
  }
  @Override
  public boolean interact(EntityPlayer player) {
    ItemStack itemStack = player.inventory.getCurrentItem();

    if (itemStack != null
        && itemStack.getItem() == MPItems.spawn_egg_mp
        && itemStack.getItemDamage() == 1014) {
      if (!this.worldObj.isRemote) {
        EntityAgeable entityageable = this.createChild(this);

        if (entityageable != null) {
          entityageable.setGrowingAge(-24000);
          entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
          this.worldObj.spawnEntityInWorld(entityageable);

          if (itemStack.hasDisplayName()) {
            entityageable.setCustomNameTag(itemStack.getDisplayName());
          }
          if (!player.capabilities.isCreativeMode) {
            --itemStack.stackSize;

            if (itemStack.stackSize <= 0) {
              player.inventory.setInventorySlotContents(
                  player.inventory.currentItem, (ItemStack) null);
            }
          }
        }
      }
      return true;
    }
    return super.interact(player);
  }
Beispiel #16
0
  /** Checking item usage for right click on entity */
  public boolean checkEntityRightClick(ItemStack item, Resident res, Entity entity) {
    for (Iterator<SegmentEntity> it = segmentsEntities.iterator(); it.hasNext(); ) {
      SegmentEntity segment = it.next();
      if (segment.getType() == EntityType.PROTECT
          && segment.getCheckClass().isAssignableFrom(entity.getClass())) {
        int dim = entity.dimension;
        int x = (int) Math.floor(entity.posX);
        int y = (int) Math.floor(entity.posY);
        int z = (int) Math.floor(entity.posZ);

        if (!hasPermission(res, segment, dim, x, y, z)) {
          return true;
        }
      }
    }

    if (item == null) return false;

    for (Iterator<SegmentItem> it = segmentsItems.iterator(); it.hasNext(); ) {
      SegmentItem segment = it.next();
      if (segment.getType() == ItemType.RIGHT_CLICK_ENTITY
          && segment.getCheckClass().isAssignableFrom(item.getItem().getClass())) {
        try {
          if (segment.checkCondition(item)) {
            int range = segment.getRange(item);
            int dim = entity.dimension;
            int x = (int) Math.floor(entity.posX);
            int y = (int) Math.floor(entity.posY);
            int z = (int) Math.floor(entity.posZ);

            if (range == 0) {
              if (!hasPermission(res, segment, dim, x, y, z)) {
                return true;
              }
            } else {
              Volume rangeBox =
                  new Volume(x - range, y - range, z - range, x + range, y + range, z + range);
              if (!hasPermission(res, segment, dim, rangeBox)) {
                return true;
              }
            }
          }
        } catch (Exception ex) {
          MyTown.instance.LOG.error(
              "Failed to check item use on {} at the player {} ({}, {}, {} | Dim: {})",
              item.getDisplayName(),
              res.getPlayerName(),
              entity.posX,
              entity.posY,
              entity.posZ,
              entity.dimension);
          MyTown.instance.LOG.error(ExceptionUtils.getStackTrace(ex));
          if (ex instanceof GetterException || ex instanceof ConditionException) {
            this.disableSegment(it, segment, ex.getMessage());
          }
        }
      }
    }
    return false;
  }
 public static void checkInventory(EntityPlayer player, int dim, int fromDim) {
   ArrayList<String> disabledItems = new ArrayList<String>();
   ArrayList<String> enabledItems = new ArrayList<String>();
   for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
     ItemStack stack = player.inventory.getStackInSlot(i);
     if (stack == null || stack.getItem() == null) continue;
     boolean disabled = DisabledHandler.isDisabledStack(stack, dim);
     boolean wasDisabled =
         fromDim > Integer.MIN_VALUE && DisabledHandler.isDisabledStack(stack, fromDim);
     if (disabled != wasDisabled) {
       String name = stack.getDisplayName();
       if (disabled && !disabledItems.contains(name)) disabledItems.add(name);
       else if (!disabled && !enabledItems.contains(name)) enabledItems.add(name);
     }
   }
   try {
     if (disabledItems.size() > 0)
       player.addChatComponentMessage(
           new ChatComponentText(
               StatCollector.translateToLocal(Names.disabled)
                   + ": "
                   + StackUtils.getConcatString(disabledItems)));
     if (enabledItems.size() > 0)
       player.addChatComponentMessage(
           new ChatComponentText(
               StatCollector.translateToLocal(Names.enabled)
                   + ": "
                   + StackUtils.getConcatString(enabledItems)));
   } catch (Exception ignore) {
   }
   disableArmour(player, dim);
 }
 @SideOnly(Side.CLIENT)
 public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
   // TODO translate
   IModule module = getModule(stack);
   if (module instanceof IRocketEngine) {
     list.add("Speed: " + ((IRocketEngine) module).getSpeed(null));
     list.add("Range: " + ((IRocketEngine) module).getMaxDistance(null));
     if (module instanceof RocketEngineFluid) {
       list.add(
           "Fuel: "
               + ((RocketEngineFluid) module).getFluidAmount()
               + "/"
               + ((RocketEngineFluid) module).getCapacity()
               + "mL");
     } else if (module instanceof RocketEngineSolid) {
       ItemStack fuel = ((RocketEngineSolid) module).getInventory().getStackInSlot(0);
       if (fuel != null) {
         int max =
             Math.max(
                 fuel.getMaxStackSize(),
                 ((RocketEngineSolid) module).getInventory().getInventoryStackLimit());
         list.add("Fuel: " + fuel.getDisplayName() + " " + fuel.stackSize + "/" + max);
       } else {
         list.add("Fuel: empty");
       }
     }
   }
 }
 private void renderBookOverlay(ScaledResolution resolution, ItemStack stack, IItemPage page) {
   int sx = resolution.getScaledWidth() / 2 - 17;
   int sy = resolution.getScaledHeight() / 2 + 2;
   mc.getRenderItem().renderItemIntoGUI(new ItemStack(ModItems.manual), sx + 20, sy - 16);
   if (mc.thePlayer.isSneaking()) {
     GlStateManager.pushMatrix();
     GlStateManager.color(1f, 1f, 1f);
     mc.fontRendererObj.drawStringWithShadow(stack.getDisplayName(), sx + 39, sy - 13, 0x00BFFF);
     mc.fontRendererObj.drawStringWithShadow(
         EnumChatFormatting.ITALIC + LangUtil.translate(page.worldDescription(stack)),
         sx + 39,
         sy - 4,
         0xBABABA);
     GlStateManager.color(1f, 1f, 1f);
     GlStateManager.popMatrix();
   } else {
     GlStateManager.pushMatrix();
     GlStateManager.scale(0.5, 0.5, 0.5);
     GlStateManager.translate((sx * 2) + 45, (sy * 2) + 2, 0);
     GlStateManager.color(1f, 1f, 1f);
     mc.fontRendererObj.drawStringWithShadow(
         LangUtil.translate("gui.augmentedaccessories.hud.shift"), 0, 0, 0xFFFFFF);
     GlStateManager.color(1f, 1f, 1f);
     GlStateManager.popMatrix();
   }
 }
 @Override
 public String describeUndo() {
   return "Restoring "
       + item.getDisplayName()
       + " to ore dictionary entry "
       + OreDictionary.getOreName(id);
 }
 @Override
 public String modifyInfo(QuestStack questStack, String info) {
   info = info.replace("$craftMaxAmount", Integer.toString(getMaxCraftCount(questStack)));
   ItemStack itemStack = getItem(questStack);
   info =
       info.replace("$craftItem", itemStack != null ? itemStack.getDisplayName() : "Unknown Item");
   return info;
 }
 @Override
 public void onBlockPlacedBy(
     World world, int x, int y, int z, EntityLivingBase entity, ItemStack item) {
   int dir = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
   TileEntityBFurnace tile = (TileEntityBFurnace) world.getBlockTileEntity(x, y, z);
   tile.direction = getFacingOnMeta(dir);
   if (item.hasDisplayName()) {
     tile.setCustomName(item.getDisplayName());
   }
 }
  /** Called by ItemBlocks after a block is set in the world, to allow post-place logic */
  public void onBlockPlacedBy(
      World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    if (stack.hasDisplayName()) {
      TileEntity tileentity = worldIn.getTileEntity(pos);

      if (tileentity instanceof TileEntityBrewingStand) {
        ((TileEntityBrewingStand) tileentity).setName(stack.getDisplayName());
      }
    }
  }
Beispiel #24
0
  /** Called when the block is placed in the world. */
  @Override
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase entity, ItemStack is) {
    super.onBlockPlacedBy(world, x, y, z, entity, is);

    if (is.hasDisplayName()) {
      TEHopper tileentityhopper = getHopperTE(world, x, y, z);
      tileentityhopper.setCustomName(is.getDisplayName());
    }
  }
Beispiel #25
0
 public boolean hasRequiredKey(EntityPlayer player, TileEntityLockable tileEntityLockable) {
   for (ItemStack stack : player.inventory.mainInventory) {
     if (stack != null && stack.getItem() == ZeiyoItems.key) {
       if (tileEntityLockable.getLockCode().getLock().equals(stack.getDisplayName())) {
         return true;
       }
     }
   }
   return false;
 }
Beispiel #26
0
  /**
   * Sends the contents of an inventory slot to the client-side Container. This doesn't have to
   * match the actual contents of that slot. Args: Container, slot number, slot contents
   */
  public void sendSlotContents(Container container, int index, ItemStack stack) {
    if (index == 0) {
      this.nameField.setText(stack == null ? "" : stack.getDisplayName());
      this.nameField.setEnabled(stack != null);

      if (stack != null) {
        this.renameItem();
      }
    }
  }
Beispiel #27
0
  @Override
  @SideOnly(Side.CLIENT)
  public void renderScreen(IGuiLexiconEntry gui, int mx, int my) {
    relativeMouseX = mx;
    relativeMouseY = my;

    renderRecipe(gui, mx, my);

    int width = gui.getWidth() - 30;
    int height = gui.getHeight();
    int x = gui.getLeft() + 16;
    int y = gui.getTop() + height - 40;
    PageText.renderText(x, y, width, height, getUnlocalizedName());

    if (tooltipStack != null) {
      List<String> tooltipData = tooltipStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
      List<String> parsedTooltip = new ArrayList();
      boolean first = true;

      for (String s : tooltipData) {
        String s_ = s;
        if (!first) s_ = EnumChatFormatting.GRAY + s;
        parsedTooltip.add(s_);
        first = false;
      }

      vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mx, my, parsedTooltip);

      int tooltipY = 8 + tooltipData.size() * 11;

      if (tooltipEntry) {
        vazkii.botania.client.core.helper.RenderHelper.renderTooltipOrange(
            mx,
            my + tooltipY,
            Arrays.asList(
                EnumChatFormatting.GRAY
                    + StatCollector.translateToLocal("botaniamisc.clickToRecipe")));
        tooltipY += 18;
      }

      if (tooltipContainerStack != null)
        vazkii.botania.client.core.helper.RenderHelper.renderTooltipGreen(
            mx,
            my + tooltipY,
            Arrays.asList(
                EnumChatFormatting.AQUA
                    + StatCollector.translateToLocal("botaniamisc.craftingContainer"),
                tooltipContainerStack.getDisplayName()));
    }

    tooltipStack = tooltipContainerStack = null;
    tooltipEntry = false;
    GL11.glDisable(GL11.GL_BLEND);
    mouseDownLastTick = Mouse.isButtonDown(0);
  }
 @Override
 public String modifyObjective(
     QuestStack questStack, EntityPlayer entityPlayer, String objective, int objectiveIndex) {
   objective = objective.replace("$craftAmount", Integer.toString(getCraftCount(questStack)));
   objective =
       objective.replace("$craftMaxAmount", Integer.toString(getMaxCraftCount(questStack)));
   ItemStack itemStack = getItem(questStack);
   objective =
       objective.replace(
           "$craftItem", itemStack != null ? itemStack.getDisplayName() : "Unknown Item");
   return objective;
 }
  @Override
  public void processCommand(ICommandSender sender, String[] params) {
    if (canCommandSenderUseCommand(sender)) {
      ChatStyle style = new ChatStyle();
      EntityPlayer player = (EntityPlayer) getCommandSenderAsPlayer(sender);
      ItemStack stack = player.getCurrentEquippedItem();
      if (stack != null) {
        for (String val : params[0].split(":")) {
          int value = Integer.parseInt(val);
          if (value < 16) {
            style.setColor(EnumChatFormatting.values()[value]);
          } else {
            switch (EnumChatFormatting.values()[value]) {
              case OBFUSCATED:
                style.setObfuscated(true);
                break;
              case BOLD:
                style.setBold(true);
                break;
              case STRIKETHROUGH:
                style.setStrikethrough(true);
                break;
              case UNDERLINE:
                style.setUnderlined(true);
                break;
              case ITALIC:
                style.setItalic(true);
                break;
              default:
                break;
            }
          }
        }
        StringBuilder name = new StringBuilder();
        for (String str : params[1].split(":")) {
          name.append(str + " ");
        }
        if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());
        NBTTagList list = new NBTTagList();
        StringBuilder desc = new StringBuilder();
        for (int i = 1; i < params.length; i++) {
          desc.append(params[i].replace(':', ' '));
        }

        NBTTagString strTag = new NBTTagString(style.getFormattingCode() + desc.toString());
        list.appendTag(strTag);
        stack.stackTagCompound.getCompoundTag("display").setTag("Lore", list);

        sender.addChatMessage(
            new ChatComponentTranslation("commands.lore.success", stack.getDisplayName()));
      }
    }
  }
Beispiel #30
0
 @Override
 public void onBlockPlacedBy(
     World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) {
   if (world.getTileEntity(x, y, z) instanceof TileEntityFL) {
     if (itemStack.hasDisplayName()) {
       ((TileEntityFL) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
     }
     ((TileEntityFL) world.getTileEntity(x, y, z))
         .setOrientation(ForgeDirection.getOrientation(getFacing(entityLiving)));
     world.setBlockMetadataWithNotify(x, y, z, getFacing(entityLiving), 2);
   }
 }