diff --git a/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java b/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java index 06fb60ca..42682931 100644 --- a/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java +++ b/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java @@ -107,10 +107,10 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon, } protected void launchProjectile(ItemStack stack, World world, EntityPlayer player, int time) { + ItemStack reference = stack.copy(); + reference.stackSize = 1; // spawn projectile on server if (!world.isRemote) { - ItemStack reference = stack.copy(); - reference.stackSize = 1; ((IAmmo) reference.getItem()).setAmmo(1, reference); Entity projectile = createProjectile(reference, world, player, getAccuracy(stack, time), time); @@ -118,7 +118,14 @@ public abstract class AmmoWeapon extends AmmoItem implements IBattlegearWeapon, } // reduce ammo - if (!player.capabilities.isCreativeMode) this.consumeAmmo(1, stack); + if (!player.capabilities.isCreativeMode) { + if (reference.hasTagCompound()) { + if (random.nextInt(10) + < 10 - reference.getTagCompound().getCompoundTag("InfiTool").getInteger("Unbreaking")) { + this.consumeAmmo(1, stack); + } + } + } } protected abstract Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy, diff --git a/src/main/java/tconstruct/library/weaponry/ProjectileWeapon.java b/src/main/java/tconstruct/library/weaponry/ProjectileWeapon.java index 38b6eb8a..03f89230 100644 --- a/src/main/java/tconstruct/library/weaponry/ProjectileWeapon.java +++ b/src/main/java/tconstruct/library/weaponry/ProjectileWeapon.java @@ -199,8 +199,12 @@ public abstract class ProjectileWeapon extends ToolCore implements IBattlegearWe // use up ammo if (!player.capabilities.isCreativeMode) { - if (ammo.getItem() instanceof IAmmo) ((IAmmo) ammo.getItem()).consumeAmmo(1, ammo); - else player.inventory.consumeInventoryItem(ammo.getItem()); + if (ammo.getItem() instanceof IAmmo) { + if (ammo.hasTagCompound()) { + int ammoReinforced = ammo.getTagCompound().getCompoundTag("InfiTool").getInteger("Unbreaking"); + if (random.nextInt(10) < 10 - ammoReinforced) ((IAmmo) ammo.getItem()).consumeAmmo(1, ammo); + } else player.inventory.consumeInventoryItem(ammo.getItem()); + } } // FIREEEEEEE diff --git a/src/main/java/tconstruct/weaponry/weapons/Crossbow.java b/src/main/java/tconstruct/weaponry/weapons/Crossbow.java index 2f41184c..ae4d58b5 100644 --- a/src/main/java/tconstruct/weaponry/weapons/Crossbow.java +++ b/src/main/java/tconstruct/weaponry/weapons/Crossbow.java @@ -145,8 +145,12 @@ public class Crossbow extends ProjectileWeapon { tags.setBoolean("Loaded", true); // remove loaded item - if (ammo.getItem() instanceof IAmmo) ((IAmmo) ammo.getItem()).consumeAmmo(1, ammo); - else { + if (ammo.getItem() instanceof IAmmo) { + if (ammo.hasTagCompound()) { + int ammoReinforced = ammo.getTagCompound().getCompoundTag("InfiTool").getInteger("Unbreaking"); + if (random.nextInt(10) < 10 - ammoReinforced) ((IAmmo) ammo.getItem()).consumeAmmo(1, ammo); + } + } else { player.inventory.consumeInventoryItem(ammo.getItem()); }