Merge terrain, decorant and deposit (wave3b/4) with carve and placement: one pinned mantle chunks set with loaded-chunk lookup, both mantle margins, placement terrain reads BedrockSettings and TerrainPalettes, IrisCaveDressing goes

This commit is contained in:
piexel committed 2026-10-15 07:23:42 +02:00
commit eca3908ec1
62 files changed
+1652 -1417

No files matched your search

@@ -20,12 +20,15 @@ package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisRegistrant;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import com.volmit.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.FeatureSettings;
import com.volmit.resource.ResourceId;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* Module settings at world columns, for one engine: the dimension's entry, then the entry of the column's
@@ -37,23 +40,45 @@ final class ChunkModuleSettings implements FeatureSettings {
private static final String REGION = "region";
private static final String BIOME = "biome";
private final Engine engine;
/** The registrants whose settings stack at a column. */
interface Levels {
IrisRegistrant dimension();
IrisRegistrant region(int worldX, int worldZ);
IrisRegistrant surfaceBiome(int worldX, int worldZ);
/** The biome a {@code BiomeSample} names by {@code id}, or null when the dimension has no such biome. */
IrisBiome biome(ResourceId id);
}
private final Levels levels;
private final PackResourceIds ids;
ChunkModuleSettings(Engine engine, PackResourceIds ids) {
this.engine = engine;
this(new EngineLevels(engine), ids);
}
ChunkModuleSettings(Levels levels, PackResourceIds ids) {
this.levels = levels;
this.ids = ids;
}
@Override
public <F extends IrisFeature> List<Entry<F>> at(Class<F> featureType, int worldX, int worldZ) {
List<Entry<F>> entries = new ArrayList<>(Target.values().length);
addEntry(entries, featureType, Target.DIMENSION, DIMENSION, engine.getDimension());
addEntry(entries, featureType, Target.REGION, REGION, engine.getRegion(worldX, worldZ));
addEntry(entries, featureType, Target.BIOME, BIOME, engine.getSurfaceBiome(worldX, worldZ));
addEntry(entries, featureType, Target.DIMENSION, DIMENSION, levels.dimension());
addEntry(entries, featureType, Target.REGION, REGION, levels.region(worldX, worldZ));
addEntry(entries, featureType, Target.BIOME, BIOME, levels.surfaceBiome(worldX, worldZ));
return entries.isEmpty() ? List.of() : List.copyOf(entries);
}
@Override
public <F extends IrisFeature> Optional<F> declaredBy(ResourceId biome, Class<F> featureType) {
IrisBiome declared = levels.biome(biome);
return declared == null ? Optional.empty() : declared.getModuleSettings().find(featureType);
}
private <F extends IrisFeature> void addEntry(List<Entry<F>> entries, Class<F> featureType, Target level, String kind,
IrisRegistrant owner) {
if (owner == null) {
@@ -62,4 +87,27 @@ final class ChunkModuleSettings implements FeatureSettings {
owner.getModuleSettings().find(featureType)
.ifPresent(value -> entries.add(new Entry<>(level, ids.of(kind, owner.getLoadKey()), value)));
}
/** The dimension, region and surface biome the engine generates a column with. */
private record EngineLevels(Engine engine) implements Levels {
@Override
public IrisRegistrant dimension() {
return engine.getDimension();
}
@Override
public IrisRegistrant region(int worldX, int worldZ) {
return engine.getRegion(worldX, worldZ);
}
@Override
public IrisRegistrant surfaceBiome(int worldX, int worldZ) {
return engine.getSurfaceBiome(worldX, worldZ);
}
@Override
public IrisBiome biome(ResourceId id) {
return ((IrisPackResources) engine.getData().getPackResources()).irisBiome(id).orElse(null);
}
}
}
@@ -100,6 +100,12 @@ final class IrisBlockRegistry implements BlockRegistry {
return specs.computeIfAbsent(spec, IrisValues::blockData);
}
@Override
public BlockState oreFor(BlockState rock, BlockState ore) {
PlatformBlockState suited = IrisPlatforms.get().registries().deepSlateOre(platformState(rock), platformState(ore));
return BlockState.parse(PlatformBlockStates.namespaced(suited.key()));
}
@Override
public boolean hasTrait(BlockState state, BlockTrait trait) {
return hasTrait(platformState(state), trait);
@@ -1,160 +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 <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.CaveDressing;
import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.engine.decorator.BiomeDecorators;
import art.arcane.iris.engine.decorator.IrisCeilingDecorator;
import art.arcane.iris.engine.decorator.IrisSurfaceDecorator;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.InferredType;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.terrain.BiomeLayers;
import art.arcane.iris.engine.terrain.TerrainPalettes;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import com.volmit.block.BlockState;
import com.volmit.hunk.Hunk;
import com.volmit.resource.ResourceId;
import java.util.ArrayList;
import java.util.List;
/**
* {@link CaveDressing} over Iris's biome layers, decorators and terrain palettes: what the carve module asks of the features that
* are not modules yet, in IrisApi's types. Transitional, like the interface.
*/
final class IrisCaveDressing implements CaveDressing {
private final Engine engine;
private final IrisPackResources resources;
private final BiomeLayers layers;
private final BiomeDecorators decorators;
private final TerrainPalettes palettes;
private final IrisSurfaceDecorator surfaceDecorator;
private final IrisCeilingDecorator ceilingDecorator;
IrisCaveDressing(Engine engine, IrisPackResources resources, ModuleLog log) {
this.engine = engine;
this.resources = resources;
this.layers = BiomeLayers.of(engine, log);
this.decorators = BiomeDecorators.of(engine);
this.palettes = TerrainPalettes.of(engine);
this.surfaceDecorator = new IrisSurfaceDecorator(engine);
this.ceilingDecorator = new IrisCeilingDecorator(engine);
}
@Override
public boolean fluidPresentAt(int x, int z) {
return B.isFluid(palettes.fluidAt(x, z));
}
@Override
public BlockState fluidAt(Hunk<BlockState> chunk, int x, int z) {
return nullable(states(chunk), palettes.fluidAt(x, z));
}
@Override
public BlockState wall(Hunk<BlockState> chunk, ResourceId biome, RNG rng, int x, int y, int z) {
IrisBiome irisBiome = resources.irisBiome(biome);
if (irisBiome == null) {
return null;
}
return nullable(states(chunk), layers.wall(irisBiome).get(rng, x, y, z));
}
@Override
public List<BlockState> floorLayers(Hunk<BlockState> chunk, ResourceId biome, int x, int z, RNG rng, int depth, int floorY) {
IrisBiome irisBiome = resources.irisBiome(biome);
if (irisBiome == null) {
return List.of();
}
return toApi(chunk, layers.generateLayers(irisBiome, engine.getDimension(), x, z, rng, depth, floorY, engine.getData(), engine.getComplex()));
}
@Override
public List<BlockState> ceilingLayers(Hunk<BlockState> chunk, ResourceId biome, int x, int z, RNG rng, int depth, int ceilingY) {
IrisBiome irisBiome = resources.irisBiome(biome);
if (irisBiome == null) {
return List.of();
}
return toApi(chunk, layers.generateCeilingLayers(irisBiome, engine.getDimension(), x, z, rng, depth, ceilingY, engine.getData(), engine.getComplex()));
}
@Override
public boolean hasDecorators(ResourceId biome, DecorationPart part) {
IrisBiome irisBiome = resources.irisBiome(biome);
return irisBiome != null && decorators.hasDecorators(irisBiome, part);
}
@Override
public void decorateFloor(Hunk<BlockState> chunk, int localX, int localZ, int x, int z, ResourceId biome, int floorY, int airThickness) {
IrisBiome irisBiome = resources.irisBiome(biome);
if (irisBiome == null) {
return;
}
surfaceDecorator.decorate(localX, localZ, x, x, x, z, z, z, platform(chunk), irisBiome, InferredType.CAVE, floorY, airThickness);
}
@Override
public void decorateCeiling(Hunk<BlockState> chunk, int localX, int localZ, int x, int z, ResourceId biome, int ceilingY, int airThickness) {
IrisBiome irisBiome = resources.irisBiome(biome);
if (irisBiome == null) {
return;
}
ceilingDecorator.decorate(localX, localZ, x, x, x, z, z, z, platform(chunk), irisBiome, InferredType.CAVE, ceilingY, airThickness);
}
@Override
public BlockState deepSlateOre(Hunk<BlockState> chunk, BlockState existing, BlockState layer) {
PlatformBlockStates states = states(chunk);
return states.toApi(B.toDeepSlateOre(states.toPlatform(existing), states.toPlatform(layer)));
}
private List<BlockState> toApi(Hunk<BlockState> chunk, List<PlatformBlockState> blocks) {
PlatformBlockStates states = states(chunk);
List<BlockState> converted = new ArrayList<>(blocks.size());
for (PlatformBlockState block : blocks) {
converted.add(nullable(states, block));
}
return converted;
}
/** A state or null where the layer gave none; IrisApi's conversion reads null as air. */
private static BlockState nullable(PlatformBlockStates states, PlatformBlockState block) {
return block == null ? null : states.toApi(block);
}
private static PlatformBlockStates states(Hunk<BlockState> chunk) {
return hunk(chunk).states();
}
private static art.arcane.iris.util.project.hunk.Hunk<PlatformBlockState> platform(Hunk<BlockState> chunk) {
return hunk(chunk).platform();
}
private static BlockStateHunk hunk(Hunk<BlockState> chunk) {
if (chunk instanceof BlockStateHunk hunk) {
return hunk;
}
throw new IllegalArgumentException("Built-in modules dress the chunks Iris hands to them, not " + chunk);
}
}
@@ -40,6 +40,8 @@ import java.util.Collection;
final class IrisGenerationContext implements GenerationContext {
/** Chunk stages write only their own chunk, but see the terrain this far around it (IrisApi's promise). */
private static final int TERRAIN_MARGIN_BLOCKS = 16;
/** The mantle too reaches this far around the chunk; chunks beyond its own are pinned when a stage first reads them. */
private static final int MANTLE_MARGIN_BLOCKS = 16;
private static final int CHUNK_WIDTH = 16;
private final Engine engine;
@@ -59,9 +61,10 @@ final class IrisGenerationContext implements GenerationContext {
this.originX = originX;
this.originZ = originZ;
this.blocks = new BlockStateHunk(blocks, states);
this.terrain = new IrisTerrainSampler(engine, ids, originX, originZ, TERRAIN_MARGIN_BLOCKS);
this.terrain = new IrisTerrainSampler(engine, ids, originX, originZ, TERRAIN_MARGIN_BLOCKS, states);
this.settings = new ChunkModuleSettings(engine, ids);
BlockBox chunk = ApiHeights.columns(engine, originX, originZ, originX + CHUNK_WIDTH, originZ + CHUNK_WIDTH);
BlockBox chunk = ApiHeights.columns(engine, originX - MANTLE_MARGIN_BLOCKS, originZ - MANTLE_MARGIN_BLOCKS,
originX + CHUNK_WIDTH + MANTLE_MARGIN_BLOCKS, originZ + CHUNK_WIDTH + MANTLE_MARGIN_BLOCKS);
this.mantle = new IrisModuleMantle(chunk, mantleChunks, mantleLayers, PlannedBlocks.of(engine, chunk, mantleChunks, states));
}
@@ -19,11 +19,8 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.actuator.DecorantModule;
import art.arcane.iris.engine.actuator.TerrainModule;
import art.arcane.iris.engine.mantle.components.ObjectModule;
import art.arcane.iris.engine.mantle.components.StructureModule;
import art.arcane.iris.engine.modifier.DepositModule;
import art.arcane.iris.engine.modifier.FloatingModule;
import art.arcane.iris.spi.IrisPlatforms;
import com.volmit.IrisModule;
@@ -61,7 +58,7 @@ public final class IrisModuleHost {
*/
public static final List<String> JAR_MODULE_IDS = List.of("iris:post", "iris:perfection", "iris:matter", "iris:loot",
"iris:spawn", "iris:prepare", "iris:anchor", "iris:validate", "iris:bore", "iris:blocks", "iris:stilt", "iris:vacuum",
"iris:snow", "iris:vanilla-features", "iris:carve");
"iris:snow", "iris:vanilla-features", "iris:carve", "iris:deposit", "iris:decorant", "iris:terrain");
/** Iris's pack object model: built-in settings may hold these classes, which Iris reads and describes itself. */
public static final String HOST_TYPE_PACKAGE = "art.arcane.iris.engine.object";
private static final String[] JAR_COPY_FOLDER = {"cache", "module-jars"};
@@ -85,8 +82,7 @@ public final class IrisModuleHost {
}
private static List<IrisModule> generationModules() {
return List.of(new TerrainModule(), new ObjectModule(), new StructureModule(),
new FloatingModule(), new DepositModule(), new DecorantModule());
return List.of(new ObjectModule(), new StructureModule(), new FloatingModule());
}
/** Iris's own log, labelled {@code [iris]}, for host code that calls module classes outside any module's stage, service or hook. */
@@ -111,6 +111,11 @@ final class IrisModuleMantle implements Mantle, MatterMantle {
return plannedBlocks;
}
@Override
public MantleLayer<Boolean> caverns() {
return new MantleCaverns(bounds, chunks);
}
@Override
public MantleEdit edit() {
if (openEdit != null) {
@@ -256,6 +261,12 @@ final class IrisModuleMantle implements Mantle, MatterMantle {
return plannedBlocks;
}
@Override
public MantleLayer<Boolean> caverns() {
requireOpen();
return new MantleCaverns(bounds, chunks);
}
@Override
public MantleEdit edit() {
throw new UnsupportedOperationException("Mantle edits cannot be nested; write through this edit");
@@ -145,12 +145,6 @@ public final class IrisPackResources implements PackResources {
return kindOf(type).ids();
}
/** The biome of the pack with this id as Iris's own class, for the built-ins that decorate with it; null when the pack has none. */
public IrisBiome irisBiome(ResourceId id) {
String key = kindOf(PackBiome.class).keyOf(id);
return key == null ? null : data.getBiomeLoader().load(key);
}
/** The id of the resource the pack names by {@code packKey}, such as {@code overworld:castle/keep} for {@code castle/keep}. */
@Override
public ResourceId idOf(String packKey) {
@@ -199,8 +193,15 @@ public final class IrisPackResources implements PackResources {
return new Kind<>(ids, files::keys, (id, key) -> files.read(key));
}
/** Iris's own biome that {@code id}, as a {@code BiomeSample} gives it, names; for host code that reads what the biome declares. */
Optional<IrisBiome> irisBiome(ResourceId id) {
String key = irisKinds.get(PackBiome.class).keyOf(id);
return key == null ? Optional.empty() : Optional.ofNullable(data.getBiomeLoader().load(key));
}
private PackBiome biomeOf(ResourceId id, IrisBiome biome) {
return new PackBiome(id, biome.getName(), ResourceId.parse(biome.getDerivativeKey()), biome.getRarity(), idsOf(biome.getChildren()));
return new PackBiome(id, biome.getName(), ResourceId.parse(biome.getDerivativeKey()), ResourceId.parse(biome.getVanillaDerivativeKey()),
biome.getRarity(), idsOf(biome.getChildren()));
}
private PackRegion regionOf(ResourceId id, IrisRegion region) {
@@ -236,6 +237,11 @@ public final class IrisPackResources implements PackResources {
});
}
/** The pack key that has {@code id}, or null. */
String keyOf(ResourceId id) {
return keysById().get(id);
}
Optional<T> find(ResourceId id) {
T cached = built.get(id);
if (cached != null) {
@@ -253,11 +259,6 @@ public final class IrisPackResources implements PackResources {
return Optional.of(raced != null ? raced : made);
}
/** The key of the resource with this id; null when the pack has none. */
String keyOf(ResourceId id) {
return keysById().get(id);
}
List<ResourceId> ids() {
return keysById().keySet().stream().sorted().toList();
}
@@ -18,7 +18,6 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.CaveDressing;
import art.arcane.iris.builtin.IrisSeed;
import art.arcane.iris.builtin.LiveWorld;
import art.arcane.iris.engine.framework.Engine;
@@ -37,7 +36,7 @@ import java.util.function.Function;
* pack's resources reload under it. Iris's built-in modules reach the engine through {@link #of(PackWorld)}, as built-in
* reaches do through {@link IrisPackSettings#of}.
*/
public final class IrisPackWorld implements PackWorld, IrisSeed.Source, LiveWorld.Source, CaveDressing.Source {
public final class IrisPackWorld implements PackWorld, IrisSeed.Source, LiveWorld.Source {
private final Engine engine;
private final IrisPackResources resources;
private final WorldStates states;
@@ -113,17 +112,13 @@ public final class IrisPackWorld implements PackWorld, IrisSeed.Source, LiveWorl
return liveWorld;
}
@Override
public CaveDressing caveDressing() {
return state(IrisCaveDressing.class, world -> new IrisCaveDressing(engine, resources, log));
}
@Override
public long seed(IrisSeed seed) {
SeedManager seeds = engine.getSeedManager();
return switch (seed) {
case BIOME -> seeds.getBiome();
case CARVE -> seeds.getCarve();
case COMPLEX -> seeds.getComplex();
case COMPONENT -> seeds.getComponent();
case DECORATOR -> seeds.getDecorator();
case DEPOSIT -> seeds.getDeposit();
@@ -24,6 +24,7 @@ import com.volmit.mantle.BlockBox;
import com.volmit.object.ObjectTransformer;
import com.volmit.placement.PlacementContext;
import com.volmit.resource.PackResources;
import com.volmit.world.BiomeKind;
import com.volmit.world.BiomeSample;
import com.volmit.world.BlockView;
import com.volmit.world.TerrainSample;
@@ -72,6 +73,16 @@ final class IrisPlacementInputs implements PlacementContext {
throw withoutEngine();
}
@Override
public BiomeKind surfaceKind(int worldX, int worldZ) {
throw withoutEngine();
}
@Override
public int minWorldY() {
throw withoutEngine();
}
@Override
public int fluidHeight() {
throw withoutEngine();
@@ -24,7 +24,8 @@ import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.NativeStructureVolume;
import art.arcane.iris.engine.object.placement.IObjectPlacer;
import art.arcane.iris.engine.terrain.TerrainPalettes;
import art.arcane.iris.builtin.terrain.BedrockSettings;
import art.arcane.iris.builtin.terrain.TerrainPalettes;
import art.arcane.volmlib.util.collection.KList;
import com.volmit.block.BlockState;
@@ -115,7 +116,7 @@ final class IrisPlacementTerrain implements PlacementTerrain {
@Override
public boolean hasBedrock() {
return engine().getDimension().isBedrock();
return engine().getDimension().getModuleSettings().find(BedrockSettings.class).map(BedrockSettings::bedrock).orElse(true);
}
@Override
@@ -134,7 +135,8 @@ final class IrisPlacementTerrain implements PlacementTerrain {
if (engine.getComplex() == null) {
return PlatformBlockStates.AIR;
}
return states.toApi(TerrainPalettes.of(engine).rockAt(x, z));
BlockState rock = TerrainPalettes.of(engine.getGeneration().world()).rockAt(x, z);
return rock == null ? PlatformBlockStates.AIR : rock;
}
@Override
@@ -20,12 +20,18 @@ package art.arcane.iris.core.modules;
import art.arcane.iris.engine.UpperDimensionContext;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.InferredType;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import com.volmit.block.BlockState;
import com.volmit.mantle.BlockBox;
import com.volmit.resource.ResourceId;
import com.volmit.world.BiomeKind;
import com.volmit.world.BiomeSample;
import com.volmit.world.TerrainSample;
import com.volmit.world.TerrainSampler;
import com.volmit.world.UpperDimension;
import java.util.Optional;
import java.util.OptionalInt;
@@ -42,18 +48,29 @@ final class IrisTerrainSampler implements TerrainSampler {
private final Engine engine;
private final PackResourceIds ids;
private final BlockBox bounds;
private final PlatformBlockStates states;
/** The chunk at {@code originX}, {@code originZ} widened by {@code reachBlocks}, over the full world height. */
IrisTerrainSampler(Engine engine, PackResourceIds ids, int originX, int originZ, int reachBlocks) {
this(engine, ids, originX, originZ, reachBlocks, new PlatformBlockStates(B::getState));
}
/** The chunk at {@code originX}, {@code originZ} widened by {@code reachBlocks}, whose blocks convert with {@code states}. */
IrisTerrainSampler(Engine engine, PackResourceIds ids, int originX, int originZ, int reachBlocks, PlatformBlockStates states) {
this(engine, ids, originX - reachBlocks, originZ - reachBlocks,
originX + CHUNK_WIDTH_BLOCKS + reachBlocks, originZ + CHUNK_WIDTH_BLOCKS + reachBlocks);
originX + CHUNK_WIDTH_BLOCKS + reachBlocks, originZ + CHUNK_WIDTH_BLOCKS + reachBlocks, states);
}
/** Columns from the minima, inclusive, to the maxima, exclusive, over the full world height. */
IrisTerrainSampler(Engine engine, PackResourceIds ids, int minX, int minZ, int maxX, int maxZ) {
this(engine, ids, minX, minZ, maxX, maxZ, new PlatformBlockStates(B::getState));
}
private IrisTerrainSampler(Engine engine, PackResourceIds ids, int minX, int minZ, int maxX, int maxZ, PlatformBlockStates states) {
this.engine = engine;
this.ids = ids;
this.bounds = ApiHeights.columns(engine, minX, minZ, maxX, maxZ);
this.states = states;
}
@Override
@@ -94,6 +111,12 @@ final class IrisTerrainSampler implements TerrainSampler {
return Optional.ofNullable(engine.getCaveBiome(worldX, y, worldZ)).map(biome -> ids.of(biome.getLoadKey()));
}
@Override
public ResourceId surfaceBiome(int worldX, int worldZ) {
requireInside(worldX, bounds.minY(), worldZ);
return ids.of(engine.getSurfaceBiome(worldX, worldZ).getLoadKey());
}
@Override
public int fluidHeight() {
return engine.getDimension().getFluidHeight();
@@ -111,6 +134,38 @@ final class IrisTerrainSampler implements TerrainSampler {
return OptionalInt.of(Math.max(upper.getUpperSurfaceY(worldX, worldZ), surfaceY + engine.getDimension().getUpperDimensionGap()));
}
@Override
public BiomeKind surfaceKind(int worldX, int worldZ) {
requireInside(worldX, bounds.minY(), worldZ);
return kindOf(engine.getSurfaceBiome(worldX, worldZ).getInferredType());
}
static BiomeKind kindOf(InferredType type) {
return switch (type) {
case LAND -> BiomeKind.LAND;
case SEA -> BiomeKind.SEA;
case SHORE -> BiomeKind.SHORE;
case CAVE -> BiomeKind.CAVE;
};
}
@Override
public Optional<BlockState> surfaceBlock(int worldX, int worldZ) {
requireInside(worldX, bounds.minY(), worldZ);
return Optional.ofNullable(engine.getComplex().getImageMapRuntime().sampleSurfaceBlock(worldX, worldZ)).map(states::toApi);
}
@Override
public int minWorldY() {
return engine.getMinHeight();
}
@Override
public Optional<UpperDimension> upperDimension() {
UpperDimensionContext upper = engine.getUpperContext();
return upper == null ? Optional.empty() : Optional.of(new IrisUpperDimension(engine, upper, new PackResourceIds(upper.getData().getDataFolder()), states));
}
private void requireInside(int worldX, int y, int worldZ) {
if (!bounds.contains(worldX, y, worldZ)) {
throw new IndexOutOfBoundsException("Block " + worldX + ", " + y + ", " + worldZ + " is outside the sampled area " + bounds);
@@ -0,0 +1,92 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisRegistrant;
import art.arcane.iris.engine.UpperDimensionContext;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import com.volmit.block.BlockState;
import com.volmit.config.FeatureSettings;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import com.volmit.world.UpperDimension;
import java.util.Optional;
/** The dimension Iris stacks above the one it generates, as IrisApi's {@link UpperDimension}: its own dimension, region and biome streams. */
final class IrisUpperDimension implements UpperDimension {
private final UpperDimensionContext upper;
private final PackResources resources;
private final PlatformBlockStates states;
private final ChunkModuleSettings settings;
IrisUpperDimension(Engine engine, UpperDimensionContext upper, PackResourceIds ids, PlatformBlockStates states) {
this.upper = upper;
this.resources = upper.getData().getPackResources();
this.states = states;
this.settings = new ChunkModuleSettings(new UpperLevels(upper, engine), ids);
}
@Override
public boolean isThisDimension() {
return upper.isSelfReferencing();
}
@Override
public String key() {
return upper.getDimension().getLoadKey();
}
@Override
public FeatureSettings settings() {
return settings;
}
@Override
public PackResources resources() {
return resources;
}
@Override
public Optional<BlockState> surfaceBlock(int worldX, int worldZ) {
return Optional.ofNullable(upper.getSurfaceBlock(worldX, worldZ)).map(states::toApi);
}
private record UpperLevels(UpperDimensionContext upper, Engine engine) implements ChunkModuleSettings.Levels {
@Override
public IrisRegistrant dimension() {
return upper.getDimension();
}
@Override
public IrisRegistrant region(int worldX, int worldZ) {
return upper.getUpperRegion(worldX, worldZ);
}
@Override
public IrisRegistrant surfaceBiome(int worldX, int worldZ) {
return upper.getUpperBiome(worldX, worldZ);
}
@Override
public IrisBiome biome(ResourceId id) {
return ((IrisPackResources) upper.getData().getPackResources()).irisBiome(id).orElse(null);
}
}
}
@@ -18,6 +18,8 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.terrain.LayerLoad;
import art.arcane.iris.builtin.terrain.LayersSettings;
import art.arcane.iris.engine.object.material.IrisBlockData;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
@@ -33,6 +35,7 @@ import com.volmit.config.Range;
import com.volmit.noise.StyledRange;
import com.volmit.world.BlockPosition;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -109,6 +112,12 @@ public final class IrisValues {
return iris;
}
/** The noise style of each layer of the biome's surface, top first, as Iris's generators know them. */
public static List<art.arcane.iris.engine.object.noise.NoiseStyle> layerStyles(art.arcane.iris.engine.object.world.biome.IrisBiome biome) {
return LayerLoad.layersOf(biome.getModuleSettings().find(LayersSettings.class).orElse(null)).stream()
.map(layer -> generatorStyle(layer.style()).getStyle()).toList();
}
/** {@code range} as the range Iris reads the same JSON into. */
public static IrisRange range(Range range) {
return new IrisRange(range.min(), range.max());
@@ -0,0 +1,141 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.MatterCavern;
import com.volmit.mantle.BlockBox;
import com.volmit.mantle.MantleLayer;
import com.volmit.mantle.MantleVisitor;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
/**
* The voids Iris's mantle holds for chunks to take over, IrisApi's {@link com.volmit.mantle.Mantle#caverns()}: where the cave
* planner marked a cavern in the mantle's cavern slice, whatever the cavern holds (air, fluid, lava). Stages only read them.
*/
final class MantleCaverns implements MantleLayer<Boolean> {
private static final int CHUNK_SHIFT = 4;
private static final int SECTION_SHIFT = 4;
private static final int LOCAL_MASK = 15;
private static final String READ_ONLY = "Stages read the caverns; the cave planner writes them";
private static final Comparator<Position> VISIT_ORDER = Comparator.comparingInt(Position::x)
.thenComparingInt(Position::y).thenComparingInt(Position::z);
private final BlockBox bounds;
private final IrisModuleMantle.Chunks chunks;
MantleCaverns(BlockBox bounds, IrisModuleMantle.Chunks chunks) {
this.bounds = bounds;
this.chunks = chunks;
}
@Override
public Boolean get(int x, int y, int z) {
requireInside(x, y, z);
return cavernAt(requireChunk(x >> CHUNK_SHIFT, z >> CHUNK_SHIFT), x, y, z) ? Boolean.TRUE : null;
}
@Override
public void visit(BlockBox area, MantleVisitor<Boolean> visitor) {
Objects.requireNonNull(visitor, "visitor");
requireInside(area);
for (Position carved : carvedIn(area)) {
visitor.accept(carved.x(), carved.y(), carved.z(), Boolean.TRUE);
}
}
@Override
public void set(int x, int y, int z, Boolean value) {
throw new UnsupportedOperationException(READ_ONLY);
}
@Override
public void remove(int x, int y, int z) {
throw new UnsupportedOperationException(READ_ONLY);
}
@Override
public void clear(BlockBox area) {
throw new UnsupportedOperationException(READ_ONLY);
}
/** The carved positions in {@code area}, ordered by x, then y, then z, as {@link MantleLayer#visit} promises. */
private List<Position> carvedIn(BlockBox area) {
List<Position> carved = new ArrayList<>();
for (int chunkX = area.minX() >> CHUNK_SHIFT; chunkX <= (area.maxX() - 1) >> CHUNK_SHIFT; chunkX++) {
for (int chunkZ = area.minZ() >> CHUNK_SHIFT; chunkZ <= (area.maxZ() - 1) >> CHUNK_SHIFT; chunkZ++) {
collect(chunkX, chunkZ, area, carved);
}
}
carved.sort(VISIT_ORDER);
return carved;
}
private void collect(int chunkX, int chunkZ, BlockBox area, List<Position> carved) {
int originX = chunkX << CHUNK_SHIFT;
int originZ = chunkZ << CHUNK_SHIFT;
requireChunk(chunkX, chunkZ).iterate(MatterCavern.class, (localX, y, localZ, cavern) -> {
int x = originX + localX;
int z = originZ + localZ;
if (cavern != null && area.contains(x, y, z)) {
carved.add(new Position(x, y, z));
}
});
}
private static boolean cavernAt(MantleChunk<Matter> chunk, int x, int y, int z) {
int section = y >> SECTION_SHIFT;
if (!chunk.exists(section)) {
return false;
}
Matter matter = chunk.get(section);
if (matter == null || !matter.hasSlice(MatterCavern.class)) {
return false;
}
return matter.<MatterCavern>getSlice(MatterCavern.class).get(x & LOCAL_MASK, y & LOCAL_MASK, z & LOCAL_MASK) != null;
}
private MantleChunk<Matter> requireChunk(int chunkX, int chunkZ) {
MantleChunk<Matter> chunk = chunks.chunk(chunkX, chunkZ);
if (chunk == null) {
throw new IllegalStateException("Mantle chunk " + chunkX + ", " + chunkZ + " is inside " + bounds + " but was not prepared");
}
return chunk;
}
private void requireInside(int x, int y, int z) {
if (!bounds.contains(x, y, z)) {
throw new IndexOutOfBoundsException("Block " + x + ", " + y + ", " + z + " is outside the mantle this invocation prepared, " + bounds);
}
}
private void requireInside(BlockBox area) {
Objects.requireNonNull(area, "area");
if (!bounds.contains(area)) {
throw new IndexOutOfBoundsException("Area " + area + " is not inside the mantle this invocation prepared, " + bounds);
}
}
private record Position(int x, int y, int z) {
}
}
@@ -60,7 +60,7 @@ public final class ModuleChunkGeneration {
int chunkX = x >> CHUNK_SHIFT;
int chunkZ = z >> CHUNK_SHIFT;
long seed = ModuleSeeds.chunk(engine.getSeedManager().getSeed(), chunkX, chunkZ);
try (PinnedMantleChunk mantle = new PinnedMantleChunk(engine, chunkX, chunkZ)) {
try (PinnedMantleChunks mantle = new PinnedMantleChunks(engine)) {
IrisGenerationContext inputs = new IrisGenerationContext(engine, x, z, blocks, new PlatformBlockStates(platformStates), mantle,
pack.catalog().mantle());
StageMetrics metrics = new StageMetrics(engine.getMetrics());
@@ -71,4 +71,8 @@ final class PackResourceIds {
ResourceId of(String type, String key) {
return of(type + "/" + key);
}
private ResourceId idOf(String key) {
return new ResourceId(namespace, NOT_PATH.matcher(key.toLowerCase(Locale.ROOT)).replaceAll(REPLACEMENT));
}
}
@@ -1,75 +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 <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.volmlib.util.mantle.runtime.Mantle;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.mantle.runtime.TectonicPlate;
import art.arcane.volmlib.util.matter.Matter;
/**
* The one mantle chunk a generating chunk's stages may read: pinned the first time a stage asks for it and
* released once the chunk's stages are done.
*/
final class PinnedMantleChunk implements IrisModuleMantle.Chunks, AutoCloseable {
/** A tectonic plate holds 32 by 32 chunks. */
private static final int PLATE_SHIFT = 5;
private static final int PLATE_MASK = (1 << PLATE_SHIFT) - 1;
private final Engine engine;
private final int chunkX;
private final int chunkZ;
private MantleChunk<Matter> pinned;
PinnedMantleChunk(Engine engine, int chunkX, int chunkZ) {
this.engine = engine;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
}
@Override
public synchronized MantleChunk<Matter> chunk(int x, int z) {
if (x != chunkX || z != chunkZ) {
return null;
}
if (pinned == null) {
pinned = engine.getMantle().getMantle().getChunk(chunkX, chunkZ).use();
}
return pinned;
}
@Override
public MantleChunk<Matter> loadedChunk(int x, int z) {
Mantle<Matter> mantle = engine.getMantle().getMantle();
TectonicPlate<Matter> plate = mantle.getLoadedRegions().get(Mantle.key(x >> PLATE_SHIFT, z >> PLATE_SHIFT));
if (plate == null || plate.isClosed()) {
return null;
}
return plate.get(x & PLATE_MASK, z & PLATE_MASK);
}
@Override
public synchronized void close() {
if (pinned != null) {
pinned.release();
pinned = null;
}
}
}
@@ -19,7 +19,9 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.volmlib.util.mantle.runtime.Mantle;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.mantle.runtime.TectonicPlate;
import art.arcane.volmlib.util.matter.Matter;
import java.util.HashMap;
@@ -30,6 +32,10 @@ import java.util.Map;
* released together once the placement is committed or discarded.
*/
final class PinnedMantleChunks implements IrisModuleMantle.Chunks, AutoCloseable {
/** A tectonic plate holds 32 by 32 chunks. */
private static final int PLATE_SHIFT = 5;
private static final int PLATE_MASK = (1 << PLATE_SHIFT) - 1;
private final Engine engine;
private final Map<Long, MantleChunk<Matter>> pinned = new HashMap<>();
@@ -42,6 +48,16 @@ final class PinnedMantleChunks implements IrisModuleMantle.Chunks, AutoCloseable
return pinned.computeIfAbsent(key(chunkX, chunkZ), ignored -> engine.getMantle().getMantle().getChunk(chunkX, chunkZ).use());
}
@Override
public MantleChunk<Matter> loadedChunk(int chunkX, int chunkZ) {
Mantle<Matter> mantle = engine.getMantle().getMantle();
TectonicPlate<Matter> plate = mantle.getLoadedRegions().get(Mantle.key(chunkX >> PLATE_SHIFT, chunkZ >> PLATE_SHIFT));
if (plate == null || plate.isClosed()) {
return null;
}
return plate.get(chunkX & PLATE_MASK, chunkZ & PLATE_MASK);
}
@Override
public synchronized void close() {
pinned.values().forEach(MantleChunk::release);
@@ -70,6 +70,11 @@ final class PlacementMantle implements Mantle, AutoCloseable {
return new StoredRange<>(placement.blocks());
}
@Override
public MantleLayer<Boolean> caverns() {
return new StoredRange<>(placement.caverns());
}
@Override
public MantleEdit edit() {
throw new UnsupportedOperationException("The placement owns the mantle edit; write through layer()");
@@ -49,6 +49,9 @@ public final class PlatformBlockStates {
/** The state read last: scans over a chunk read long runs of one state, such as stone or air, so most reads hit it. */
private PlatformBlockState lastRead;
private BlockState lastReadAsApi;
/** The state written last: a stage fills long runs of one block, such as rock, so most writes hit it. */
private BlockState lastWritten;
private PlatformBlockState lastWrittenAsPlatform;
/** {@code platformStates} turns a block state key into the platform's state, such as {@code B::getState}. */
public PlatformBlockStates(Function<String, PlatformBlockState> platformStates) {
@@ -82,11 +85,14 @@ public final class PlatformBlockStates {
}
public PlatformBlockState toPlatform(BlockState state) {
PlatformBlockState origin = origins.get(state);
if (origin != null) {
return origin;
if (state == lastWritten) {
return lastWrittenAsPlatform;
}
return written.computeIfAbsent(state, api -> platformStates.apply(api.key()));
PlatformBlockState origin = origins.get(state);
PlatformBlockState platform = origin != null ? origin : written.computeIfAbsent(state, api -> platformStates.apply(api.key()));
lastWritten = state;
lastWrittenAsPlatform = platform;
return platform;
}
/** {@code key} with Minecraft's namespace when it names none, as Minecraft reads such keys. */
@@ -36,7 +36,10 @@ final class StageMetrics implements StageTimings {
private static final Map<String, Function<EngineMetrics, AtomicRollingSequence>> NAMED = Map.of(
"iris:post/smooth", EngineMetrics::getPost,
"iris:perfection/surface", EngineMetrics::getPerfection,
"iris:carve/apply", EngineMetrics::getCave);
"iris:carve/apply", EngineMetrics::getCave,
"iris:deposit/ores", EngineMetrics::getDeposit,
"iris:decorant/decorate", EngineMetrics::getDecoration,
"iris:terrain/shape", EngineMetrics::getTerrain);
private final EngineMetrics metrics;
@@ -1,45 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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 <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.engine.framework;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.iris.util.project.hunk.Hunk;
public interface EngineDecorator extends EngineComponent {
@BlockCoordinates
void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max);
@BlockCoordinates
default void decorate(int x, int z, int realX, int realZ, Hunk<PlatformBlockState> data, IrisBiome biome, int height, int max) {
decorate(x, z, realX, realX, realX, realZ, realZ, realZ, data, biome, height, max);
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
default boolean canGoOn(PlatformBlockState decorant, PlatformBlockState atop) {
if (atop == null || atop.isAir()) {
return false;
}
return B.canPlaceOnto(decorant, atop);
}
}
@@ -19,6 +19,7 @@
package art.arcane.iris.engine.mantle;
import art.arcane.iris.builtin.terrain.BedrockSettings;
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.project.matter.TileWrapper;
@@ -198,7 +199,7 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
return;
}
if (y == 0 && t instanceof PlatformBlockState && engineMantle.getEngine().getDimension().isBedrock()) {
if (y == 0 && t instanceof PlatformBlockState && engineMantle.getEngine().getDimension().getModuleSettings().find(BedrockSettings.class).map(BedrockSettings::bedrock).orElse(true)) {
return;
}