2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3 KiB
Java

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