From e2d4a5ff2794a4cd0a5050a6124954fad2de36c6 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Tue, 19 Sep 2023 11:43:21 -0700 Subject: [PATCH] Fix CachedToAABBs when offset becomes zero If the offset were to be undone, then it would incorrectly mark the cache as not having an offset when it actually did. --- ...hly-optimise-single-and-multi-AABB-VoxelSha.patch | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/patches/server/0027-fixup-Highly-optimise-single-and-multi-AABB-VoxelSha.patch b/patches/server/0027-fixup-Highly-optimise-single-and-multi-AABB-VoxelSha.patch index 6f128c98c0..e3191eaf5c 100644 --- a/patches/server/0027-fixup-Highly-optimise-single-and-multi-AABB-VoxelSha.patch +++ b/patches/server/0027-fixup-Highly-optimise-single-and-multi-AABB-VoxelSha.patch @@ -2176,10 +2176,10 @@ index 0000000000000000000000000000000000000000..1cb96b09375770f92f3e494ce2f28d9f +} diff --git a/src/main/java/io/papermc/paper/util/collisions/CachedToAABBs.java b/src/main/java/io/papermc/paper/util/collisions/CachedToAABBs.java new file mode 100644 -index 0000000000000000000000000000000000000000..7aa8a16b5a58b709f644ff3600a4dd9b5e0b501d +index 0000000000000000000000000000000000000000..85c448a775f60ca4b4a4f2baf17487ef45bdd383 --- /dev/null +++ b/src/main/java/io/papermc/paper/util/collisions/CachedToAABBs.java -@@ -0,0 +1,37 @@ +@@ -0,0 +1,39 @@ +package io.papermc.paper.util.collisions; + +import net.minecraft.world.phys.AABB; @@ -2208,13 +2208,15 @@ index 0000000000000000000000000000000000000000..7aa8a16b5a58b709f644ff3600a4dd9b + } + + public static CachedToAABBs offset(final CachedToAABBs cache, final double offX, final double offY, final double offZ) { ++ if (offX == 0.0 && offY == 0.0 && offZ == 0.0) { ++ return cache; ++ } ++ + final double resX = cache.offX + offX; + final double resY = cache.offY + offY; + final double resZ = cache.offZ + offZ; + -+ final boolean isOffset = resX != 0.0 || resY != 0.0 || resZ != 0.0; -+ -+ return new CachedToAABBs(cache.aabbs, isOffset, resX, resY, resZ); ++ return new CachedToAABBs(cache.aabbs, true, resX, resY, resZ); + } +} diff --git a/src/main/java/io/papermc/paper/util/collisions/FlatBitsetUtil.java b/src/main/java/io/papermc/paper/util/collisions/FlatBitsetUtil.java