-
Notifications
You must be signed in to change notification settings - Fork 753
/
WeaponryActiveToolMod.java
38 lines (35 loc) · 1.28 KB
/
WeaponryActiveToolMod.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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) {
if(stack.getItem() == TinkerWeaponry.javelin && stack.hasTagCompound()) {
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;
}
}
}
// all other ammo items can't be damaged
else if(stack.getItem() instanceof IAmmo)
return true;
return false;
}
}