aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0420-Ensure-Entity-AABB-s-are-never-invalid.patch
blob: 0779b97f5510d1ff31827c4b05267bf94d4fe7b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 283c541a431aad061da20f9bff49cb8686a24cd7..5a1959a16070a49e935bfd7a43fbf3fabdd2b1e6 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -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() {
@@ -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
         // 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());
@@ -4230,6 +4235,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
             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() {}