diff options
author | Spottedleaf <[email protected]> | 2023-12-14 18:57:17 -0800 |
---|---|---|
committer | Spottedleaf <[email protected]> | 2023-12-14 18:57:17 -0800 |
commit | f1820dc80a02009980e6466ea5847933861b911a (patch) | |
tree | 66798f85913fd62d20be01a35a91e57618afe67a | |
parent | 7e15d977ecce23ee72b059e9be292d983a336c50 (diff) | |
download | Paper-f1820dc80a02009980e6466ea5847933861b911a.tar.gz Paper-f1820dc80a02009980e6466ea5847933861b911a.zip |
Fix incorrect border collision detection
The epsilon used was in the opposite direction, which would cause
the getCollisions method to incorrectly return it for when players
were exactly on the border but not colliding. To bring it in-line
with the rest of the collision code, the collision must be into
the border by +EPSILON.
Fixes https://github.com/PaperMC/Paper/issues/9859
-rw-r--r-- | patches/server/0720-Collision-optimisations.patch | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/patches/server/0720-Collision-optimisations.patch b/patches/server/0720-Collision-optimisations.patch index 4cf76f9bb1..62c51edd7e 100644 --- a/patches/server/0720-Collision-optimisations.patch +++ b/patches/server/0720-Collision-optimisations.patch @@ -105,10 +105,10 @@ index be668387f65a633c6ac497fca632a4767a1bf3a2..e08f4e39db4ee3fed62e37364d17dcc5 } diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java new file mode 100644 -index 0000000000000000000000000000000000000000..bfb1de19f53d5d7c7b65e25a606fabfa416706b3 +index 0000000000000000000000000000000000000000..5d4c5cc8eb06f2e6c31df6cbb98ea642b2264d49 --- /dev/null +++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java -@@ -0,0 +1,1876 @@ +@@ -0,0 +1,1878 @@ +package io.papermc.paper.util; + +import io.papermc.paper.util.collisions.CachedShapeData; @@ -1684,13 +1684,15 @@ index 0000000000000000000000000000000000000000..bfb1de19f53d5d7c7b65e25a606fabfa + + public static boolean isCollidingWithBorderEdge(final WorldBorder worldborder, final double boxMinX, final double boxMaxX, + final double boxMinZ, final double boxMaxZ) { -+ final double borderMinX = worldborder.getMinX() + COLLISION_EPSILON; // -X -+ final double borderMaxX = worldborder.getMaxX() - COLLISION_EPSILON; // +X ++ final double borderMinX = worldborder.getMinX(); // -X ++ final double borderMaxX = worldborder.getMaxX(); // +X + -+ final double borderMinZ = worldborder.getMinZ() + COLLISION_EPSILON; // -Z -+ final double borderMaxZ = worldborder.getMaxZ() - COLLISION_EPSILON; // +Z ++ final double borderMinZ = worldborder.getMinZ(); // -Z ++ final double borderMaxZ = worldborder.getMaxZ(); // +Z + -+ return boxMinX < borderMinX || boxMaxX > borderMaxX || boxMinZ < borderMinZ || boxMaxZ > borderMaxZ; ++ // inverted check for world border enclosing the specified box expanded by -EPSILON ++ return (borderMinX - boxMinX) > CollisionUtil.COLLISION_EPSILON || (borderMaxX - boxMaxX) < -CollisionUtil.COLLISION_EPSILON || ++ (borderMinZ - boxMinZ) > CollisionUtil.COLLISION_EPSILON || (borderMaxZ - boxMaxZ) < -CollisionUtil.COLLISION_EPSILON; + } + + /* Math.max/min specify that any NaN argument results in a NaN return, unlike these functions */ |