forked from TAIGA/TAIGA
fixed #174: added missing safety factor to division
Signed-off-by: Giovanni Harting <539@idlegandalf.com>
This commit is contained in:
@@ -13,22 +13,22 @@ public class TraitHeroic extends AbstractTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float damage(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, float
|
public float damage(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, float newDamage, boolean isCritical) {
|
||||||
newDamage, boolean isCritical) {
|
|
||||||
int durability = ToolHelper.getCurrentDurability(tool);
|
int durability = ToolHelper.getCurrentDurability(tool);
|
||||||
int durabilitymax = ToolHelper.getMaxDurability(tool);
|
int durabilitymax = ToolHelper.getMaxDurability(tool);
|
||||||
|
|
||||||
int safeDenominator = durabilitymax - durability - 1;
|
int safeDenominator = durabilitymax - durability - 1;
|
||||||
if (safeDenominator <= 0) {
|
if (safeDenominator <= 0) {
|
||||||
safeDenominator = 1;
|
safeDenominator = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
float calc;
|
float calc;
|
||||||
if ((durability * durabilitymax / (durabilitymax - durability - 1)) != 0) {
|
if ((durability * durabilitymax / (durabilitymax - durability - 1 / safeDenominator)) != 0) {
|
||||||
calc = newDamage + (newDamage / 2) / (durability * durabilitymax / safeDenominator);
|
calc = newDamage + (newDamage / 2) / (durability * durabilitymax / safeDenominator);
|
||||||
} else {
|
} else {
|
||||||
calc = newDamage + (newDamage / 2) / ((durability * durabilitymax / safeDenominator) + 1);
|
calc = newDamage + (newDamage / 2) / ((durability * durabilitymax / safeDenominator) + 1);
|
||||||
}
|
}
|
||||||
if ((float) durability < (float) (0.10 * durabilitymax) || player.getHealth() < player.getMaxHealth() / 8 ||
|
if ((float) durability < (float) (0.10 * durabilitymax) || player.getHealth() < player.getMaxHealth() / 8 || (target.getHealth() == target.getMaxHealth() && random.nextFloat() > 0.8)) {
|
||||||
(target.getHealth() == target.getMaxHealth() && random.nextFloat() > 0.8)) {
|
|
||||||
return super.damage(tool, player, target, damage, calc, isCritical);
|
return super.damage(tool, player, target, damage, calc, isCritical);
|
||||||
} else return super.damage(tool, player, target, damage, newDamage * 0.9f, isCritical);
|
} else return super.damage(tool, player, target, damage, newDamage * 0.9f, isCritical);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user