2021-06-14 10:37:14 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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
2023-09-10 04:28:03 +02:00
index c99d24008792b07d5e2984261215de944482006b..ffd7e11b16604050e87a6b8aac08948fd3311bd1 100644
2021-06-14 10:37:14 +02:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2023-06-09 01:21:20 +02:00
@@ -721,8 +721,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
2021-07-09 03:18:32 +02:00
}
2021-06-14 10:37:14 +02:00
public void setPos(double x, double y, double z) {
2021-07-09 03:18:32 +02:00
- this.setPosRaw(x, y, z);
2021-06-14 10:37:14 +02:00
- this.setBoundingBox(this.makeBoundingBox());
2021-07-09 03:18:32 +02:00
+ this.setPosRaw(x, y, z, true); // Paper - force bounding box update
2021-06-14 10:37:14 +02:00
+ // this.setBoundingBox(this.makeBoundingBox()); // Paper - move into setPositionRaw
}
protected AABB makeBoundingBox() {
2023-07-04 10:22:56 +02:00
@@ -4196,6 +4196,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
2021-06-14 10:37:14 +02:00
}
public final void setPosRaw(double x, double y, double z) {
2021-07-09 03:18:32 +02:00
+ // Paper start
+ this.setPosRaw(x, y, z, false);
+ }
+ public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
2021-06-14 10:37:14 +02:00
+ // Paper end
2023-06-08 07:21:04 +02:00
// Paper start - rewrite chunk system
if (this.updatingSectionStatus) {
LOGGER.error("Refusing to update position for entity " + this + " to position " + new Vec3(x, y, z) + " since it is processing a section status update", new Throwable());
2023-07-04 10:22:56 +02:00
@@ -4219,6 +4224,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
2022-06-08 07:02:19 +02:00
this.levelCallback.onMove();
2021-07-09 03:18:32 +02:00
}
+ // 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() {}