From fc1a197de2f35d39eac8e585d425d62935d15d98 Mon Sep 17 00:00:00 2001 From: Bjarne Koll <32834385+lynxplay@users.noreply.github.com> Date: Fri, 9 Jul 2021 03:18:32 +0200 Subject: [PATCH] Ensure shulker bounding box is updated (#6010) Co-authored-by: Jake Potrebic --- ...sure-Entity-AABB-s-are-never-invalid.patch | 26 ++++++++++++++----- .../MC-4-Fix-item-position-desync.patch | 10 +++---- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/patches/server/Ensure-Entity-AABB-s-are-never-invalid.patch b/patches/server/Ensure-Entity-AABB-s-are-never-invalid.patch index 97eb5627be..3607da3d2d 100644 --- a/patches/server/Ensure-Entity-AABB-s-are-never-invalid.patch +++ b/patches/server/Ensure-Entity-AABB-s-are-never-invalid.patch @@ -9,10 +9,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + } public void setPos(double x, double y, double z) { - this.setPosRaw(x, y, 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 } @@ -21,12 +23,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public final void setPosRaw(double x, double y, double z) { -+ // 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) && (this.position.x != x || this.position.y != y || this.position.z != z)) { -+ this.setBoundingBox(this.dimensions.makeBoundingBox(x, y, 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); +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + } + } + ++ // 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() {} diff --git a/patches/server/MC-4-Fix-item-position-desync.patch b/patches/server/MC-4-Fix-item-position-desync.patch index 53d77697f4..ec65fc5778 100644 --- a/patches/server/MC-4-Fix-item-position-desync.patch +++ b/patches/server/MC-4-Fix-item-position-desync.patch @@ -46,8 +46,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n } - - public final void setPosRaw(double x, double y, double z) { + public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) { + // Paper end + // Paper start - fix MC-4 + if (this instanceof ItemEntity) { + if (com.destroystokyo.paper.PaperConfig.fixEntityPositionDesync) { @@ -58,6 +58,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + // Paper end - fix MC-4 - // 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) && (this.position.x != x || this.position.y != y || this.position.z != z)) { + 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);