Fix Thorns enchantment bypassing ISpecialArmor.damageArmor function. Closes #2463

This commit is contained in:
LexManos 2016-05-28 22:49:54 -07:00
parent 2f5f9968e4
commit 5d2b8438c9

View file

@ -0,0 +1,43 @@
--- ../src-base/minecraft/net/minecraft/enchantment/EnchantmentThorns.java
+++ ../src-work/minecraft/net/minecraft/enchantment/EnchantmentThorns.java
@@ -51,12 +51,12 @@
if (itemstack != null)
{
- itemstack.func_77972_a(3, p_151367_1_);
+ damageArmor(itemstack, 3, p_151367_1_);
}
}
else if (itemstack != null)
{
- itemstack.func_77972_a(1, p_151367_1_);
+ damageArmor(itemstack, 1, p_151367_1_);
}
}
@@ -69,4 +69,25 @@
{
return p_92095_0_ > 10 ? p_92095_0_ - 10 : 1 + p_92095_1_.nextInt(4);
}
+
+ private void damageArmor(ItemStack stack, int amount, EntityLivingBase entity)
+ {
+ int slot = -1;
+ int x = 0;
+ for (ItemStack i : entity.func_184193_aE())
+ {
+ if (i == stack){
+ slot = x;
+ break;
+ }
+ x++;
+ }
+ if (slot == -1 || !(stack.func_77973_b() instanceof net.minecraftforge.common.ISpecialArmor))
+ {
+ stack.func_77972_a(1, entity);
+ return;
+ }
+ net.minecraftforge.common.ISpecialArmor armor = (net.minecraftforge.common.ISpecialArmor)stack.func_77973_b();
+ armor.damageArmor(entity, stack, DamageSource.func_92087_a(entity), amount, slot);
+ }
}