From 4bfc59bd9126bda6ee804b15055bd5bfb2d79c5d Mon Sep 17 00:00:00 2001 From: HoosierTransfer Date: Sun, 30 Jun 2024 10:56:27 -0400 Subject: [PATCH] add armor changes from 1.9 --- .../minecraft/entity/EntityLivingBase.java | 11 +- .../inventory/EntityEquipmentSlot.java | 58 +++ src/main/java/net/minecraft/item/Item.java | 2 +- .../java/net/minecraft/item/ItemArmor.java | 40 +- src/main/java/net/minecraft/item/ItemHoe.java | 4 +- .../java/net/minecraft/item/ItemStack.java | 369 ++++++++++-------- .../java/net/minecraft/item/ItemSword.java | 4 +- .../java/net/minecraft/item/ItemTool.java | 4 +- 8 files changed, 322 insertions(+), 170 deletions(-) create mode 100644 src/main/java/net/minecraft/inventory/EntityEquipmentSlot.java diff --git a/src/main/java/net/minecraft/entity/EntityLivingBase.java b/src/main/java/net/minecraft/entity/EntityLivingBase.java index 0a7da48..d9dc25a 100644 --- a/src/main/java/net/minecraft/entity/EntityLivingBase.java +++ b/src/main/java/net/minecraft/entity/EntityLivingBase.java @@ -11,6 +11,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import javax.annotation.Nullable; + import net.hoosiertransfer.EaglerItems; import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID; @@ -34,6 +36,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemElytra; @@ -492,7 +495,7 @@ public abstract class EntityLivingBase extends Entity { for (int i = 0; i < inv.length; ++i) { ItemStack itemstack = inv[i]; if (itemstack != null) { - this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers()); + this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers(4 - i)); } } @@ -501,7 +504,7 @@ public abstract class EntityLivingBase extends Entity { for (int i = 0; i < inv.length; ++i) { ItemStack itemstack1 = inv[i]; if (itemstack1 != null) { - this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers()); + this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers(4 - i)); } } @@ -1674,11 +1677,11 @@ public abstract class EntityLivingBase extends Entity { ((WorldServer) this.worldObj).getEntityTracker().sendToAllTrackingEntity(this, new S04PacketEntityEquipment(this.getEntityId(), j, itemstack1)); if (itemstack != null) { - this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers()); + this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers(4 - j)); } if (itemstack1 != null) { - this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers()); + this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers(4 - j)); } this.previousEquipment[j] = itemstack1 == null ? null : itemstack1.copy(); diff --git a/src/main/java/net/minecraft/inventory/EntityEquipmentSlot.java b/src/main/java/net/minecraft/inventory/EntityEquipmentSlot.java new file mode 100644 index 0000000..9627f1e --- /dev/null +++ b/src/main/java/net/minecraft/inventory/EntityEquipmentSlot.java @@ -0,0 +1,58 @@ +package net.minecraft.inventory; + +/* + * this is not the same as the EntityEquipmentSlot in 1.9 + */ +public enum EntityEquipmentSlot { + // MAINHAND(EntityEquipmentSlot.Type.HAND, 0, 0, "mainhand"), + FEET(EntityEquipmentSlot.Type.ARMOR, 3, 1, "feet"), + LEGS(EntityEquipmentSlot.Type.ARMOR, 2, 2, "legs"), + CHEST(EntityEquipmentSlot.Type.ARMOR, 1, 3, "chest"), + HEAD(EntityEquipmentSlot.Type.ARMOR, 0, 4, "head"); + + private final EntityEquipmentSlot.Type slotType; + private final int index; + private final int slotIndex; + private final String name; + + private EntityEquipmentSlot(EntityEquipmentSlot.Type slotTypeIn, int indexIn, int slotIndexIn, String nameIn) { + this.slotType = slotTypeIn; + this.index = indexIn; + this.slotIndex = slotIndexIn; + this.name = nameIn; + } + + public EntityEquipmentSlot.Type getSlotType() { + return this.slotType; + } + + public int getIndex() { + return this.index; + } + + /** + * Gets the actual slot index. + */ + public int getSlotIndex() { + return this.slotIndex; + } + + public String getName() { + return this.name; + } + + public static EntityEquipmentSlot fromString(String targetName) { + for (EntityEquipmentSlot entityequipmentslot : values()) { + if (entityequipmentslot.getName().equals(targetName)) { + return entityequipmentslot; + } + } + + throw new IllegalArgumentException("Invalid slot \'" + targetName + "\'"); + } + + public static enum Type { + HAND, + ARMOR; + } +} diff --git a/src/main/java/net/minecraft/item/Item.java b/src/main/java/net/minecraft/item/Item.java index 74c5138..25066af 100644 --- a/src/main/java/net/minecraft/item/Item.java +++ b/src/main/java/net/minecraft/item/Item.java @@ -532,7 +532,7 @@ public class Item { return false; } - public Multimap getItemAttributeModifiers() { + public Multimap getItemAttributeModifiers(int equipmentSlot) { return HashMultimap.create(); } diff --git a/src/main/java/net/minecraft/item/ItemArmor.java b/src/main/java/net/minecraft/item/ItemArmor.java index 9501c73..264f625 100644 --- a/src/main/java/net/minecraft/item/ItemArmor.java +++ b/src/main/java/net/minecraft/item/ItemArmor.java @@ -1,9 +1,12 @@ package net.minecraft.item; import java.util.List; +import java.util.UUID; import com.google.common.base.Predicates; +import com.google.common.collect.Multimap; +import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID; import net.minecraft.block.BlockDispenser; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; @@ -11,8 +14,11 @@ import net.minecraft.dispenser.IBehaviorDispenseItem; import net.minecraft.dispenser.IBlockSource; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; @@ -54,6 +60,8 @@ public class ItemArmor extends Item { * Holds the 'base' maxDamage that each armorType have. */ private static final int[] maxDamageArray = new int[] { 11, 16, 15, 13 }; + private static final EaglercraftUUID[] ARMOR_MODIFIERS = new EaglercraftUUID[] {EaglercraftUUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), EaglercraftUUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), EaglercraftUUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), EaglercraftUUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")}; + public static final String[] EMPTY_SLOT_NAMES = new String[] { "minecraft:items/empty_armor_slot_helmet", "minecraft:items/empty_armor_slot_chestplate", "minecraft:items/empty_armor_slot_leggings", "minecraft:items/empty_armor_slot_boots" }; @@ -88,6 +96,8 @@ public class ItemArmor extends Item { }; public final int armorType; public final int damageReduceAmount; + public final float field_189415_e; + public final int renderIndex; private final ItemArmor.ArmorMaterial material; @@ -97,6 +107,7 @@ public class ItemArmor extends Item { this.renderIndex = renderIndex; this.damageReduceAmount = material.getDamageReductionAmount(armorType); this.setMaxDamage(material.getDurability(armorType)); + this.field_189415_e = material.func_189416_e(); this.maxStackSize = 1; this.setCreativeTab(CreativeTabs.tabCombat); BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserBehavior); @@ -227,22 +238,39 @@ public class ItemArmor extends Item { return itemstack; } + + public Multimap getItemAttributeModifiers(int equipmentSlot) + { + Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); + System.out.println("slot in " + equipmentSlot); + System.out.println("slot needed " + this.armorType); + + if (equipmentSlot == this.armorType) + { + multimap.put(SharedMonsterAttributes.ARMOR.getAttributeUnlocalizedName(), new AttributeModifier(ARMOR_MODIFIERS[equipmentSlot], "Armor modifier", (double)this.damageReduceAmount, 0)); + multimap.put(SharedMonsterAttributes.field_189429_h.getAttributeUnlocalizedName(), new AttributeModifier(ARMOR_MODIFIERS[equipmentSlot], "Armor toughness", (double)this.field_189415_e, 0)); + } + + return multimap; + } public static enum ArmorMaterial { - LEATHER("leather", 5, new int[] { 1, 3, 2, 1 }, 15), CHAIN("chainmail", 15, new int[] { 2, 5, 4, 1 }, 12), - IRON("iron", 15, new int[] { 2, 6, 5, 2 }, 9), GOLD("gold", 7, new int[] { 2, 5, 3, 1 }, 25), - DIAMOND("diamond", 33, new int[] { 3, 8, 6, 3 }, 10); + LEATHER("leather", 5, new int[] { 1, 3, 2, 1 }, 15, 0.0F), CHAIN("chainmail", 15, new int[] { 2, 5, 4, 1 }, 12, 0.0F), + IRON("iron", 15, new int[] { 2, 6, 5, 2 }, 9, 0.0F), GOLD("gold", 7, new int[] { 2, 5, 3, 1 }, 25, 0.0F), + DIAMOND("diamond", 33, new int[] { 3, 8, 6, 3 }, 10, 2.0F); private final String name; private final int maxDamageFactor; private final int[] damageReductionAmountArray; private final int enchantability; + private final float somethingidk; - private ArmorMaterial(String name, int maxDamage, int[] reductionAmounts, int enchantability) { + private ArmorMaterial(String name, int maxDamage, int[] reductionAmounts, int enchantability, float something) { this.name = name; this.maxDamageFactor = maxDamage; this.damageReductionAmountArray = reductionAmounts; this.enchantability = enchantability; + somethingidk = something; } public int getDurability(int armorType) { @@ -267,5 +295,9 @@ public class ItemArmor extends Item { public String getName() { return this.name; } + + public float func_189416_e() { + return this.somethingidk; + } } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemHoe.java b/src/main/java/net/minecraft/item/ItemHoe.java index df2807b..469f28e 100644 --- a/src/main/java/net/minecraft/item/ItemHoe.java +++ b/src/main/java/net/minecraft/item/ItemHoe.java @@ -136,8 +136,8 @@ public class ItemHoe extends Item { return this.theToolMaterial.toString(); } - public Multimap getItemAttributeModifiers() { - Multimap multimap = super.getItemAttributeModifiers(); + public Multimap getItemAttributeModifiers(int equipmentSlot) { + Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 0.0D, 0)); diff --git a/src/main/java/net/minecraft/item/ItemStack.java b/src/main/java/net/minecraft/item/ItemStack.java index d1fc0a9..8854b45 100644 --- a/src/main/java/net/minecraft/item/ItemStack.java +++ b/src/main/java/net/minecraft/item/ItemStack.java @@ -28,6 +28,7 @@ import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.HoverEvent; import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -649,178 +650,236 @@ public final class ItemStack { * Return a list of strings containing information about the * item */ - public List getTooltip(EntityPlayer playerIn, boolean advanced) { - ArrayList arraylist = Lists.newArrayList(); - String s = this.getDisplayName(); - if (this.hasDisplayName()) { - s = EnumChatFormatting.ITALIC + s; - } + public List getTooltip(EntityPlayer playerIn, boolean advanced) + { + List list = Lists.newArrayList(); + String s = this.getDisplayName(); - s = s + EnumChatFormatting.RESET; - if (advanced) { - String s1 = ""; - if (s.length() > 0) { - s = s + " ("; - s1 = ")"; - } + if (this.hasDisplayName()) + { + s = EnumChatFormatting.ITALIC + s; + } - int i = Item.getIdFromItem(this.item); - if (this.getHasSubtypes()) { - s = s + HString.format("#%04d/%d%s", - new Object[] { Integer.valueOf(i), Integer.valueOf(this.itemDamage), s1 }); - } else { - s = s + HString.format("#%04d%s", new Object[] { Integer.valueOf(i), s1 }); - } - } else if (!this.hasDisplayName() && this.item == Items.filled_map) { - s = s + " #" + this.itemDamage; - } + s = s + EnumChatFormatting.RESET; - arraylist.add(s); - int k = 0; - if (this.hasTagCompound() && this.stackTagCompound.hasKey("HideFlags", 99)) { - k = this.stackTagCompound.getInteger("HideFlags"); - } + if (advanced) + { + String s1 = ""; - if ((k & 32) == 0) { - this.item.addInformation(this, playerIn, arraylist, advanced); - } + if (!s.isEmpty()) + { + s = s + " ("; + s1 = ")"; + } - if (this.hasTagCompound()) { - if ((k & 1) == 0) { - NBTTagList nbttaglist = this.getEnchantmentTagList(); - if (nbttaglist != null) { - for (int j = 0; j < nbttaglist.tagCount(); ++j) { - short short1 = nbttaglist.getCompoundTagAt(j).getShort("id"); - short short2 = nbttaglist.getCompoundTagAt(j).getShort("lvl"); - if (Enchantment.getEnchantmentById(short1) != null) { - arraylist.add(Enchantment.getEnchantmentById(short1).getTranslatedName(short2)); - } - } - } - } + int i = Item.getIdFromItem(this.item); - if (this.stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); - if (nbttagcompound.hasKey("color", 3)) { - if (advanced) { - arraylist.add( - "Color: #" + Integer.toHexString(nbttagcompound.getInteger("color")).toUpperCase()); - } else { - arraylist.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed")); - } - } + 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.item == Items.filled_map) + { + s = s + " #" + this.itemDamage; + } - if (nbttagcompound.getTagId("Lore") == 9) { - NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); - if (nbttaglist1.tagCount() > 0) { - for (int l = 0; l < nbttaglist1.tagCount(); ++l) { - arraylist.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC - + nbttaglist1.getStringTagAt(l)); - } - } - } - } - } + list.add(s); + int i1 = 0; - Multimap multimap = this.getAttributeModifiers(); - if (!multimap.isEmpty() && (k & 2) == 0) { - arraylist.add(""); + if (this.hasTagCompound() && this.stackTagCompound.hasKey("HideFlags", 99)) + { + i1 = this.stackTagCompound.getInteger("HideFlags"); + } - for (Entry entry : (Set) multimap.entries()) { - AttributeModifier attributemodifier = (AttributeModifier) entry.getValue(); - double d0 = attributemodifier.getAmount(); - boolean flag = false; + if ((i1 & 32) == 0) + { + this.item.addInformation(this, playerIn, list, advanced); + } - if (attributemodifier.getID() == Item.ATTACK_DAMAGE_MODIFIER) { - d0 = d0 + playerIn.getEntityAttribute(SharedMonsterAttributes.attackDamage).getBaseValue(); - d0 = d0 + (double)EnchantmentHelper.func_152377_a(this, EnumCreatureAttribute.UNDEFINED); - flag = true; - } else if (attributemodifier.getID() == Item.ATTACK_SPEED_MODIFIER) - { - d0 += playerIn.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue(); - flag = true; - } + if (this.hasTagCompound()) + { + if ((i1 & 1) == 0) + { + NBTTagList nbttaglist = this.getEnchantmentTagList(); - double d1; - if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) { - d1 = d0; - } else { - d1 = d0 * 100.0D; - } - if (flag) { - arraylist.add(EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted( - "attribute.modifier.plus." + attributemodifier.getOperation(), - new Object[] { DECIMALFORMAT.format(d1), - StatCollector.translateToLocal("attribute.name." + (String) entry.getKey()) })); - } else if (d0 > 0.0D) { - arraylist.add(EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted( - "attribute.modifier.plus." + attributemodifier.getOperation(), - new Object[] { DECIMALFORMAT.format(d1), - StatCollector.translateToLocal("attribute.name." + (String) entry.getKey()) })); - } else if (d0 < 0.0D) { - d1 = d1 * -1.0D; - arraylist.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted( - "attribute.modifier.take." + attributemodifier.getOperation(), - new Object[] { DECIMALFORMAT.format(d1), - StatCollector.translateToLocal("attribute.name." + (String) entry.getKey()) })); - } - } - } + if (nbttaglist != null) + { + for (int j = 0; j < nbttaglist.tagCount(); ++j) + { + int k = nbttaglist.getCompoundTagAt(j).getShort("id"); + int l = nbttaglist.getCompoundTagAt(j).getShort("lvl"); - if (this.hasTagCompound() && this.getTagCompound().getBoolean("Unbreakable") && (k & 4) == 0) { - arraylist.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("item.unbreakable")); - } + if (Enchantment.getEnchantmentById(k) != null) + { + list.add(Enchantment.getEnchantmentById(k).getTranslatedName(l)); + } + } + } + } - if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanDestroy", 9) && (k & 8) == 0) { - NBTTagList nbttaglist2 = this.stackTagCompound.getTagList("CanDestroy", 8); - if (nbttaglist2.tagCount() > 0) { - arraylist.add(""); - arraylist.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("item.canBreak")); + if (this.stackTagCompound.hasKey("display", 10)) + { + NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); - for (int i1 = 0; i1 < nbttaglist2.tagCount(); ++i1) { - Block block = Block.getBlockFromName(nbttaglist2.getStringTagAt(i1)); - if (block != null) { - arraylist.add(EnumChatFormatting.DARK_GRAY + block.getLocalizedName()); - } else { - arraylist.add(EnumChatFormatting.DARK_GRAY + "missingno"); - } - } - } - } + if (nbttagcompound.hasKey("color", 3)) + { + if (advanced) + { + list.add("Color: #" + String.format("%06X", new Object[] {Integer.valueOf(nbttagcompound.getInteger("color"))})); + } + else + { + list.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed")); + } + } - if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanPlaceOn", 9) && (k & 16) == 0) { - NBTTagList nbttaglist3 = this.stackTagCompound.getTagList("CanPlaceOn", 8); - if (nbttaglist3.tagCount() > 0) { - arraylist.add(""); - arraylist.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("item.canPlace")); + if (nbttagcompound.getTagId("Lore") == 9) + { + NBTTagList nbttaglist3 = nbttagcompound.getTagList("Lore", 8); - for (int j1 = 0; j1 < nbttaglist3.tagCount(); ++j1) { - Block block1 = Block.getBlockFromName(nbttaglist3.getStringTagAt(j1)); - if (block1 != null) { - arraylist.add(EnumChatFormatting.DARK_GRAY + block1.getLocalizedName()); - } else { - arraylist.add(EnumChatFormatting.DARK_GRAY + "missingno"); - } - } - } - } + if (!nbttaglist3.hasNoTags()) + { + for (int l1 = 0; l1 < nbttaglist3.tagCount(); ++l1) + { + list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + nbttaglist3.getStringTagAt(l1)); + } + } + } + } + } - if (advanced) { - if (this.isItemDamaged()) { - arraylist.add( - "Durability: " + (this.getMaxDamage() - this.getItemDamage()) + " / " + this.getMaxDamage()); - } + // for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) + // { + // Multimap multimap = this.getAttributeModifiers(entityequipmentslot.getIndex()); - arraylist.add(EnumChatFormatting.DARK_GRAY - + ((ResourceLocation) Item.itemRegistry.getNameForObject(this.item)).toString()); - if (this.hasTagCompound()) { - arraylist.add( - EnumChatFormatting.DARK_GRAY + "NBT: " + this.getTagCompound().getKeySet().size() + " tag(s)"); - } - } + // if (!multimap.isEmpty() && (i1 & 2) == 0) + // { + // list.add(""); + // list.add(StatCollector.translateToLocal("item.modifiers." + entityequipmentslot.getName())); - return arraylist; - } + // for (Entry entry : multimap.entries()) + // { + // AttributeModifier attributemodifier = (AttributeModifier)entry.getValue(); + // double d0 = attributemodifier.getAmount(); + // boolean flag = false; + + // if (attributemodifier.getID() == Item.ATTACK_DAMAGE_MODIFIER) + // { + // d0 = d0 + playerIn.getEntityAttribute(SharedMonsterAttributes.attackDamage).getBaseValue(); + // d0 = d0 + (double)EnchantmentHelper.func_152377_a(this, EnumCreatureAttribute.UNDEFINED); + // flag = true; + // } + // else if (attributemodifier.getID() == Item.ATTACK_SPEED_MODIFIER) + // { + // d0 += playerIn.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue(); + // flag = true; + // } + + // double d1; + + // if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) + // { + // d1 = d0; + // } + // else + // { + // d1 = d0 * 100.0D; + // } + + // if (flag) + // { + // list.add(" " + StatCollector.translateToLocalFormatted("attribute.modifier.equals." + attributemodifier.getOperation(), new Object[] {DECIMALFORMAT.format(d1), StatCollector.translateToLocal("attribute.name." + (String)entry.getKey())})); + // } + // else if (d0 > 0.0D) + // { + // list.add(EnumChatFormatting.BLUE + " " + StatCollector.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier.getOperation(), new Object[] {DECIMALFORMAT.format(d1), StatCollector.translateToLocal("attribute.name." + (String)entry.getKey())})); + // } + // else if (d0 < 0.0D) + // { + // d1 = d1 * -1.0D; + // list.add(EnumChatFormatting.RED + " " + StatCollector.translateToLocalFormatted("attribute.modifier.take." + attributemodifier.getOperation(), new Object[] {DECIMALFORMAT.format(d1), StatCollector.translateToLocal("attribute.name." + (String)entry.getKey())})); + // } + // } + // } + // } + + if (this.hasTagCompound() && this.getTagCompound().getBoolean("Unbreakable") && (i1 & 4) == 0) + { + list.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("item.unbreakable")); + } + + if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanDestroy", 9) && (i1 & 8) == 0) + { + NBTTagList nbttaglist1 = this.stackTagCompound.getTagList("CanDestroy", 8); + + if (!nbttaglist1.hasNoTags()) + { + list.add(""); + list.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("item.canBreak")); + + for (int j1 = 0; j1 < nbttaglist1.tagCount(); ++j1) + { + Block block = Block.getBlockFromName(nbttaglist1.getStringTagAt(j1)); + + if (block != null) + { + list.add(EnumChatFormatting.DARK_GRAY + block.getLocalizedName()); + } + else + { + list.add(EnumChatFormatting.DARK_GRAY + "missingno"); + } + } + } + } + + if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanPlaceOn", 9) && (i1 & 16) == 0) + { + NBTTagList nbttaglist2 = this.stackTagCompound.getTagList("CanPlaceOn", 8); + + if (!nbttaglist2.hasNoTags()) + { + list.add(""); + list.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("item.canPlace")); + + for (int k1 = 0; k1 < nbttaglist2.tagCount(); ++k1) + { + Block block1 = Block.getBlockFromName(nbttaglist2.getStringTagAt(k1)); + + if (block1 != null) + { + list.add(EnumChatFormatting.DARK_GRAY + block1.getLocalizedName()); + } + else + { + list.add(EnumChatFormatting.DARK_GRAY + "missingno"); + } + } + } + } + + if (advanced) + { + if (this.isItemDamaged()) + { + list.add("Durability: " + (this.getMaxDamage() - this.getItemDamage()) + " / " + this.getMaxDamage()); + } + + list.add(EnumChatFormatting.DARK_GRAY + ((ResourceLocation)Item.itemRegistry.getNameForObject(this.item)).toString()); + + if (this.hasTagCompound()) + { + list.add(EnumChatFormatting.DARK_GRAY + "NBT: " + this.getTagCompound().getKeySet().size() + " tag(s)"); + } + } + + return list; + } public boolean hasEffect() { return this.getItem().hasEffect(this); @@ -926,7 +985,7 @@ public final class ItemStack { this.stackTagCompound.setInteger("RepairCost", cost); } - public Multimap getAttributeModifiers() { + public Multimap getAttributeModifiers(int equipmentSlot) { Object object; if (this.hasTagCompound() && this.stackTagCompound.hasKey("AttributeModifiers", 9)) { object = HashMultimap.create(); @@ -942,7 +1001,7 @@ public final class ItemStack { } } } else { - object = this.getItem().getItemAttributeModifiers(); + object = this.getItem().getItemAttributeModifiers(equipmentSlot); } return (Multimap) object; diff --git a/src/main/java/net/minecraft/item/ItemSword.java b/src/main/java/net/minecraft/item/ItemSword.java index 7d71859..3fa7e51 100644 --- a/src/main/java/net/minecraft/item/ItemSword.java +++ b/src/main/java/net/minecraft/item/ItemSword.java @@ -166,8 +166,8 @@ public class ItemSword extends Item { return this.material.getRepairItem() == repair.getItem() ? true : super.getIsRepairable(toRepair, repair); } - public Multimap getItemAttributeModifiers() { - Multimap multimap = super.getItemAttributeModifiers(); + public Multimap getItemAttributeModifiers(int equipmentSlot) { + Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double) this.attackDamage, 0)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0)); diff --git a/src/main/java/net/minecraft/item/ItemTool.java b/src/main/java/net/minecraft/item/ItemTool.java index f474e33..cd0fdc0 100644 --- a/src/main/java/net/minecraft/item/ItemTool.java +++ b/src/main/java/net/minecraft/item/ItemTool.java @@ -140,9 +140,9 @@ public class ItemTool extends Item { : super.getIsRepairable(itemstack, itemstack1); } - public Multimap getItemAttributeModifiers() + public Multimap getItemAttributeModifiers(int equipmentSlot) { - Multimap multimap = super.getItemAttributeModifiers(); + Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); // if (equipmentSlot == EntityEquipmentSlot.MAINHAND) // {