diff --git a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java index 1656357..086b110 100644 --- a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java +++ b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java @@ -143,14 +143,11 @@ public class CinderEventHandler implements IFuelHandler { float[] durabilityThresholds = {0.5f, 0.4f, 0.25f}; double[] probabilities = {0.0005, 0.001, 0.005}; - LOTREnchantment sturdy = LOTREnchantment.getEnchantmentByName("meleeSturdy"); - boolean hasSturdy = LOTREnchantmentHelper.hasEnchant(weapon, sturdy); float durabilityPercent = (weapon.getMaxDamage() - weapon.getItemDamage()) / (float)weapon.getMaxDamage(); for (int i = 0; i < durabilityThresholds.length; i++) { if (durabilityPercent <= durabilityThresholds[i]) { - double chance = probabilities[i] * (hasSturdy ? 0.5 : 1.0); - if (random.nextDouble() <= chance) { + if (random.nextDouble() <= probabilities[i]) { addNegativeModifier(weapon, player, "weapon"); } break; @@ -301,6 +298,16 @@ public class CinderEventHandler implements IFuelHandler { world.playSoundEffect(x, y, z, "mob.irongolem.hit", 1.0F, 2.0F); } private void addNegativeModifier(ItemStack item, EntityPlayerMP player, String type) { + //Sturdy Check + LOTREnchantment sturdy = type.equals("weapon") + ? LOTREnchantment.getEnchantmentByName("meleeSturdy") + : type.equals("armor") + ? LOTREnchantment.getEnchantmentByName("armorSturdy") + : null; + + if (sturdy != null && LOTREnchantmentHelper.hasEnchant(item, sturdy)) + return; + NBTTagCompound tag = item.getTagCompound(); if (tag == null) { tag = new NBTTagCompound();