Esempio n. 1
0
 protected void drawSlot(
     int p_180791_1_,
     int p_180791_2_,
     int p_180791_3_,
     int p_180791_4_,
     int p_180791_5_,
     int p_180791_6_) {
   StatBase var7 = (StatBase) StatList.generalStats.get(p_180791_1_);
   GuiStats.this.drawString(
       GuiStats.this.fontRenderer,
       var7.getStatName().getUnformattedText(),
       p_180791_2_ + 2,
       p_180791_3_ + 1,
       p_180791_1_ % 2 == 0 ? 16777215 : 9474192);
   String var8 = var7.func_75968_a(GuiStats.this.field_146546_t.writeStat(var7));
   GuiStats.this.drawString(
       GuiStats.this.fontRenderer,
       var8,
       p_180791_2_ + 2 + 213 - GuiStats.this.fontRenderer.getStringWidth(var8),
       p_180791_3_ + 1,
       p_180791_1_ % 2 == 0 ? 16777215 : 9474192);
 }
Esempio n. 2
0
  /** Draws the hover event specified by the given chat component */
  protected void handleComponentHover(
      IChatComponent p_175272_1_, int p_175272_2_, int p_175272_3_) {
    if (p_175272_1_ != null && p_175272_1_.getChatStyle().getChatHoverEvent() != null) {
      HoverEvent hoverevent = p_175272_1_.getChatStyle().getChatHoverEvent();

      if (hoverevent.getAction() == HoverEvent.Action.SHOW_ITEM) {
        ItemStack itemstack = null;

        try {
          NBTBase nbtbase = JsonToNBT.getTagFromJson(hoverevent.getValue().getUnformattedText());

          if (nbtbase instanceof NBTTagCompound) {
            itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound) nbtbase);
          }
        } catch (NBTException var11) {;
        }

        if (itemstack != null) {
          this.renderToolTip(itemstack, p_175272_2_, p_175272_3_);
        } else {
          this.drawCreativeTabHoveringText(
              EnumChatFormatting.RED + "Invalid Item!", p_175272_2_, p_175272_3_);
        }
      } else if (hoverevent.getAction() == HoverEvent.Action.SHOW_ENTITY) {
        if (this.mc.gameSettings.advancedItemTooltips) {
          try {
            NBTBase nbtbase1 = JsonToNBT.getTagFromJson(hoverevent.getValue().getUnformattedText());

            if (nbtbase1 instanceof NBTTagCompound) {
              List<String> list1 = Lists.<String>newArrayList();
              NBTTagCompound nbttagcompound = (NBTTagCompound) nbtbase1;
              list1.add(nbttagcompound.getString("name"));

              if (nbttagcompound.hasKey("type", 8)) {
                String s = nbttagcompound.getString("type");
                list1.add("Type: " + s + " (" + EntityList.getIDFromString(s) + ")");
              }

              list1.add(nbttagcompound.getString("id"));
              this.drawHoveringText(list1, p_175272_2_, p_175272_3_);
            } else {
              this.drawCreativeTabHoveringText(
                  EnumChatFormatting.RED + "Invalid Entity!", p_175272_2_, p_175272_3_);
            }
          } catch (NBTException var10) {
            this.drawCreativeTabHoveringText(
                EnumChatFormatting.RED + "Invalid Entity!", p_175272_2_, p_175272_3_);
          }
        }
      } else if (hoverevent.getAction() == HoverEvent.Action.SHOW_TEXT) {
        this.drawHoveringText(
            NEWLINE_SPLITTER.splitToList(hoverevent.getValue().getFormattedText()),
            p_175272_2_,
            p_175272_3_);
      } else if (hoverevent.getAction() == HoverEvent.Action.SHOW_ACHIEVEMENT) {
        StatBase statbase = StatList.getOneShotStat(hoverevent.getValue().getUnformattedText());

        if (statbase != null) {
          IChatComponent ichatcomponent = statbase.getStatName();
          IChatComponent ichatcomponent1 =
              new ChatComponentTranslation(
                  "stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic"),
                  new Object[0]);
          ichatcomponent1.getChatStyle().setItalic(Boolean.valueOf(true));
          String s1 =
              statbase instanceof Achievement ? ((Achievement) statbase).getDescription() : null;
          List<String> list =
              Lists.newArrayList(
                  new String[] {
                    ichatcomponent.getFormattedText(), ichatcomponent1.getFormattedText()
                  });

          if (s1 != null) {
            list.addAll(this.fontRendererObj.listFormattedStringToWidth(s1, 150));
          }

          this.drawHoveringText(list, p_175272_2_, p_175272_3_);
        } else {
          this.drawCreativeTabHoveringText(
              EnumChatFormatting.RED + "Invalid statistic/achievement!", p_175272_2_, p_175272_3_);
        }
      }

      GlStateManager.disableLighting();
    }
  }