Skip to content

Commit

Permalink
Apply and items with 0 durability have one use left iirc, move a comm…
Browse files Browse the repository at this point in the history
…ent over
  • Loading branch information
Intybyte committed Oct 27, 2024
1 parent 6221de9 commit 5b0eabc
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.annotation.ParametersAreNonnullByDefault;

import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm;
import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedDurability;
import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEnchantment;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
Expand Down Expand Up @@ -93,7 +94,6 @@ public static boolean useFlintAndSteel(Player p, Block smelteryBlock) {

ItemStack item = inv.getItem(inv.first(Material.FLINT_AND_STEEL));

// Only damage the Flint and Steel if it isn't unbreakable.
damageFlintAndSteel(item, smelteryBlock);

SoundEffect.IGNITION_CHAMBER_USE_FLINT_AND_STEEL_SOUND.playAt(smelteryBlock);
Expand All @@ -104,6 +104,7 @@ private static void damageFlintAndSteel(ItemStack flintAndSteel, Block smelteryB
ItemMeta meta = flintAndSteel.getItemMeta();
Damageable damageable = (Damageable) meta;

// Only damage the Flint and Steel if it isn't unbreakable.
if (meta.isUnbreakable()) {
return;
}
Expand All @@ -115,7 +116,7 @@ private static void damageFlintAndSteel(ItemStack flintAndSteel, Block smelteryB
damageable.setDamage(damageable.getDamage() + 1);
}

if (damageable.getDamage() >= flintAndSteel.getType().getMaxDurability()) {
if (damageable.getDamage() > VersionedDurability.getDurability(flintAndSteel)) {
// The Flint and Steel broke
flintAndSteel.setAmount(0);
SoundEffect.LIMITED_USE_ITEM_BREAK_SOUND.playAt(smelteryBlock);
Expand Down

0 comments on commit 5b0eabc

Please sign in to comment.