diff options
author | Wesley Wolfe <weswolf@aol.com> | 2012-06-23 08:31:01 -0500 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2012-06-27 21:17:20 -0500 |
commit | f5b6abfae1377905e6fc2c46e36dfe2279c48b2b (patch) | |
tree | c3f71da0f8a4b506ba899e8e4194a336eadad370 /src/main/java | |
parent | 412b7eaa12f2ea3dd8b2e8f114aff5e543b0cf73 (diff) | |
download | craftbukkit-f5b6abfae1377905e6fc2c46e36dfe2279c48b2b.tar craftbukkit-f5b6abfae1377905e6fc2c46e36dfe2279c48b2b.tar.gz craftbukkit-f5b6abfae1377905e6fc2c46e36dfe2279c48b2b.tar.lz craftbukkit-f5b6abfae1377905e6fc2c46e36dfe2279c48b2b.tar.xz craftbukkit-f5b6abfae1377905e6fc2c46e36dfe2279c48b2b.zip |
Fix double overflow/underflow calculations with explosions. Fixes BUKKIT-1865
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/net/minecraft/server/Explosion.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java index e4ba3207..c1582f66 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -108,17 +108,26 @@ public class Explosion { for (int k2 = 0; k2 < list.size(); ++k2) { Entity entity = (Entity) list.get(k2); - double d7 = entity.f(this.posX, this.posY, this.posZ) / (double) this.size; + // CraftBukkit - start + d0 = entity.locX - this.posX; + d1 = entity.locY - this.posY; + d2 = entity.locZ - this.posZ; + double d8 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); + + double d7 = d8 / this.size; // Don't call sub-method and sqrt again if (d7 <= 1.0D) { - d0 = entity.locX - this.posX; - d1 = entity.locY - this.posY; - d2 = entity.locZ - this.posZ; - double d8 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); // CraftBukkit - - d0 /= d8; - d1 /= d8; - d2 /= d8; + // Moved calculations up + if (d8 != 0) { + d0 /= d8; + d1 /= d8; + d2 /= d8; + } else { // Compensate for underflow + d0 = 0d; + d1 = 0d; + d2 = 0d; + } + // CraftBukkit - end double d9 = (double) this.world.a(vec3d, entity.boundingBox); double d10 = (1.0D - d7) * d9; |