From 694eacb9563ca9ac71f40d4dca9c7590671aea72 Mon Sep 17 00:00:00 2001 From: sisby-folk Date: Mon, 26 Aug 2024 17:43:31 +1000 Subject: [PATCH] fix damage checks --- .../tinkerers_smithing/recipe/SacrificeUpgradeRecipe.java | 5 +++-- .../tinkerers_smithing/recipe/SmithingUpgradeRecipe.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/folk/sisby/tinkerers_smithing/recipe/SacrificeUpgradeRecipe.java b/src/main/java/folk/sisby/tinkerers_smithing/recipe/SacrificeUpgradeRecipe.java index 97baf54..3140ede 100644 --- a/src/main/java/folk/sisby/tinkerers_smithing/recipe/SacrificeUpgradeRecipe.java +++ b/src/main/java/folk/sisby/tinkerers_smithing/recipe/SacrificeUpgradeRecipe.java @@ -45,8 +45,9 @@ public static int resultDamage(Item resultItem, int additionUnits, int resultUni public ItemStack craft(Inventory inventory) { ItemStack output = super.craft(inventory); ItemStack addition = inventory.getStack(1); - output.setDamage(resultDamage(output.getItem(), additionUnits, resultUnits, addition.getDamage(), addition.getMaxDamage())); - if (output.getDamage() > output.getMaxDamage()) return ItemStack.EMPTY; + int damage = resultDamage(output.getItem(), additionUnits, resultUnits, addition.getDamage(), addition.getMaxDamage()); + if (damage > output.getMaxDamage()) return ItemStack.EMPTY; + output.setDamage(damage); return output; } diff --git a/src/main/java/folk/sisby/tinkerers_smithing/recipe/SmithingUpgradeRecipe.java b/src/main/java/folk/sisby/tinkerers_smithing/recipe/SmithingUpgradeRecipe.java index 3218a01..50296d2 100644 --- a/src/main/java/folk/sisby/tinkerers_smithing/recipe/SmithingUpgradeRecipe.java +++ b/src/main/java/folk/sisby/tinkerers_smithing/recipe/SmithingUpgradeRecipe.java @@ -42,8 +42,9 @@ public static int resultDamage(Item resultItem, int additionCount, int usedCount public ItemStack craft(Inventory inventory) { ItemStack output = super.craft(inventory); int usedCount = Math.min(additionCount, inventory.getStack(1).getCount()); - output.setDamage(resultDamage(output.getItem(), additionCount, usedCount)); - if (output.getDamage() > output.getMaxDamage()) return ItemStack.EMPTY; + int damage = resultDamage(output.getItem(), additionCount, usedCount); + if (damage > output.getMaxDamage()) return ItemStack.EMPTY; + output.setDamage(damage); return output; }