Ammo reinforced modifier support (#140)

This commit is contained in:
Nova authored and GitHub committed 2024-12-21 10:28:08 -06:00
1 parent a3dae07fb5
commit 012e6fe2cd
3 files changed
+22 -7

No files matched your search

@@ -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());
}