2
0
Fork 0

Fixed Sturdy only applying to weapons

Also made sturdy entirely negate obtaining negative modifiers
main
KeyLime17 5 months ago
parent d96df8dde2
commit 064801f3d3

@ -143,14 +143,11 @@ public class CinderEventHandler implements IFuelHandler {
float[] durabilityThresholds = {0.5f, 0.4f, 0.25f}; float[] durabilityThresholds = {0.5f, 0.4f, 0.25f};
double[] probabilities = {0.0005, 0.001, 0.005}; 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(); float durabilityPercent = (weapon.getMaxDamage() - weapon.getItemDamage()) / (float)weapon.getMaxDamage();
for (int i = 0; i < durabilityThresholds.length; i++) { for (int i = 0; i < durabilityThresholds.length; i++) {
if (durabilityPercent <= durabilityThresholds[i]) { if (durabilityPercent <= durabilityThresholds[i]) {
double chance = probabilities[i] * (hasSturdy ? 0.5 : 1.0); if (random.nextDouble() <= probabilities[i]) {
if (random.nextDouble() <= chance) {
addNegativeModifier(weapon, player, "weapon"); addNegativeModifier(weapon, player, "weapon");
} }
break; break;
@ -301,6 +298,16 @@ public class CinderEventHandler implements IFuelHandler {
world.playSoundEffect(x, y, z, "mob.irongolem.hit", 1.0F, 2.0F); world.playSoundEffect(x, y, z, "mob.irongolem.hit", 1.0F, 2.0F);
} }
private void addNegativeModifier(ItemStack item, EntityPlayerMP player, String type) { 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(); NBTTagCompound tag = item.getTagCompound();
if (tag == null) { if (tag == null) {
tag = new NBTTagCompound(); tag = new NBTTagCompound();

Loading…
Cancel
Save