PaperMC/patches/server/0420-Ensure-Entity-AABB-s-are-never-invalid.patch

47 lines
2.2 KiB
Diff
Raw Normal View History

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
index a9a845f6a7967d306ec935c4f32414053da591f0..886db1055c69f2b0ce7a5bf61e53d3b1119d2c19 100644
--- 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 {
}
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() {
2023-06-09 01:21:20 +02:00
@@ -4207,6 +4207,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
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
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-06-09 01:21:20 +02:00
@@ -4230,6 +4235,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
2022-06-08 07:02:19 +02:00
this.levelCallback.onMove();
}
+ // 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() {}