mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Javelins now can be used properly as melee and ranged weapons
This commit is contained in:
1 parent
62904b92dc
commit
9d7d33fea3
4 files changed
+44
-2
No files matched your search
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user