Exemplo n.º 1
0
  @Override
  public List<String> getTooltip(PC_Vec2I position) {

    Slot slot = getSlotAtPosition(position);
    if (slot != null) {
      ItemStack itemstack = null;

      if (slot.getHasStack()) itemstack = slot.getStack();

      // if (slot instanceof PC_Slot && ((PC_Slot) slot).getBackgroundStack() != null && ((PC_Slot)
      // slot).renderTooltipWhenEmpty())
      // itemstack = ((PC_Slot) slot).getBackgroundStack();

      if (itemstack != null) {
        @SuppressWarnings("unchecked")
        List<String> l =
            itemstack.getTooltip(
                PC_ClientUtils.mc().thePlayer,
                PC_ClientUtils.mc().gameSettings.advancedItemTooltips);

        for (int k = 0; k < l.size(); ++k) {
          if (k == 0) {
            l.set(k, itemstack.getRarity().rarityColor + l.get(k));
          } else {
            l.set(k, EnumChatFormatting.GRAY + l.get(k));
          }
        }
        return l;
      }
    }
    return super.getTooltip(position);
  }
Exemplo n.º 2
0
  @Override
  protected void renderToolTip(ItemStack par1ItemStack, int par2, int par3) {
    List list =
        par1ItemStack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);

    Behavior b = Behavior.getBehaviorFromStack(par1ItemStack);
    if (b != null) {
      b.getInformation(par1ItemStack, list);
    }

    for (int k = 0; k < list.size(); ++k) {
      if (k == 0) {
        list.set(
            k,
            "\u00a7"
                + Integer.toHexString(par1ItemStack.getRarity().rarityColor.getFormattingCode())
                + (String) list.get(k));
      } else {
        list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
      }
    }

    FontRenderer font = par1ItemStack.getItem().getFontRenderer(par1ItemStack);
    drawHoveringText(list, par2, par3, (font == null ? fontRendererObj : font));
  }
Exemplo n.º 3
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);
  }
Exemplo n.º 4
0
  @SuppressWarnings("unchecked")
  @SideOnly(Side.CLIENT)
  protected void renderTooltipAndTransfer(
      GuiBooklet gui,
      ItemStack stack,
      int x,
      int y,
      boolean checkAndTransfer,
      boolean mousePressed) {
    boolean flagBefore = gui.mc.fontRenderer.getUnicodeFlag();
    gui.mc.fontRenderer.setUnicodeFlag(false);

    List list = stack.getTooltip(gui.mc.thePlayer, gui.mc.gameSettings.advancedItemTooltips);

    for (int k = 0; k < list.size(); ++k) {
      if (k == 0) {
        list.set(k, stack.getRarity().rarityColor + (String) list.get(k));
      } else {
        list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
      }
    }

    if (checkAndTransfer) {
      BookletPage page = BookletUtils.getFirstPageForStack(stack);
      if (page != null && page != this) {
        list.add(
            EnumChatFormatting.GOLD
                + StringUtil.localize("booklet." + ModUtil.MOD_ID_LOWER + ".clickToSeeRecipe"));

        if (mousePressed) {
          BookletUtils.openIndexEntry(
              gui,
              page.getChapter().entry,
              InitBooklet.entries.indexOf(page.getChapter().entry)
                      / GuiBooklet.CHAPTER_BUTTONS_AMOUNT
                  + 1,
              true);
          BookletUtils.openChapter(gui, page.getChapter(), page);
          Minecraft.getMinecraft()
              .getSoundHandler()
              .playSound(
                  PositionedSoundRecord.func_147674_a(
                      new ResourceLocation("gui.button.press"), 1.0F));
        }
      }
    }

    gui.drawHoveringText(list, x, y);

    gui.mc.fontRenderer.setUnicodeFlag(flagBefore);
  }
Exemplo n.º 5
0
  protected void renderToolTip(ItemStack stack, int x, int y) {
    List<String> list =
        stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);

    for (int i = 0; i < list.size(); ++i) {
      if (i == 0) {
        list.set(i, stack.getRarity().rarityColor + (String) list.get(i));
      } else {
        list.set(i, EnumChatFormatting.GRAY + (String) list.get(i));
      }
    }

    FontRenderer font = stack.getItem().getFontRenderer(stack);
    this.drawHoveringText(list, x, y, (font == null ? fontRendererObj : font));
  }
