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 diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 8e59a63e8c161e90ccff951ecb2b6530fadf3b80..df02a649ca99218745b7cd38e34edcabc2987255 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -595,8 +595,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i } public void setPos(double x, double y, double z) { - this.setPosRaw(x, y, z); - this.setBoundingBox(this.makeBoundingBox()); + this.setPosRaw(x, y, z, true); // Paper - force bounding box update + // this.setBoundingBox(this.makeBoundingBox()); // Paper - move into setPositionRaw } protected AABB makeBoundingBox() { @@ -3786,6 +3786,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i } public final void setPosRaw(double x, double y, double z) { + // Paper start + this.setPosRaw(x, y, z, false); + } + public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) { + // Paper end if (this.position.x != x || this.position.y != y || this.position.z != z) { this.position = new Vec3(x, y, z); int i = Mth.floor(x); @@ -3808,6 +3813,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i } } + // Paper start - never allow AABB to become desynced from position + // hanging has its own special logic + if (!(this instanceof net.minecraft.world.entity.decoration.HangingEntity) && (forceBoundingBoxUpdate || this.position.x != x || this.position.y != y || this.position.z != z)) { + this.setBoundingBox(this.makeBoundingBox()); + } + // Paper end } public void checkDespawn() {}