Skip to content

Commit

Permalink
Ensure shulker bounding box is updated
Browse files Browse the repository at this point in the history
A previous paper patch introduced bounding box reuse for entities on
position updates if the x,y and z coordinate did not change.
While this reusing in itself works fine, shulkers do update their
bounding box without actually changing their x,y and z coordinates which
is not respected due to the old bounding box being reused.

This commit fixes this issue by manually updating the shulker bounding
box after reapplying the position.

Another alternative solution would have been an exception specifically
made for shulkers to ignore the reuse logic, tho this would introduce a
new instanceOf check into the Entity#setPosRaw method and would be
evaulated for every type of entity.

See also: https://github.com/PaperMC/Paper/blob/master/patches/server/0467-Ensure-Entity-AABB-s-are-never-invalid.patch
Resolves: 5915
  • Loading branch information
lynxplay committed Jun 26, 2021
1 parent 1c77d64 commit 6b1c9fc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions patches/server/0467-Ensure-Entity-AABB-s-are-never-invalid.patch
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ index 912723108af2ffe660f0c2e528e4e028f7f74bcb..b208f561ab8bb0ea9ad06fb2a30becef
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);
diff --git a/src/main/java/net/minecraft/world/entity/monster/Shulker.java b/src/main/java/net/minecraft/world/entity/monster/Shulker.java
index ca0d1c059a6ad94590bcbff34b37b9c13ef19474..c61f127342f404fbf766c64254fd191ff01f1507 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Shulker.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Shulker.java
@@ -236,6 +236,7 @@ public class Shulker extends AbstractGolem implements Enemy {

private void onPeekAmountChange() {
this.reapplyPosition();
+ this.setBoundingBox(this.makeBoundingBox()); // Paper - manually update bounding box as paper caches bounding box if the entity did not move (See Entity#setPosRaw)
float f = Shulker.getPhysicalPeek(this.currentPeekAmount);
float f1 = Shulker.getPhysicalPeek(this.currentPeekAmountO);
Direction enumdirection = this.getAttachFace().getOpposite();

0 comments on commit 6b1c9fc

Please sign in to comment.