From 2b63a849d3cf31bdc1f78124917aca3fae0a10a2 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Tue, 19 Sep 2023 11:40:19 -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. --- .../moonrise/patches/collisions/shape/CachedToAABBs.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/shape/CachedToAABBs.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/shape/CachedToAABBs.java index af8ebe5..9d33ead 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/shape/CachedToAABBs.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/shape/CachedToAABBs.java @@ -26,12 +26,14 @@ public record CachedToAABBs( } 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); } }