package com.zivilon.cinder_loe.items; import lotr.common.item.LOTRItemSpear; import lotr.common.item.LOTRItemSword; import lotr.common.item.LOTRMaterial; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; public class UnnamedSpear extends LOTRItemSpear { private static final double ARMOR_DAMAGE = 0.025; // Default is 5% public UnnamedSpear(LOTRMaterial material) { super(material); } @Override public boolean hitEntity(ItemStack itemStack, EntityLivingBase target, EntityLivingBase attacker) { if (target instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) target; for (int i = 0; i < 4; i++) { ItemStack armorPiece = player.getCurrentArmor(i); if (armorPiece != null) { int currentDurabilty = armorPiece.getMaxDamage() - armorPiece.getItemDamage(); int damageAmount = (int) (currentDurabilty * ARMOR_DAMAGE); if (damageAmount < 1) { damageAmount = 1; } armorPiece.damageItem(damageAmount, player); } } } return true; } }