コード例 #1
0
  /** Return a list of strings containing information about the item */
  @SideOnly(Side.CLIENT)
  public List getTooltip(EntityPlayer par1EntityPlayer, boolean par2) {
    ArrayList arraylist = new ArrayList();
    String s = this.getDisplayName();

    if (this.hasDisplayName()) {
      s = EnumChatFormatting.ITALIC + s + EnumChatFormatting.RESET;
    }

    int i;

    if (par2) {
      String s1 = "";

      if (s.length() > 0) {
        s = s + " (";
        s1 = ")";
      }

      i = Item.getIdFromItem(this.field_151002_e);

      if (this.getHasSubtypes()) {
        s =
            s
                + String.format(
                    "#%04d/%d%s",
                    new Object[] {Integer.valueOf(i), Integer.valueOf(this.itemDamage), s1});
      } else {
        s = s + String.format("#%04d%s", new Object[] {Integer.valueOf(i), s1});
      }
    } else if (!this.hasDisplayName() && this.field_151002_e == Items.filled_map) {
      s = s + " #" + this.itemDamage;
    }

    arraylist.add(s);
    this.field_151002_e.addInformation(this, par1EntityPlayer, arraylist, par2);

    if (this.hasTagCompound()) {
      NBTTagList nbttaglist = this.getEnchantmentTagList();

      if (nbttaglist != null) {
        for (i = 0; i < nbttaglist.tagCount(); ++i) {
          short short1 = nbttaglist.getCompoundTagAt(i).getShort("id");
          short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl");

          if (Enchantment.enchantmentsList[short1] != null) {
            arraylist.add(Enchantment.enchantmentsList[short1].getTranslatedName(short2));
          }
        }
      }

      if (this.stackTagCompound.hasKey("display", 10)) {
        NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display");

        if (nbttagcompound.hasKey("color", 3)) {
          if (par2) {
            arraylist.add(
                "Color: #" + Integer.toHexString(nbttagcompound.getInteger("color")).toUpperCase());
          } else {
            arraylist.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed"));
          }
        }

        if (nbttagcompound.func_150299_b("Lore") == 9) {
          NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8);

          if (nbttaglist1.tagCount() > 0) {
            for (int j = 0; j < nbttaglist1.tagCount(); ++j) {
              arraylist.add(
                  EnumChatFormatting.DARK_PURPLE
                      + ""
                      + EnumChatFormatting.ITALIC
                      + nbttaglist1.getStringTagAt(j));
            }
          }
        }
      }
    }

    Multimap multimap = this.getAttributeModifiers();

    if (!multimap.isEmpty()) {
      arraylist.add("");
      Iterator iterator = multimap.entries().iterator();

      while (iterator.hasNext()) {
        Entry entry = (Entry) iterator.next();
        AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
        double d0 = attributemodifier.getAmount();
        double d1;

        if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) {
          d1 = attributemodifier.getAmount();
        } else {
          d1 = attributemodifier.getAmount() * 100.0D;
        }

        if (d0 > 0.0D) {
          arraylist.add(
              EnumChatFormatting.BLUE
                  + StatCollector.translateToLocalFormatted(
                      "attribute.modifier.plus." + attributemodifier.getOperation(),
                      new Object[] {
                        field_111284_a.format(d1),
                        StatCollector.translateToLocal("attribute.name." + (String) entry.getKey())
                      }));
        } else if (d0 < 0.0D) {
          d1 *= -1.0D;
          arraylist.add(
              EnumChatFormatting.RED
                  + StatCollector.translateToLocalFormatted(
                      "attribute.modifier.take." + attributemodifier.getOperation(),
                      new Object[] {
                        field_111284_a.format(d1),
                        StatCollector.translateToLocal("attribute.name." + (String) entry.getKey())
                      }));
        }
      }
    }

    if (this.hasTagCompound() && this.getTagCompound().getBoolean("Unbreakable")) {
      arraylist.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("item.unbreakable"));
    }

    if (par2 && this.isItemDamaged()) {
      arraylist.add(
          "Durability: "
              + (this.getMaxDamage() - this.getItemDamageForDisplay())
              + " / "
              + this.getMaxDamage());
    }
    ForgeEventFactory.onItemTooltip(this, par1EntityPlayer, arraylist, par2);

    return arraylist;
  }