Skip to content

Commit

Permalink
Found some piece of code that already does that
Browse files Browse the repository at this point in the history
  • Loading branch information
Intybyte committed Sep 26, 2024
1 parent 07888f4 commit c163534
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm;
import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEnchantment;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
Expand Down Expand Up @@ -113,10 +114,7 @@ private static void damageFlintAndSteel(ItemStack flintAndSteel, Block smelteryB
Enchantment unbreaking = VersionedEnchantment.UNBREAKING;
int lvl = flintAndSteel.getEnchantmentLevel(unbreaking);

//Calculation from https://minecraft.fandom.com/wiki/Unbreaking
double breakingChance = 1.0 / (lvl + 1.0);

if (ThreadLocalRandom.current().nextDouble() < breakingChance) {
if (UnbreakingAlgorithm.TOOLS.evaluate(lvl)) {
damageable.setDamage(damageable.getDamage() + 1);
}

Expand Down

0 comments on commit c163534

Please sign in to comment.