add armor changes from 1.9

This commit is contained in:
HoosierTransfer 2024-06-30 10:56:27 -04:00
parent 449dd53039
commit 4bfc59bd91
8 changed files with 322 additions and 170 deletions

View File

@ -11,6 +11,8 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable;
import net.hoosiertransfer.EaglerItems; import net.hoosiertransfer.EaglerItems;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID; 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.entity.projectile.EntityArrow;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemElytra; import net.minecraft.item.ItemElytra;
@ -492,7 +495,7 @@ public abstract class EntityLivingBase extends Entity {
for (int i = 0; i < inv.length; ++i) { for (int i = 0; i < inv.length; ++i) {
ItemStack itemstack = inv[i]; ItemStack itemstack = inv[i];
if (itemstack != null) { 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) { for (int i = 0; i < inv.length; ++i) {
ItemStack itemstack1 = inv[i]; ItemStack itemstack1 = inv[i];
if (itemstack1 != null) { 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, ((WorldServer) this.worldObj).getEntityTracker().sendToAllTrackingEntity(this,
new S04PacketEntityEquipment(this.getEntityId(), j, itemstack1)); new S04PacketEntityEquipment(this.getEntityId(), j, itemstack1));
if (itemstack != null) { if (itemstack != null) {
this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers()); this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers(4 - j));
} }
if (itemstack1 != null) { if (itemstack1 != null) {
this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers()); this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers(4 - j));
} }
this.previousEquipment[j] = itemstack1 == null ? null : itemstack1.copy(); this.previousEquipment[j] = itemstack1 == null ? null : itemstack1.copy();

View File

@ -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;
}
}

View File

@ -532,7 +532,7 @@ public class Item {
return false; return false;
} }
public Multimap<String, AttributeModifier> getItemAttributeModifiers() { public Multimap<String, AttributeModifier> getItemAttributeModifiers(int equipmentSlot) {
return HashMultimap.create(); return HashMultimap.create();
} }

View File

@ -1,9 +1,12 @@
package net.minecraft.item; package net.minecraft.item;
import java.util.List; import java.util.List;
import java.util.UUID;
import com.google.common.base.Predicates; 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.block.BlockDispenser;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
@ -11,8 +14,11 @@ import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.dispenser.IBlockSource; import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase; 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.entity.player.EntityPlayer;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
@ -54,6 +60,8 @@ public class ItemArmor extends Item {
* Holds the 'base' maxDamage that each armorType have. * Holds the 'base' maxDamage that each armorType have.
*/ */
private static final int[] maxDamageArray = new int[] { 11, 16, 15, 13 }; 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", 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_chestplate", "minecraft:items/empty_armor_slot_leggings",
"minecraft:items/empty_armor_slot_boots" }; "minecraft:items/empty_armor_slot_boots" };
@ -88,6 +96,8 @@ public class ItemArmor extends Item {
}; };
public final int armorType; public final int armorType;
public final int damageReduceAmount; public final int damageReduceAmount;
public final float field_189415_e;
public final int renderIndex; public final int renderIndex;
private final ItemArmor.ArmorMaterial material; private final ItemArmor.ArmorMaterial material;
@ -97,6 +107,7 @@ public class ItemArmor extends Item {
this.renderIndex = renderIndex; this.renderIndex = renderIndex;
this.damageReduceAmount = material.getDamageReductionAmount(armorType); this.damageReduceAmount = material.getDamageReductionAmount(armorType);
this.setMaxDamage(material.getDurability(armorType)); this.setMaxDamage(material.getDurability(armorType));
this.field_189415_e = material.func_189416_e();
this.maxStackSize = 1; this.maxStackSize = 1;
this.setCreativeTab(CreativeTabs.tabCombat); this.setCreativeTab(CreativeTabs.tabCombat);
BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserBehavior); BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserBehavior);
@ -227,22 +238,39 @@ public class ItemArmor extends Item {
return itemstack; return itemstack;
} }
public Multimap<String, AttributeModifier> getItemAttributeModifiers(int equipmentSlot)
{
Multimap<String, AttributeModifier> 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 { public static enum ArmorMaterial {
LEATHER("leather", 5, new int[] { 1, 3, 2, 1 }, 15), CHAIN("chainmail", 15, new int[] { 2, 5, 4, 1 }, 12), 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), GOLD("gold", 7, new int[] { 2, 5, 3, 1 }, 25), 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); DIAMOND("diamond", 33, new int[] { 3, 8, 6, 3 }, 10, 2.0F);
private final String name; private final String name;
private final int maxDamageFactor; private final int maxDamageFactor;
private final int[] damageReductionAmountArray; private final int[] damageReductionAmountArray;
private final int enchantability; 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.name = name;
this.maxDamageFactor = maxDamage; this.maxDamageFactor = maxDamage;
this.damageReductionAmountArray = reductionAmounts; this.damageReductionAmountArray = reductionAmounts;
this.enchantability = enchantability; this.enchantability = enchantability;
somethingidk = something;
} }
public int getDurability(int armorType) { public int getDurability(int armorType) {
@ -267,5 +295,9 @@ public class ItemArmor extends Item {
public String getName() { public String getName() {
return this.name; return this.name;
} }
public float func_189416_e() {
return this.somethingidk;
}
} }
} }