Exemplo n.º 6
0
  protected void renderToolTip(ItemStack p_146285_1_, int p_146285_2_, int p_146285_3_) {
    if (selectedTabIndex == CreativeTabs.tabAllSearch.getTabIndex()) {
      List list =
          p_146285_1_.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
      CreativeTabs creativetabs = p_146285_1_.getItem().getCreativeTab();

      if (creativetabs == null && p_146285_1_.getItem() == Items.enchanted_book) {
        Map map = EnchantmentHelper.getEnchantments(p_146285_1_);

        if (map.size() == 1) {
          Enchantment enchantment =
              Enchantment.enchantmentsList[((Integer) map.keySet().iterator().next()).intValue()];
          CreativeTabs[] acreativetabs = CreativeTabs.creativeTabArray;
          int k = acreativetabs.length;

          for (int l = 0; l < k; ++l) {
            CreativeTabs creativetabs1 = acreativetabs[l];

            if (creativetabs1.func_111226_a(enchantment.type)) {
              creativetabs = creativetabs1;
              break;
            }
          }
        }
      }

      if (creativetabs != null) {
        list.add(
            1,
            ""
                + EnumChatFormatting.BOLD
                + EnumChatFormatting.BLUE
                + I18n.format(creativetabs.getTranslatedTabLabel(), new Object[0]));
      }

      for (int i1 = 0; i1 < list.size(); ++i1) {
        if (i1 == 0) {
          list.set(i1, p_146285_1_.getRarity().rarityColor + (String) list.get(i1));
        } else {
          list.set(i1, EnumChatFormatting.GRAY + (String) list.get(i1));
        }
      }

      this.func_146283_a(list, p_146285_2_, p_146285_3_);
    } else {
      super.renderToolTip(p_146285_1_, p_146285_2_, p_146285_3_);
    }
  }
Exemplo n.º 7
0
  // split from above for custom search tabs
  private void updateFilteredItems(CreativeInv.ContainerCreative containercreative) {
    Iterator iterator;
    Enchantment[] aenchantment = Enchantment.enchantmentsList;
    int j = aenchantment.length;

    for (int i = 0; i < j; ++i) {
      Enchantment enchantment = aenchantment[i];

      if (enchantment != null && enchantment.type != null) {
        Items.enchanted_book.func_92113_a(enchantment, containercreative.itemList);
      }
    }

    iterator = containercreative.itemList.iterator();
    String s1 = this.searchField.getText().toLowerCase();

    while (iterator.hasNext()) {
      ItemStack itemstack = (ItemStack) iterator.next();
      boolean flag = false;
      Iterator iterator1 =
          itemstack
              .getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips)
              .iterator();

      while (true) {
        if (iterator1.hasNext()) {
          String s = (String) iterator1.next();

          if (!s.toLowerCase().contains(s1)) {
            continue;
          }

          flag = true;
        }

        if (!flag) {
          iterator.remove();
        }

        break;
      }
    }

    this.currentScroll = 0.0F;
    containercreative.scrollTo(0.0F);
  }
  @ForgeSubscribe
  public void onAttackEntityEvent(AttackEntityEvent event) {
    EntityPlayer player;
    if (!event.entityPlayer.worldObj.isRemote && event.target.getEntityName() != null) {
      System.out.println(event.target.getEntityName());

      player = (EntityPlayer) event.entityPlayer;

      ItemStack stack = player.getCurrentEquippedItem();

      if (stack.itemID == ItemInfo.ESSENCE_CONTAINER_ID + 256) {
        int damage = 0;
        for (String s : ModItem.essenceNames) {
          if (s.equals(event.target.getEntityName())) stack.setItemDamage(damage);
          damage++;
        }
        stack.getItem().addInformation(stack, player, stack.getTooltip(player, true), false);
      }
    }
  }
Exemplo n.º 9
0
 @SuppressWarnings("unchecked")
 protected void drawTooltip(int x, int y) {
   if (!this.hasActiveSeed()) {
     return;
   }
   for (Component<PlantStatsStorage> component : this.activeSeeds) {
     if (component != null && component.getComponent() != null) {
       // tooltip
       if (component.isOverComponent(x, y)) {
         PlantStatsStorage stats = component.getComponent();
         short growth = stats.getGrowth();
         short gain = stats.getGain();
         short strength = stats.getStrength();
         ItemStack stack = new ItemStack(activeSeed, stats.amount, activeMeta);
         stack.setTagCompound(
             CropPlantHandler.setSeedNBT(new NBTTagCompound(), growth, gain, strength, true));
         List toolTip = stack.getTooltip(Minecraft.getMinecraft().thePlayer, true);
         drawHoveringText(toolTip, x - this.guiLeft, y - this.guiTop, fontRendererObj);
       }
     }
   }
 }