From d597c4927a83f4bb45fff9194f72dc672d4a26f1 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Thu, 14 Dec 2023 18:57:17 -0800 Subject: [PATCH] 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 --- patches/server/Collision-optimisations.patch | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/patches/server/Collision-optimisations.patch b/patches/server/Collision-optimisations.patch index ce53d7029a..ed97ab15d8 100644 --- a/patches/server/Collision-optimisations.patch +++ b/patches/server/Collision-optimisations.patch @@ -1684,13 +1684,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + 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 */