From b59052566bac09ce537a09b7995b5e42fe75b8de Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 10 May 2020 22:14:47 -0400 Subject: [PATCH] Ensure Entity AABB's are never invalid If anything used setPositionRaw, it left potential for an AABB to be left stale at their old location, which could cause massive AABB boxes if movement ever then got called on the new position. This guarantees any time we set the entities position, we also update their AABB. --- ...sure-Entity-AABB-s-are-never-invalid.patch | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Spigot-Server-Patches/0514-Ensure-Entity-AABB-s-are-never-invalid.patch diff --git a/Spigot-Server-Patches/0514-Ensure-Entity-AABB-s-are-never-invalid.patch b/Spigot-Server-Patches/0514-Ensure-Entity-AABB-s-are-never-invalid.patch new file mode 100644 index 0000000000..d7dd3f6ff6 --- /dev/null +++ b/Spigot-Server-Patches/0514-Ensure-Entity-AABB-s-are-never-invalid.patch @@ -0,0 +1,55 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Sun, 10 May 2020 22:12:46 -0400 +Subject: [PATCH] Ensure Entity AABB's are never invalid + +If anything used setPositionRaw, it left potential for an AABB +to be left stale at their old location, which could cause massive +AABB boxes if movement ever then got called on the new position. + +This guarantees any time we set the entities position, we also +update their AABB. + +diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java +index cd2c183828c884ae6f9350009475a7a83982a2f8..149c22e6d5c5974250b04a20dd2a8c8379a8f7c3 100644 +--- a/src/main/java/net/minecraft/server/Entity.java ++++ b/src/main/java/net/minecraft/server/Entity.java +@@ -415,10 +415,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + + public void setPosition(double d0, double d1, double d2) { + this.setPositionRaw(d0, d1, d2); +- float f = this.size.width / 2.0F; +- float f1 = this.size.height; +- +- this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f)); ++ // Paper start - move into setPositionRaw ++ //float f = this.size.width / 2.0F; ++ //float f1 = this.size.height; ++ //this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f)); ++ // Paper end + if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit + } + +@@ -2980,6 +2981,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + return new AxisAlignedBB(vec3d, vec3d1); + } + ++ public final void setBoundingBox(AxisAlignedBB axisalignedbb) { a(axisalignedbb); } // Paper - OBFHELPER + public void a(AxisAlignedBB axisalignedbb) { + // CraftBukkit start - block invalid bounding boxes + double minX = axisalignedbb.minX, +@@ -3438,6 +3440,14 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + } + + public void setPositionRaw(double d0, double d1, double d2) { ++ // Paper start - never allow AABB to become desynced from position ++ // hanging has its own special logic ++ if (!(this instanceof EntityHanging) && (locX != d0 || locY != d1 || locZ != d2)) { ++ float f = this.size.width / 2.0F; ++ float f1 = this.size.height; ++ this.setBoundingBox(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f)); ++ } ++ // Paper end + this.locX = d0; + this.locY = d1; + this.locZ = d2;