Skip to content

Commit

Permalink
Check if item is damageable (Fixes #118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrbysco committed Jan 18, 2025
1 parent fbfe8b3 commit 2180b53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public interface IForceChargingTool {
static final int FORCE_DMG_RATIO = 25;

default int damageItem(ItemStack stack, int amount) {
if (!stack.isDamageableItem()) return 0;
int forceDrain = amount * FORCE_DMG_RATIO;

ForceToolData fd = new ForceToolData(stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.level.Level;

import org.jetbrains.annotations.Nullable;

import java.util.Map;

public class TransmutationRecipe implements CraftingRecipe {
Expand Down Expand Up @@ -157,7 +157,8 @@ public NonNullList<ItemStack> getRemainingItems(CraftingContainer inv) {
if (itemstack1.getItem().getDamage(itemstack1) >= itemstack1.getMaxDamage()) {
itemstack1.shrink(1);
} else {
itemstack1.setDamageValue(itemstack1.getDamageValue() + damage);
if (damage > 0)
itemstack1.setDamageValue(itemstack1.getDamageValue() + damage);
nonnulllist.set(i, itemstack1);
}
continue;
Expand Down

0 comments on commit 2180b53

Please sign in to comment.