Name the rule that the first listed cave owns a block

This commit is contained in:
piexel committed 2026-11-14 21:10:16 +01:00
1 parent 9d0f7a6887
commit c10341af2b
1 file changed
+7 -4
@@ -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<ListedColumns> 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);