From c10341af2b86063281a8d73287579ab10fdc291a Mon Sep 17 00:00:00 2001 From: piexel Date: Sat, 14 Nov 2026 21:10:16 +0100 Subject: [PATCH] Name the rule that the first listed cave owns a block --- .../iris/generation/mantle/ListedCaveCarving.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/art/arcane/iris/generation/mantle/ListedCaveCarving.java b/core/src/main/java/art/arcane/iris/generation/mantle/ListedCaveCarving.java index 2b3a25b09..29d9a8803 100644 --- a/core/src/main/java/art/arcane/iris/generation/mantle/ListedCaveCarving.java +++ b/core/src/main/java/art/arcane/iris/generation/mantle/ListedCaveCarving.java @@ -120,8 +120,7 @@ final class ListedCaveCarving { /** Carves the listed caves of the chunk into {@code sink}, under the surface and the fluids and ceilings that surround it. */ void carve(CaveListing listing, int chunkX, int chunkZ, ChunkSurface surface, CaveCellSink sink, CaveFluidSupportPlan fluidSupport) { boolean[] sealed = sealedColumns(surface.fluidBoundaries()); - for (int index = listing.caves().size() - 1; index >= 0; index--) { - ListedColumns listed = listing.caves().get(index); + for (ListedColumns listed : firstListedWritesLast(listing)) { ChunkColumns columns = new ChunkColumns(surface.surfaceY(), listed.weight(), sealed, surface.ceilings(), DepthRange.OWN); carveCave(listed.cave(), columns, listed.band(), surface, chunkX, chunkZ, sink, fluidSupport); } @@ -138,8 +137,7 @@ final class ListedCaveCarving { boolean[] sealed = new boolean[CHUNK_AREA]; Arrays.fill(sealed, true); ChunkSurface surface = new ChunkSurface(worldTop, null, null); - for (int index = listing.caves().size() - 1; index >= 0; index--) { - ListedColumns listed = listing.caves().get(index); + for (ListedColumns listed : firstListedWritesLast(listing)) { HeightBand band = new HeightBand(Math.max(listed.band().lowestY(), lowestUpperY), Math.min(listed.band().highestY(), world.height() - 1)); if (band.lowestY() > band.highestY()) { continue; @@ -149,6 +147,11 @@ final class ListedCaveCarving { } } + /** A block several caves carve is written by each in turn, so whoever writes last owns it: the first listed. */ + private static List firstListedWritesLast(CaveListing listing) { + return listing.caves().reversed(); + } + private void carveCave(ListedCave cave, ChunkColumns columns, HeightBand band, ChunkSurface surface, int chunkX, int chunkZ, CaveCellSink sink, CaveFluidSupportPlan fluidSupport) { int originX = PowerOfTwoCoordinates.chunkToBlock(chunkX);