View File

@ -136,8 +136,8 @@ public class ItemHoe extends Item {
return this.theToolMaterial.toString(); return this.theToolMaterial.toString();
} }
public Multimap<String, AttributeModifier> getItemAttributeModifiers() { public Multimap<String, AttributeModifier> getItemAttributeModifiers(int equipmentSlot) {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(); Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(),
new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 0.0D, 0)); new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 0.0D, 0));

View File

@ -28,6 +28,7 @@ import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.event.HoverEvent; import net.minecraft.event.HoverEvent;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
@ -649,178 +650,236 @@ public final class ItemStack {
* Return a list of strings containing information about the * Return a list of strings containing information about the
* item * item
*/ */
public List<String> getTooltip(EntityPlayer playerIn, boolean advanced) { public List<String> getTooltip(EntityPlayer playerIn, boolean advanced)
ArrayList arraylist = Lists.newArrayList(); {
String s = this.getDisplayName(); List<String> list = Lists.<String>newArrayList();
if (this.hasDisplayName()) { String s = this.getDisplayName();
s = EnumChatFormatting.ITALIC + s;
}
s = s + EnumChatFormatting.RESET; if (this.hasDisplayName())
if (advanced) { {
String s1 = ""; s = EnumChatFormatting.ITALIC + s;
if (s.length() > 0) { }
s = s + " (";
s1 = ")";
}
int i = Item.getIdFromItem(this.item); s = s + EnumChatFormatting.RESET;
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;
}
arraylist.add(s); if (advanced)
int k = 0; {
if (this.hasTagCompound() && this.stackTagCompound.hasKey("HideFlags", 99)) { String s1 = "";
k = this.stackTagCompound.getInteger("HideFlags");
}
if ((k & 32) == 0) { if (!s.isEmpty())
this.item.addInformation(this, playerIn, arraylist, advanced); {
} s = s + " (";
s1 = ")";
}
if (this.hasTagCompound()) { int i = Item.getIdFromItem(this.item);
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));
}
}
}
}
if (this.stackTagCompound.hasKey("display", 10)) { if (this.getHasSubtypes())
NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); {
if (nbttagcompound.hasKey("color", 3)) { s = s + String.format("#%04d/%d%s", new Object[] {Integer.valueOf(i), Integer.valueOf(this.itemDamage), s1});
if (advanced) { }
arraylist.add( else
"Color: #" + Integer.toHexString(nbttagcompound.getInteger("color")).toUpperCase()); {
} else { s = s + String.format("#%04d%s", new Object[] {Integer.valueOf(i), s1});
arraylist.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed")); }
} }
} else if (!this.hasDisplayName() && this.item == Items.filled_map)
{
s = s + " #" + this.itemDamage;
}
if (nbttagcompound.getTagId("Lore") == 9) { list.add(s);
NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); int i1 = 0;
if (nbttaglist1.tagCount() > 0) {
for (int l = 0; l < nbttaglist1.tagCount(); ++l) {
arraylist.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC
+ nbttaglist1.getStringTagAt(l));
}
}
}
}
}
Multimap multimap = this.getAttributeModifiers(); if (this.hasTagCompound() && this.stackTagCompound.hasKey("HideFlags", 99))
if (!multimap.isEmpty() && (k & 2) == 0) { {
arraylist.add(""); i1 = this.stackTagCompound.getInteger("HideFlags");
}
for (Entry entry : (Set<Entry>) multimap.entries()) { if ((i1 & 32) == 0)
AttributeModifier attributemodifier = (AttributeModifier) entry.getValue(); {
double d0 = attributemodifier.getAmount(); this.item.addInformation(this, playerIn, list, advanced);
boolean flag = false; }
if (attributemodifier.getID() == Item.ATTACK_DAMAGE_MODIFIER) { if (this.hasTagCompound())
d0 = d0 + playerIn.getEntityAttribute(SharedMonsterAttributes.attackDamage).getBaseValue(); {
d0 = d0 + (double)EnchantmentHelper.func_152377_a(this, EnumCreatureAttribute.UNDEFINED); if ((i1 & 1) == 0)
flag = true; {
} else if (attributemodifier.getID() == Item.ATTACK_SPEED_MODIFIER) NBTTagList nbttaglist = this.getEnchantmentTagList();
{
d0 += playerIn.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue();
flag = true;
}
double d1; if (nbttaglist != null)
if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) { {
d1 = d0; for (int j = 0; j < nbttaglist.tagCount(); ++j)
} else { {
d1 = d0 * 100.0D; int k = nbttaglist.getCompoundTagAt(j).getShort("id");
} int l = nbttaglist.getCompoundTagAt(j).getShort("lvl");
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 (this.hasTagCompound() && this.getTagCompound().getBoolean("Unbreakable") && (k & 4) == 0) { if (Enchantment.getEnchantmentById(k) != null)
arraylist.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("item.unbreakable")); {
} list.add(Enchantment.getEnchantmentById(k).getTranslatedName(l));
}
}
}
}
if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanDestroy", 9) && (k & 8) == 0) { if (this.stackTagCompound.hasKey("display", 10))
NBTTagList nbttaglist2 = this.stackTagCompound.getTagList("CanDestroy", 8); {
if (nbttaglist2.tagCount() > 0) { NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display");
arraylist.add("");
arraylist.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("item.canBreak"));
for (int i1 = 0; i1 < nbttaglist2.tagCount(); ++i1) { if (nbttagcompound.hasKey("color", 3))
Block block = Block.getBlockFromName(nbttaglist2.getStringTagAt(i1)); {
if (block != null) { if (advanced)
arraylist.add(EnumChatFormatting.DARK_GRAY + block.getLocalizedName()); {
} else { list.add("Color: #" + String.format("%06X", new Object[] {Integer.valueOf(nbttagcompound.getInteger("color"))}));
arraylist.add(EnumChatFormatting.DARK_GRAY + "missingno"); }
} else
} {
} list.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed"));
} }
}
if (this.hasTagCompound() && this.stackTagCompound.hasKey("CanPlaceOn", 9) && (k & 16) == 0) { if (nbttagcompound.getTagId("Lore") == 9)
NBTTagList nbttaglist3 = this.stackTagCompound.getTagList("CanPlaceOn", 8); {
if (nbttaglist3.tagCount() > 0) { NBTTagList nbttaglist3 = nbttagcompound.getTagList("Lore", 8);
arraylist.add("");
arraylist.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("item.canPlace"));
for (int j1 = 0; j1 < nbttaglist3.tagCount(); ++j1) { if (!nbttaglist3.hasNoTags())
Block block1 = Block.getBlockFromName(nbttaglist3.getStringTagAt(j1)); {
if (block1 != null) { for (int l1 = 0; l1 < nbttaglist3.tagCount(); ++l1)
arraylist.add(EnumChatFormatting.DARK_GRAY + block1.getLocalizedName()); {
} else { list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + nbttaglist3.getStringTagAt(l1));
arraylist.add(EnumChatFormatting.DARK_GRAY + "missingno"); }
} }
} }
} }
} }
if (advanced) { // for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
if (this.isItemDamaged()) { // {
arraylist.add( // Multimap<String, AttributeModifier> multimap = this.getAttributeModifiers(entityequipmentslot.getIndex());
"Durability: " + (this.getMaxDamage() - this.getItemDamage()) + " / " + this.getMaxDamage());
}
arraylist.add(EnumChatFormatting.DARK_GRAY // if (!multimap.isEmpty() && (i1 & 2) == 0)
+ ((ResourceLocation) Item.itemRegistry.getNameForObject(this.item)).toString()); // {
if (this.hasTagCompound()) { // list.add("");
arraylist.add( // list.add(StatCollector.translateToLocal("item.modifiers." + entityequipmentslot.getName()));
EnumChatFormatting.DARK_GRAY + "NBT: " + this.getTagCompound().getKeySet().size() + " tag(s)");
}
}
return arraylist; // for (Entry<String, AttributeModifier> 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() { public boolean hasEffect() {
return this.getItem().hasEffect(this); return this.getItem().hasEffect(this);
@ -926,7 +985,7 @@ public final class ItemStack {
this.stackTagCompound.setInteger("RepairCost", cost); this.stackTagCompound.setInteger("RepairCost", cost);
} }
public Multimap<String, AttributeModifier> getAttributeModifiers() { public Multimap<String, AttributeModifier> getAttributeModifiers(int equipmentSlot) {
Object object; Object object;
if (this.hasTagCompound() && this.stackTagCompound.hasKey("AttributeModifiers", 9)) { if (this.hasTagCompound() && this.stackTagCompound.hasKey("AttributeModifiers", 9)) {
object = HashMultimap.create(); object = HashMultimap.create();
@ -942,7 +1001,7 @@ public final class ItemStack {
} }
} }
} else { } else {
object = this.getItem().getItemAttributeModifiers(); object = this.getItem().getItemAttributeModifiers(equipmentSlot);
} }
return (Multimap<String, AttributeModifier>) object; return (Multimap<String, AttributeModifier>) object;

View File

@ -166,8 +166,8 @@ public class ItemSword extends Item {
return this.material.getRepairItem() == repair.getItem() ? true : super.getIsRepairable(toRepair, repair); return this.material.getRepairItem() == repair.getItem() ? true : super.getIsRepairable(toRepair, repair);
} }
public Multimap<String, AttributeModifier> getItemAttributeModifiers() { public Multimap<String, AttributeModifier> getItemAttributeModifiers(int equipmentSlot) {
Multimap multimap = super.getItemAttributeModifiers(); Multimap multimap = super.getItemAttributeModifiers(equipmentSlot);
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(),
new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double) this.attackDamage, 0)); 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)); multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0));

View File

@ -140,9 +140,9 @@ public class ItemTool extends Item {
: super.getIsRepairable(itemstack, itemstack1); : super.getIsRepairable(itemstack, itemstack1);
} }
public Multimap<String, AttributeModifier> getItemAttributeModifiers() public Multimap<String, AttributeModifier> getItemAttributeModifiers(int equipmentSlot)
{ {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(); Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
// if (equipmentSlot == EntityEquipmentSlot.MAINHAND) // if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
// { // {