diff --git a/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java b/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java index 49536b04..6850cfad 100644 --- a/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java +++ b/src/main/java/electroblob/wizardry/item/ItemWizardArmour.java @@ -1,6 +1,9 @@ package electroblob.wizardry.item; import java.util.List; +import java.util.UUID; + +import com.google.common.collect.Multimap; import electroblob.wizardry.Wizardry; import electroblob.wizardry.constants.Constants; @@ -8,11 +11,12 @@ import electroblob.wizardry.constants.Element; import electroblob.wizardry.registry.WizardryAdvancementTriggers; import electroblob.wizardry.registry.WizardryTabs; import electroblob.wizardry.spell.Petrify; -import electroblob.wizardry.util.WizardryUtilities; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; 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.inventory.EntityEquipmentSlot; import net.minecraft.item.EnumAction; @@ -31,6 +35,11 @@ import net.minecraftforge.fml.relauncher.SideOnly; @Mod.EventBusSubscriber public class ItemWizardArmour extends ItemArmor implements ISpecialArmor { + //VanillaCopy, ItemArmor has this set to private for some reason. + public static final UUID[] ARMOR_MODIFIERS = new UUID[] {UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")}; + //Damage reduction values that used to be in WizardryItems.SILK [feet, legs, chest, head] + private static int[] reductions = new int[]{2, 4, 5, 2}; + public Element element; public ItemWizardArmour(ArmorMaterial material, int renderIndex, EntityEquipmentSlot armourType, Element element){ @@ -162,7 +171,7 @@ public class ItemWizardArmour extends ItemArmor implements ISpecialArmor { return new ArmorProperties(0, ArmorMaterial.DIAMOND.getDamageReductionAmount(slot) / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); }else{ - return new ArmorProperties(0, this.damageReduceAmount / 25D, + return new ArmorProperties(0, reductions[slotIndex] / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); } }else{ @@ -180,12 +189,21 @@ public class ItemWizardArmour extends ItemArmor implements ISpecialArmor { // Legendary armour gives full 10 shields, like diamond. return ArmorMaterial.DIAMOND.getDamageReductionAmount(slot); }else{ - return this.getArmorMaterial().getDamageReductionAmount(slot); + return reductions[slotIndex]; } }else{ return 0; } } + + @Override + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { + Multimap map = super.getAttributeModifiers(slot, stack); + if(stack.getItemDamage() < stack.getMaxDamage() && this.armorType == slot) + map.put(SharedMonsterAttributes.ARMOR.getName(), new AttributeModifier(ARMOR_MODIFIERS[slot.getIndex()], + "Armor modifier", reductions[slot.getIndex()], 0)); + return map; + } @Override public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot){ @@ -205,16 +223,8 @@ public class ItemWizardArmour extends ItemArmor implements ISpecialArmor { * integer slot index in ISpecialArmor instead of an EntityEquipmentSlot. */ // NOTE: Remove in 1.12.2 - private EntityEquipmentSlot getArmorSlotFromIndex(int slotIndex){ - // Had to pick something to begin with. - EntityEquipmentSlot slot = EntityEquipmentSlot.HEAD; - - for(EntityEquipmentSlot s : WizardryUtilities.ARMOUR_SLOTS){ - if(s.getIndex() == slotIndex){ - slot = s; - } - } - return slot; + private static EntityEquipmentSlot getArmorSlotFromIndex(int index){ + return EntityEquipmentSlot.values()[index + 2]; } @SubscribeEvent diff --git a/src/main/java/electroblob/wizardry/registry/WizardryItems.java b/src/main/java/electroblob/wizardry/registry/WizardryItems.java index ccae6f2f..e7bf125a 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryItems.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryItems.java @@ -127,7 +127,7 @@ public final class WizardryItems { public static final Item armour_upgrade = new ItemArmourUpgrade(); public static final ArmorMaterial SILK = EnumHelper.addArmorMaterial("SILK", - "wizardry/textures/armour/wizard_armour", 15, new int[]{2, 5, 4, 2}, 0, + "wizardry/textures/armour/wizard_armour", 15, new int[]{0, 0, 0, 0}, 0, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0F); // Saw a post somewhere that said you have to put these in the init methods rather than defining them as constants.