Replace Double.isFinite with inhouse method
Double#isFinite is java 1.8 dependant, our inhouse method does exactly the same but isn't.
This commit is contained in:
parent
8eec4744dd
commit
2cd6769481
@ -626,13 +626,13 @@ public class MUtil
|
||||
public static void setDamage(EntityDamageEvent event, double newDamage)
|
||||
{
|
||||
// Check New Damage
|
||||
if ( ! Double.isFinite(newDamage)) throw new IllegalStateException("not finite newDamage: " + newDamage);
|
||||
if ( ! isFinite(newDamage)) throw new IllegalStateException("not finite newDamage: " + newDamage);
|
||||
|
||||
// Get Old Damage
|
||||
final double oldDamage = event.getDamage(DamageModifier.BASE);
|
||||
|
||||
// Check Old Damage
|
||||
if ( ! Double.isFinite(oldDamage)) throw new IllegalStateException("not finite oldDamage: " + oldDamage);
|
||||
if ( ! isFinite(oldDamage)) throw new IllegalStateException("not finite oldDamage: " + oldDamage);
|
||||
|
||||
// No Change?
|
||||
if (newDamage == oldDamage) return;
|
||||
@ -644,7 +644,7 @@ public class MUtil
|
||||
final double factor = newDamage / oldDamage;
|
||||
|
||||
// Check Factor
|
||||
if ( ! Double.isFinite(factor)) throw new IllegalStateException("not finite factor: " + factor + " damage: " + newDamage + " oldDamage: " + oldDamage);
|
||||
if ( ! isFinite(factor)) throw new IllegalStateException("not finite factor: " + factor + " damage: " + newDamage + " oldDamage: " + oldDamage);
|
||||
|
||||
// Now scale all damage modifiers!
|
||||
for (DamageModifier modifier : DamageModifier.values())
|
||||
@ -669,7 +669,7 @@ public class MUtil
|
||||
public static void scaleDamage(EntityDamageEvent event, double factor)
|
||||
{
|
||||
// Clean Input
|
||||
if ( ! Double.isFinite(factor)) throw new IllegalStateException("not finite factor: " + factor);
|
||||
if ( ! isFinite(factor)) throw new IllegalStateException("not finite factor: " + factor);
|
||||
|
||||
// No Change?
|
||||
if (factor == 1) return;
|
||||
@ -684,6 +684,12 @@ public class MUtil
|
||||
}
|
||||
}
|
||||
|
||||
// isFinite check recreation to be compatible with java 1.7/1.6
|
||||
public static boolean isFinite(double d)
|
||||
{
|
||||
return Math.abs(d) <= Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// GET IP
|
||||
// -------------------------------------------- //
|
||||
|
Loading…
Reference in New Issue
Block a user