diff --git a/README.md b/README.md index 180280cfe..5eb1b32c7 100644 --- a/README.md +++ b/README.md @@ -184,9 +184,9 @@ placement's own states). Its types answer with IrisApi, VolmLib and built-in val (`postProcessingWalls`, `postProcessingSlabs`) and the biome's `wall` and `slab` as module settings through its context. `iris:carve` also reads the mantle's matter slices through `MatterMantle` (a facade Iris's mantle implements: the chunk of -`MatterCavern`s and markers it plans and applies, which the platform and the rest of Iris read as slices, not as module layers) and asks -`CaveDressing` for what the biome layers, decorators and fluid palette give a cave's walls, floor and ceiling. `CaveDressing` is -transitional: it goes when `iris:terrain` and `iris:decorant` are modules of the same jar and carve asks their classes directly. +`MatterCavern`s and markers it plans and applies, which the platform and the rest of Iris read as slices, not as module layers). What a +cave's walls, floor and ceiling get comes from the terrain and decorant built-ins of the same jar (`terrain.BiomeLayers`, +`terrain.TerrainPalettes`, the biome decorators), through carve's own `CaveDressing`, which tests replace with fixed blocks. A cave's dimension, region and biome settings are found by the id the layout's biome samples carry (`DeclaredByLevel`), its absolute world Y bands convert with `PackWorld.minHeight()`, and its noise reads `NoiseSampler.signed(...)` (Iris's memoised signed read) and `scaled(...)`. `caveLavaHeight` and `upperDimensionCarving` are its dimension settings. diff --git a/builtin-modules.txt b/builtin-modules.txt index f1fa10c09..0ac32e0b4 100644 --- a/builtin-modules.txt +++ b/builtin-modules.txt @@ -41,6 +41,8 @@ module art.arcane.iris.engine.framework.vanillafeatures.VanillaFeaturesModule include art/arcane/iris/engine/framework/vanillafeatures/** module art.arcane.iris.engine.modifier.CarveModule include art/arcane/iris/engine/modifier/CaveApplying*.class +include art/arcane/iris/engine/modifier/CaveDressing.class +include art/arcane/iris/engine/modifier/BuiltInCaveDressing.class include art/arcane/iris/engine/modifier/CaveBiomeBands*.class include art/arcane/iris/engine/modifier/CaveBiomeCache.class include art/arcane/iris/engine/modifier/CaveBlockClasses.class diff --git a/src/main/java/art/arcane/iris/builtin/CaveDressing.java b/src/main/java/art/arcane/iris/builtin/CaveDressing.java deleted file mode 100644 index 14afe16e0..000000000 --- a/src/main/java/art/arcane/iris/builtin/CaveDressing.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Servers - * Copyright (c) 2026 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.builtin; - -import art.arcane.iris.builtin.decorant.DecorationPart; -import art.arcane.volmlib.util.math.RNG; -import com.volmit.block.BlockState; -import com.volmit.hunk.Hunk; -import com.volmit.resource.ResourceId; -import com.volmit.world.PackWorld; - -import java.util.List; - -/** - * What a cave's floor, ceiling and walls get from the rest of Iris's terrain and decoration: the blocks of a biome's layers - * and wall, its decorators and the fluid of the dimension's palette. Those features keep their workers per world and are - * ported on their own; until they are modules this narrow interface is the one thing {@code iris:carve} needs from them, in - * IrisApi's types, and Iris's worlds implement it ({@link Source}). - * - *

Transitional: when {@code iris:terrain} and {@code iris:decorant} are modules of the same jar, {@code iris:carve} asks - * their classes directly and this interface goes. - * - *

The methods that give a block take the {@code chunk} hunk the block is for. A block read from here and written to that - * hunk keeps the identity of a content plugin's custom block, as it did when the layers wrote the platform's states themselves. - */ -public interface CaveDressing { - /** The dressing of {@code world}, which must be a world Iris generates. */ - static CaveDressing of(PackWorld world) { - if (world instanceof Source source) { - return source.caveDressing(); - } - throw new IllegalArgumentException("Built-in modules generate Iris's own worlds, not " + world); - } - - /** Iris's worlds answer for their dressing. */ - interface Source { - CaveDressing caveDressing(); - } - - /** Whether the dimension's fluid palette gives a fluid (water, lava) at the column; false where it gives none. */ - boolean fluidPresentAt(int x, int z); - - /** The block the dimension's fluid palette gives at the column; null where it gives none. */ - BlockState fluidAt(Hunk chunk, int x, int z); - - /** The block the biome's wall gives at the position; null where the biome has no wall or the layer gives none. */ - BlockState wall(Hunk chunk, ResourceId biome, RNG rng, int x, int y, int z); - - /** The blocks the biome's surface layers stack up to at the column, top first, at most {@code depth} of them. */ - List floorLayers(Hunk chunk, ResourceId biome, int x, int z, RNG rng, int depth, int floorY); - - /** The blocks the biome's cave ceiling layers stack up to at the column, nearest the ceiling first, at most {@code depth} of them. */ - List ceilingLayers(Hunk chunk, ResourceId biome, int x, int z, RNG rng, int depth, int ceilingY); - - /** Whether the biome has a decorator for {@code part}. */ - boolean hasDecorators(ResourceId biome, DecorationPart part); - - /** - * Decorates a cave's floor in the column at {@code chunk}'s {@code localX}, {@code localZ} (world {@code x}, {@code z}) above - * the block at {@code floorY}, with the biome's decorators for {@link DecorationPart#NONE}, in a space {@code airThickness} high. - */ - void decorateFloor(Hunk chunk, int localX, int localZ, int x, int z, ResourceId biome, int floorY, int airThickness); - - /** Decorates a cave's ceiling the same way, from the block at {@code ceilingY} down, with the decorators for {@link DecorationPart#CEILING}. */ - void decorateCeiling(Hunk chunk, int localX, int localZ, int x, int z, ResourceId biome, int ceilingY, int airThickness); - - /** - * {@code layer}, the block a layer wants in the place of the ore {@code existing}, as the deepslate or the stone variant - * of the ore that fits the rock {@code existing} is; {@code layer} itself where it has no variant. - */ - BlockState deepSlateOre(Hunk chunk, BlockState existing, BlockState layer); -} diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java b/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java index 94745233d..2cebe417d 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java @@ -18,7 +18,6 @@ package art.arcane.iris.engine.mantle.components; -import art.arcane.iris.builtin.CaveDressing; import art.arcane.iris.builtin.MatterMantle; import art.arcane.iris.builtin.carve.CaveProfile; import art.arcane.iris.engine.object.terrain.carving.CarvingResolver; @@ -63,7 +62,7 @@ public class CaveCarving { private final CarveWorld world; private final DeclaredCaveProfiles declaredProfiles; private final CarvingResolver resolver; - private final CaveDressing dressing; + private final FluidColumns fluidColumns; private final boolean upperDimensionCarving; private final Object profileCarverLock = new Object(); private volatile Map profileCarvers = new IdentityHashMap<>(); @@ -81,11 +80,17 @@ public class CaveCarving { } } - public CaveCarving(PackWorld packWorld, CarveWorld world, boolean upperDimensionCarving) { + /** Whether the dimension's fluid palette gives a column a fluid, which caves near it blend towards. */ + @FunctionalInterface + public interface FluidColumns { + boolean hasFluid(int worldX, int worldZ); + } + + public CaveCarving(PackWorld packWorld, CarveWorld world, boolean upperDimensionCarving, FluidColumns fluidColumns) { this.world = world; this.declaredProfiles = DeclaredCaveProfiles.of(packWorld); this.resolver = CarvingResolver.of(packWorld); - this.dressing = CaveDressing.of(packWorld); + this.fluidColumns = fluidColumns; this.upperDimensionCarving = upperDimensionCarving; } @@ -430,7 +435,7 @@ public class CaveCarving { int worldZ = startZ + fieldZ; int fieldIndex = (fieldX * FIELD_SIZE) + fieldZ; blendScratch.fieldSurfaceHeights[fieldIndex] = terrain.surfaceY(worldX, worldZ); - blendScratch.fieldHasFluid[fieldIndex] = dressing.fluidPresentAt(worldX, worldZ); + blendScratch.fieldHasFluid[fieldIndex] = fluidColumns.hasFluid(worldX, worldZ); } } } diff --git a/src/main/java/art/arcane/iris/engine/modifier/BuiltInCaveDressing.java b/src/main/java/art/arcane/iris/engine/modifier/BuiltInCaveDressing.java new file mode 100644 index 000000000..e7ed1001a --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/BuiltInCaveDressing.java @@ -0,0 +1,111 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.decorant.DecorantSettings; +import art.arcane.iris.builtin.decorant.DecorationPart; +import art.arcane.iris.builtin.terrain.BiomeLayers; +import art.arcane.iris.builtin.terrain.ColumnSlope; +import art.arcane.iris.builtin.terrain.PaletteExplosion; +import art.arcane.iris.builtin.terrain.TerrainPalettes; +import art.arcane.iris.engine.decorator.BiomeDecorators; +import art.arcane.iris.engine.decorator.DecoratedBiome; +import art.arcane.iris.engine.decorator.DecorationScene; +import art.arcane.iris.engine.decorator.IrisCeilingDecorator; +import art.arcane.iris.engine.decorator.IrisSurfaceDecorator; +import art.arcane.volmlib.util.math.RNG; +import com.volmit.block.BlockRegistry; +import com.volmit.block.BlockState; +import com.volmit.config.FeatureSettings; +import com.volmit.resource.ResourceId; +import com.volmit.stage.ChunkStageContext; +import com.volmit.world.BiomeKind; +import com.volmit.world.TerrainSampler; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** A chunk's {@link CaveDressing} from the world's biome layers, terrain palettes and decorators, which carving shares with the terrain and decorant built-ins. */ +final class BuiltInCaveDressing implements CaveDressing { + private final BiomeLayers layers; + private final TerrainPalettes palettes; + private final FeatureSettings settings; + private final BlockRegistry blocks; + private final PaletteExplosion explosion; + private final ColumnSlope slope; + private final DecorationScene scene; + private final Map decoratedBiomes = new HashMap<>(); + + BuiltInCaveDressing(ChunkStageContext context) { + TerrainSampler terrain = context.terrain(); + this.layers = BiomeLayers.of(context.world()); + this.palettes = TerrainPalettes.of(context.world()); + this.settings = context.settings(); + this.blocks = context.resources().blocks(); + this.explosion = PaletteExplosion.of(settings, context.originX(), context.originZ()); + this.slope = (x, z) -> terrain.column((int) x, (int) z).slope(); + this.scene = DecorationScene.of(context); + } + + @Override + public BlockState fluidAt(int x, int z) { + return palettes.fluidAt(x, z); + } + + @Override + public BlockState wall(ResourceId biome, RNG rng, int x, int y, int z) { + return layers.wall(layers.biome(biome, settings)).get(rng, x, y, z); + } + + @Override + public List floorLayers(ResourceId biome, int x, int z, RNG rng, int depth, int floorY) { + return layers.generateLayers(layers.biome(biome, settings), explosion, x, z, rng, depth, floorY, slope); + } + + @Override + public List ceilingLayers(ResourceId biome, int x, int z, RNG rng, int depth) { + return layers.generateCeilingLayers(layers.biome(biome, settings), explosion, x, z, rng, depth); + } + + @Override + public boolean hasDecorators(ResourceId biome, DecorationPart part) { + return scene.decorators().hasDecorators(decorated(biome), part); + } + + @Override + public void decorateFloor(int localX, int localZ, int x, int z, ResourceId biome, int floorY, int airThickness) { + new IrisSurfaceDecorator(scene).decorate(localX, localZ, x, x, x, z, z, z, decorated(biome), floorY, airThickness); + } + + @Override + public void decorateCeiling(int localX, int localZ, int x, int z, ResourceId biome, int ceilingY, int airThickness) { + new IrisCeilingDecorator(scene).decorate(localX, localZ, x, x, x, z, z, z, decorated(biome), ceilingY, airThickness); + } + + @Override + public BlockState oreFor(BlockState rock, BlockState ore) { + return blocks.oreFor(rock, ore); + } + + /** The decorators' view of a cave biome: what it declares, under the key its settings come from, as other decorated biomes are. */ + private DecoratedBiome decorated(ResourceId biome) { + return decoratedBiomes.computeIfAbsent(biome, id -> new DecoratedBiome(BiomeDecorators.biomeKey(id), + settings.declaredBy(id, DecorantSettings.class).orElse(null), BiomeKind.CAVE)); + } +} diff --git a/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java b/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java index 0c484456d..eddf4d1a4 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java @@ -28,6 +28,7 @@ import art.arcane.iris.builtin.carve.CaveDepthSettings; import art.arcane.iris.builtin.carve.CaveLavaHeightSettings; import art.arcane.iris.builtin.carve.CaveProfile; import art.arcane.iris.builtin.carve.UpperDimensionCarvingSettings; +import art.arcane.iris.builtin.terrain.TerrainPalettes; import art.arcane.iris.engine.mantle.components.CarveWorld; import art.arcane.iris.engine.mantle.components.CaveCarving; import com.volmit.FeatureRegistry; @@ -38,7 +39,9 @@ import com.volmit.config.FeatureSettings; import com.volmit.config.FeatureSettings.Entry; import com.volmit.FeatureAttachment.Target; import com.volmit.hunk.Hunk; +import com.volmit.block.BlockRegistry; import com.volmit.block.BlockState; +import com.volmit.block.BlockTrait; import com.volmit.service.CaveBiomes; import com.volmit.stage.ChunkStageContext; import com.volmit.stage.MantleStageContext; @@ -99,12 +102,12 @@ public final class CarveModule implements IrisModule { MatterMantle mantle = MatterMantle.of(context.mantle()); Hunk blocks = context.hunk(BlockState.class); caveApplying(context.world(), context.terrain(), context.settings(), context.originX(), context.originZ()) - .apply(mantle, context.terrain(), context.originX() >> CHUNK_SHIFT, context.originZ() >> CHUNK_SHIFT, blocks); + .apply(mantle, context.terrain(), context.originX() >> CHUNK_SHIFT, context.originZ() >> CHUNK_SHIFT, blocks, CaveDressing.of(context)); } private static CaveCarving caveCarving(PackWorld world, TerrainSampler terrain, FeatureSettings settings, int originX, int originZ) { return world.state(CaveCarving.class, generating -> new CaveCarving(generating, carveWorld(generating, terrain), - upperDimensionCarving(settings, originX, originZ))); + upperDimensionCarving(settings, originX, originZ), fluidColumns(generating))); } private static CaveApplying caveApplying(PackWorld world, TerrainSampler terrain, FeatureSettings settings, int originX, int originZ) { @@ -112,6 +115,16 @@ public final class CarveModule implements IrisModule { upperDimensionCarving(settings, originX, originZ))); } + /** The columns the dimension's fluid palette fills with a fluid. */ + private static CaveCarving.FluidColumns fluidColumns(PackWorld world) { + TerrainPalettes palettes = TerrainPalettes.of(world); + BlockRegistry blocks = world.resources().blocks(); + return (worldX, worldZ) -> { + BlockState fluid = palettes.fluidAt(worldX, worldZ); + return fluid != null && blocks.hasTrait(fluid, BlockTrait.FLUID); + }; + } + /** What the carvers need of the world, from the dimension's settings and the first terrain they see (constant for the world). */ private static CarveWorld carveWorld(PackWorld world, TerrainSampler terrain) { int lavaHeight = dimensionSetting(world, CaveLavaHeightSettings.class, CaveLavaHeightSettings::height, CaveLavaHeightSettings.DEFAULT_HEIGHT); diff --git a/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java b/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java index a939da5e5..5d77c7741 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java +++ b/src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java @@ -18,7 +18,6 @@ package art.arcane.iris.engine.modifier; -import art.arcane.iris.builtin.CaveDressing; import art.arcane.iris.builtin.MatterMantle; import art.arcane.iris.builtin.decorant.DecorationPart; import art.arcane.volmlib.util.mantle.runtime.MantleChunk; @@ -66,7 +65,6 @@ public class CaveApplying { private final CarveWorld world; private final PackResources resources; private final BlockRegistry blocks; - private final CaveDressing dressing; private final boolean upperDimensionCarving; private final RNG rng; private final BlockState caveAir; @@ -77,7 +75,6 @@ public class CaveApplying { this.world = world; this.resources = packWorld.resources(); this.blocks = resources.blocks(); - this.dressing = CaveDressing.of(packWorld); this.upperDimensionCarving = upperDimensionCarving; this.rng = new RNG(world.carveSeed()); this.caveAir = blocks.resolve("minecraft:cave_air"); @@ -87,14 +84,15 @@ public class CaveApplying { /** * Applies the caves to the chunk at chunk coordinates {@code x}, {@code z}, whose blocks are {@code output}; the caves are in - * {@code mantle}, and {@code terrain} gives the heights and cave biomes around the chunk. + * {@code mantle}, {@code terrain} gives the heights and cave biomes around the chunk and {@code dressing} what its caves' walls, + * floors and ceilings get. */ - public void apply(MatterMantle mantle, TerrainSampler terrain, int x, int z, Hunk output) { + public void apply(MatterMantle mantle, TerrainSampler terrain, int x, int z, Hunk output, CaveDressing dressing) { MantleChunk mantleChunk = mantle.chunk(x, z); if (mantleChunk == null) { return; } - new Application(mantle, mantleChunk, terrain, x, z, output).run(); + new Application(mantle, mantleChunk, terrain, x, z, output, dressing).run(); } static boolean hasExplicitCarveIntent(MatterCavern cavern) { @@ -153,17 +151,20 @@ public class CaveApplying { private final int chunkX; private final int chunkZ; private final Hunk output; + private final CaveDressing dressing; private final CaveBlockClasses classes = new CaveBlockClasses(blocks); private final CaveBiomeCache caveBiomeCache = new CaveBiomeCache(CAVE_BIOME_CACHE_SIZE); private final IrisCarveScratch scratch = SCRATCH.get(); - Application(MatterMantle mantle, MantleChunk mantleChunk, TerrainSampler terrain, int chunkX, int chunkZ, Hunk output) { + Application(MatterMantle mantle, MantleChunk mantleChunk, TerrainSampler terrain, int chunkX, int chunkZ, Hunk output, + CaveDressing dressing) { this.mantle = mantle; this.mantleChunk = mantleChunk; this.terrain = terrain; this.chunkX = chunkX; this.chunkZ = chunkZ; this.output = output; + this.dressing = dressing; } void run() { @@ -226,7 +227,7 @@ public class CaveApplying { if (explicitCarveIntent) { // Only a fluid cavern consumes the fluid sample, so never take it per voxel. - BlockState fluid = isFluidIntent(cavern) ? dressing.fluidAt(output, chunkBlockX + rx, chunkBlockZ + rz) : null; + BlockState fluid = isFluidIntent(cavern) ? dressing.fluidAt(chunkBlockX + rx, chunkBlockZ + rz) : null; BlockState carved = resolveExplicitCarveState(cavern, fluid, lava, caveAir); output.set(rx, yy, rz, carved == null ? plainAir : carved); } else if (usesDefaultLava(caveLavaHeight, yy)) { @@ -251,7 +252,7 @@ public class CaveApplying { : resolveCustomBiome(customBiomeCache, customBiome); if (biome != null) { - BlockState data = dressing.wall(output, biome, rng, worldX, yy, worldZ); + BlockState data = dressing.wall(biome, rng, worldX, yy, worldZ); int columnIndex = PowerOfTwoCoordinates.packLocal16(rx, rz); if (data != null && classes.isSolid(output.get(rx, yy, rz)) && yy < surfaceHeights[columnIndex]) { @@ -496,7 +497,7 @@ public class CaveApplying { /** Replaces the solid blocks under {@code floorY} with the layers of {@code floorBiome}. */ private void paintFloorLayers(ResourceId floorBiome, int rx, int rz, int worldX, int worldZ, int floorY) { - List floorLayers = dressing.floorLayers(output, floorBiome, worldX, worldZ, rng, LAYER_DEPTH, floorY); + List floorLayers = dressing.floorLayers(floorBiome, worldX, worldZ, rng, LAYER_DEPTH, floorY); for (int i = 0; i < floorY - 1; i++) { if (i >= floorLayers.size()) { break; @@ -507,13 +508,13 @@ public class CaveApplying { if (layer == null || !classes.isSolid(existing) || !canReplaceCaveFloorLayer(output, rx, y, rz, layer, classes)) { continue; } - output.set(rx, y, rz, classes.isOre(existing) ? dressing.deepSlateOre(output, existing, layer) : layer); + output.set(rx, y, rz, classes.isOre(existing) ? dressing.oreFor(existing, layer) : layer); } } /** Replaces the solid blocks over {@code ceilingY} with the cave ceiling layers of {@code ceilingBiome}, below {@code maxY}. */ private void paintCeilingLayers(ResourceId ceilingBiome, int rx, int rz, int worldX, int worldZ, int ceilingY, int maxY) { - List ceilingLayers = dressing.ceilingLayers(output, ceilingBiome, worldX, worldZ, rng, LAYER_DEPTH, ceilingY); + List ceilingLayers = dressing.ceilingLayers(ceilingBiome, worldX, worldZ, rng, LAYER_DEPTH); for (int i = 0; i < ceilingLayers.size(); i++) { int y = ceilingY + i + 1; if (y >= maxY) { @@ -524,7 +525,7 @@ public class CaveApplying { if (layer == null || !classes.isSolid(existing)) { continue; } - output.set(rx, y, rz, classes.isOre(existing) ? dressing.deepSlateOre(output, existing, layer) : layer); + output.set(rx, y, rz, classes.isOre(existing) ? dressing.oreFor(existing, layer) : layer); } } @@ -578,12 +579,12 @@ public class CaveApplying { if (floorBiome != null && dressing.hasDecorators(floorBiome, DecorationPart.NONE) && hasStableCaveFloorSupport(output, rx, zone.getFloor(), rz, classes)) { - dressing.decorateFloor(output, rx, rz, xx, zz, floorBiome, zone.getFloor() - 1, zone.airThickness()); + dressing.decorateFloor(rx, rz, xx, zz, floorBiome, zone.getFloor() - 1, zone.airThickness()); } if (ceilingBiome != null && dressing.hasDecorators(ceilingBiome, DecorationPart.CEILING) && zone.getCeiling() + 1 < maxY && classes.isSolid(output.get(rx, zone.getCeiling() + 1, rz))) { - dressing.decorateCeiling(output, rx, rz, xx, zz, ceilingBiome, zone.getCeiling(), zone.airThickness()); + dressing.decorateCeiling(rx, rz, xx, zz, ceilingBiome, zone.getCeiling(), zone.airThickness()); } } diff --git a/src/main/java/art/arcane/iris/engine/modifier/CaveDressing.java b/src/main/java/art/arcane/iris/engine/modifier/CaveDressing.java new file mode 100644 index 000000000..2cc160d08 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/CaveDressing.java @@ -0,0 +1,55 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.decorant.DecorationPart; +import art.arcane.volmlib.util.math.RNG; +import com.volmit.block.BlockState; +import com.volmit.resource.ResourceId; +import com.volmit.stage.ChunkStageContext; + +import java.util.List; + +/** + * What a cave's walls, floor and ceiling get in one chunk: its biome's layers and decorators and the dimension's fluid palette. + * {@link #of} answers with the terrain and decorant built-ins, which ship in the same jar; tests answer with fixed blocks. + */ +public interface CaveDressing { + /** The built-ins' dressing of the chunk {@code context} generates. */ + static CaveDressing of(ChunkStageContext context) { + return new BuiltInCaveDressing(context); + } + + BlockState fluidAt(int x, int z); + + /** The block of the biome's wall at the position; null when the biome declares no wall. */ + BlockState wall(ResourceId biome, RNG rng, int x, int y, int z); + + List floorLayers(ResourceId biome, int x, int z, RNG rng, int depth, int floorY); + + List ceilingLayers(ResourceId biome, int x, int z, RNG rng, int depth); + + boolean hasDecorators(ResourceId biome, DecorationPart part); + + void decorateFloor(int localX, int localZ, int x, int z, ResourceId biome, int floorY, int airThickness); + + void decorateCeiling(int localX, int localZ, int x, int z, ResourceId biome, int ceilingY, int airThickness); + + /** The ore that suits the {@code rock} it replaces, as the platform decides. */ + BlockState oreFor(BlockState rock, BlockState ore); +}