From 4f772e2b4892046c3b324af820cf8cdb87db3be8 Mon Sep 17 00:00:00 2001 From: piexel Date: Fri, 6 Nov 2026 12:29:55 +0100 Subject: [PATCH] Remember the cavern slices of a 4 by 4 window of chunks A chunk and its eight neighbours no longer share a place, so the apply stage reading across a border does not rebuild a chunk's slices on every block. --- .../java/art/arcane/iris/core/modules/CarvedVoids.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/art/arcane/iris/core/modules/CarvedVoids.java b/core/src/main/java/art/arcane/iris/core/modules/CarvedVoids.java index ec09acc8f..b6ba9e0de 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/CarvedVoids.java +++ b/core/src/main/java/art/arcane/iris/core/modules/CarvedVoids.java @@ -55,7 +55,10 @@ final class CarvedVoids implements MantleLayer { private static final int CHUNK_SHIFT = 4; private static final int SECTION_SHIFT = 4; private static final int LOCAL_MASK = 15; - private static final int RECENT_CHUNKS = 8; + /** The chunks it remembers are those of a 4 by 4 window, so a chunk and the eight around it never share a place. */ + private static final int RECENT_SIDE_BITS = 2; + private static final int RECENT_SIDE_MASK = (1 << RECENT_SIDE_BITS) - 1; + private static final int RECENT_CHUNKS = 1 << (2 * RECENT_SIDE_BITS); private static final String READ_ONLY = "This view only reads the carved voids; mantle stages write them on the mantle itself"; private final BlockBox bounds; @@ -157,7 +160,7 @@ final class CarvedVoids implements MantleLayer { } private ChunkSlices slicesAt(int chunkX, int chunkZ) { - int slot = (chunkX * 31 + chunkZ) & (RECENT_CHUNKS - 1); + int slot = ((chunkX & RECENT_SIDE_MASK) << RECENT_SIDE_BITS) | (chunkZ & RECENT_SIDE_MASK); ChunkSlices known = recent[slot]; if (known != null && known.chunkX == chunkX && known.chunkZ == chunkZ) { return known;