ForgePatch/patches/minecraft/net/minecraft/enchantment/EnchantmentThorns.java.patch

44 lines
1.4 KiB
Diff

--- ../src-base/minecraft/net/minecraft/enchantment/EnchantmentThorns.java
+++ ../src-work/minecraft/net/minecraft/enchantment/EnchantmentThorns.java
@@ -51,12 +51,12 @@
if (!itemstack.func_190926_b())
{
- itemstack.func_77972_a(3, p_151367_1_);
+ damageArmor(itemstack, 3, p_151367_1_);
}
}
else if (!itemstack.func_190926_b())
{
- 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);
+ }
}