Files
TinkersConstruct/src/main/java/tconstruct/weaponry/WeaponryActiveToolMod.java
T

33 lines
1.3 KiB
Java
Raw Normal View History

package tconstruct.weaponry;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.ActiveToolMod;
import tconstruct.library.weaponry.IAmmo;
public class WeaponryActiveToolMod extends ActiveToolMod {
@Override
public boolean damageTool(ItemStack stack, int damage, EntityLivingBase entity) {
// does not proc on tool 'healing'
if (stack.getItem() == TinkerWeaponry.javelin && stack.hasTagCompound() && damage > 0) {
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
IAmmo ammo = (IAmmo) stack.getItem();
if (tags.getInteger("Damage") == 0) {
int rem = ammo.consumeAmmo(1, stack);
if (rem > 0) return true;
} else if (ammo.getAmmoCount(stack) > 0) {
int d = tags.getInteger("Damage") + damage;
int max = tags.getInteger("TotalDurability");
if (d > max) {
tags.setInteger("Damage", 0);
return true;
}
}
}
2014-11-08 11:38:31 +01:00
// all other ammo items can't be damaged
else if (stack.getItem() instanceof IAmmo) return true;
return false;
}
}