Merge branch 'wave3b/4'

# Conflicts:
#	builtin-modules.txt
#	src/main/java/art/arcane/iris/builtin/package-info.java
#	src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java
#	src/main/java/art/arcane/iris/engine/modifier/CarveModule.java
#	src/main/java/art/arcane/iris/engine/modifier/CaveApplying.java
#	src/main/java/art/arcane/iris/engine/modifier/IrisCarveScratch.java
#	src/main/java/art/arcane/iris/engine/object/placement/VacuumModule.java
#	src/main/java/art/arcane/iris/engine/object/placement/ValidateModule.java
This commit is contained in:
piexel committed 2026-10-15 07:15:17 +02:00
commit 81e8b300ef
50 files changed
+2183 -1442

No files matched your search

@@ -27,7 +27,7 @@ import com.volmit.world.PackWorld;
* from {@link PackWorld#seed()}.
*/
public enum IrisSeed {
BIOME, CARVE, COMPONENT, DECORATOR, DEPOSIT, ENTITY, LOOT, MANTLE, POST, TERRAIN;
BIOME, CARVE, COMPLEX, COMPONENT, DECORATOR, DEPOSIT, ENTITY, LOOT, MANTLE, POST, TERRAIN;
/** This seed of {@code world}, which must be a world Iris generates. */
public long of(PackWorld world) {
@@ -0,0 +1,38 @@
/*
* 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.builtin.decorant;
import com.volmit.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
/** Whether a dimension decorates at all, written as {@code "decorate": false}. A dimension without the key decorates. */
@Desc("Generate decorations or not")
@Feature(id = "iris:decorant/decorate", name = "Decorate", key = "decorate", root = "decorate", targets = Target.DIMENSION)
public final class DecorateSettings implements IrisFeature {
@Desc("Generate decorations or not")
private boolean decorate = true;
public DecorateSettings() {
}
public boolean decorate() {
return decorate;
}
}
@@ -0,0 +1,52 @@
/*
* 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.builtin.decorant;
/** How loaded with decorating a biome is, which studio's decorator load view colours it by. */
public final class DecoratorLoad {
private static final int COLUMNS_PER_CHUNK = 256;
private DecoratorLoad() {
}
/** The sum of the decorators' chances times their stack heights, at least one block each; 0 for a biome without decorators. */
public static double of(DecorantSettings settings) {
if (settings == null) {
return 0D;
}
double load = 0D;
for (Decorator decorator : settings.decorators()) {
load += Math.max(decorator.stackMax(), 1) * decorator.chance();
}
return load;
}
/** The sum of the decorators' chances over a chunk's columns, which is how strongly the view colours the biome. */
public static double colour(DecorantSettings settings) {
if (settings == null) {
return 0D;
}
double load = 0D;
for (Decorator decorator : settings.decorators()) {
load += decorator.chance() * Math.min(1, decorator.stackMax()) * COLUMNS_PER_CHUNK;
}
return load;
}
}
@@ -30,7 +30,8 @@
* Besides those, it holds what the compiled-in built-ins and the built-ins jar must share, since each sees its own copy
* of every other class: narrow facades only Iris's own built-ins use, interfaces Iris's worlds implement
* ({@link art.arcane.iris.builtin.IrisSeed}, {@link art.arcane.iris.builtin.LiveWorld}), and per-world state several of them use
* ({@link art.arcane.iris.builtin.terrain.LayerBlocks}). Keep them few: each is a promise.
* ({@link art.arcane.iris.builtin.terrain.LayerBlocks}, {@link art.arcane.iris.builtin.terrain.BiomeLayers},
* {@link art.arcane.iris.builtin.terrain.TerrainPalettes}). Keep them few: each is a promise.
* <p>
* The placement stages ({@code iris:prepare} to {@code iris:snow}) reach the object being placed through
* {@link art.arcane.iris.builtin.placement.ObjectPlacement}, a facade Iris implements for each placement. Its types
@@ -0,0 +1,38 @@
/*
* 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.builtin.terrain;
import com.volmit.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
/** Whether a dimension has a layer of bedrock at its bottom, written as {@code "bedrock": false}. A dimension without the key has it. */
@Desc("Should bedrock be generated or not.")
@Feature(id = "iris:terrain/bedrock", name = "Bedrock", key = "bedrock", root = "bedrock", targets = Target.DIMENSION)
public final class BedrockSettings implements IrisFeature {
@Desc("Should bedrock be generated or not.")
private boolean bedrock = true;
public BedrockSettings() {
}
public boolean bedrock() {
return bedrock;
}
}
@@ -0,0 +1,322 @@
/*
* 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.builtin.terrain;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.volmlib.util.cache.AtomicCache;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
import com.volmit.block.BlockState;
import com.volmit.config.FeatureSettings;
import com.volmit.noise.NoiseFactory;
import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
/**
* What the terrain module keeps for one world about the layers of its biomes: each layer made ready ({@link ResolvedLayer})
* and the noise that sets the thickness of a biome's layers, and the blocks the layers of a biome stack up to at a column.
* A biome's layers are its {@link LayersSettings}, {@link SeaLayersSettings} and {@link CaveCeilingLayersSettings}; a biome
* that declares no layers has the one layer of grass the settings default to.
*
* <p>The noise of a biome's layers is built once, from the random of the first column asked for, as it always was.
*/
public final class BiomeLayers {
private static final int SURFACE_HEIGHT_SEED = 7235;
private static final int SEA_HEIGHT_SEED = 7735;
private static final int LOCKED_LAYERS_REFERENCE_HEIGHT = 512;
private static final LayersSettings DEFAULT_LAYERS = new LayersSettings();
private static final PaletteLayer NO_LAYER = PaletteLayer.withoutBlocks();
private static final BlockState BARRIER = new BlockState("minecraft:barrier");
private final Supplier<LayerBlocks> layerBlocks;
private final Supplier<NoiseFactory> noise;
private final ModuleLog log;
private final Map<PaletteLayer, ResolvedLayer> resolved = new ConcurrentHashMap<>();
private final Map<LayersSettings, AtomicCache<KList<LayerNoise>>> surfaceHeights = new ConcurrentHashMap<>();
private final Map<SeaLayersSettings, AtomicCache<KList<LayerNoise>>> seaHeights = new ConcurrentHashMap<>();
private final Map<ResourceId, LayeredBiome> biomes = new ConcurrentHashMap<>();
/** The layers of {@code world}. */
public static BiomeLayers of(PackWorld world) {
return world.state(BiomeLayers.class, generating -> new BiomeLayers(() -> LayerBlocks.of(generating), () -> generating.resources().noise(), generating.log()));
}
/** The layers of a world whose layer blocks {@code layerBlocks} and noise {@code noise} give, asked for when a layer first needs them. */
public BiomeLayers(Supplier<LayerBlocks> layerBlocks, Supplier<NoiseFactory> noise, ModuleLog log) {
this.layerBlocks = layerBlocks;
this.noise = noise;
this.log = log;
}
/** {@code layer} ready for this world; its block picks are the world's {@link LayerBlocks}. */
public ResolvedLayer resolve(PaletteLayer layer) {
return resolved.computeIfAbsent(layer, declared -> ResolvedLayer.of(declared, layerBlocks, noise));
}
/** What the biome {@code id} declares about its layers, read once from {@code settings}. */
public LayeredBiome biome(ResourceId id, FeatureSettings settings) {
LayeredBiome known = biomes.get(id);
if (known != null) {
return known;
}
return biomes.computeIfAbsent(id, ignored -> new LayeredBiome(
settings.declaredBy(id, LayersSettings.class).orElse(null),
settings.declaredBy(id, SeaLayersSettings.class).orElse(null),
settings.declaredBy(id, CaveCeilingLayersSettings.class).orElse(null),
settings.declaredBy(id, LockLayersSettings.class).orElse(null),
settings.declaredBy(id, LockLayersMaxSettings.class).orElse(null),
settings.declaredBy(id, WallSettings.class).orElse(null)));
}
/** The biome's wall, which places no block when the biome declares none. */
public ResolvedLayer wall(LayeredBiome biome) {
PaletteLayer layer = biome.wall() == null ? NO_LAYER : biome.wall().layer();
return resolve(layer);
}
/** The blocks the biome's layers stack up to at the column, top first, at most {@code maxDepth} of them. */
public KList<BlockState> generateLayers(LayeredBiome biome, PaletteExplosion explosion, double wx, double wz, RNG random, int maxDepth, int height,
ColumnSlope slope) {
if (isLocked(biome)) {
return generateLockedLayers(biome, wx, wz, random, maxDepth, height, slope);
}
KList<BlockState> blocks = new KList<>();
if (maxDepth <= 0) {
return blocks;
}
LayersSettings settings = surfaceSettings(biome);
List<PaletteLayer> layers = settings.layers();
if (layers.isEmpty()) {
return blocks;
}
KList<LayerNoise> heightNoises = surfaceHeightNoises(settings, random);
for (int i = 0; i < layers.size(); i++) {
ResolvedLayer layer = resolve(layers.get(i));
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, slope);
if (depth <= 0) {
continue;
}
stackLayer(blocks, layer, i, depth, wx, wz, random, maxDepth);
if (blocks.size() >= maxDepth) {
break;
}
separateLayers(blocks, explosion, maxDepth);
}
return blocks;
}
/** The blocks the biome's cave ceiling layers stack up to at the column, nearest the ceiling first, at most {@code maxDepth} of them. */
public KList<BlockState> generateCeilingLayers(LayeredBiome biome, PaletteExplosion explosion, double wx, double wz, RNG random, int maxDepth) {
KList<BlockState> blocks = new KList<>();
if (maxDepth <= 0) {
return blocks;
}
List<PaletteLayer> ceilingLayers = biome.ceilingLayers() == null ? List.of() : biome.ceilingLayers().layers();
if (ceilingLayers.isEmpty()) {
return blocks;
}
KList<LayerNoise> heightNoises = surfaceHeightNoises(surfaceSettings(biome), random);
// Ceiling layers reuse the surface-layer height noise, so entries beyond the surface layers have none; skip them.
int usableLayers = Math.min(ceilingLayers.size(), heightNoises.size());
for (int i = 0; i < usableLayers; i++) {
ResolvedLayer layer = resolve(ceilingLayers.get(i));
double depth = layerThickness(layer, heightNoises.get(i), wx, wz);
if (depth <= 0) {
continue;
}
stackLayer(blocks, layer, i, depth, wx, wz, random, maxDepth);
if (blocks.size() >= maxDepth) {
break;
}
separateLayers(blocks, explosion, maxDepth);
}
return blocks;
}
/** The blocks of the biome's sea layers at the column, from the water surface down, at most {@code maxDepth} of them. */
public KList<BlockState> generateSeaLayers(LayeredBiome biome, double wx, double wz, RNG random, int maxDepth) {
KList<BlockState> blocks = new KList<>();
SeaLayersSettings settings = biome.seaLayers();
if (settings == null || settings.layers().isEmpty()) {
return blocks;
}
List<PaletteLayer> layers = settings.layers();
KList<LayerNoise> heightNoises = seaHeightNoises(settings, random);
for (int i = 0; i < layers.size(); i++) {
ResolvedLayer layer = resolve(layers.get(i));
int depth = heightNoises.get(i).fit(layer.minHeight(), layer.maxHeight(), wx / layer.zoom(), wz / layer.zoom());
if (depth < 0) {
continue;
}
stackLayer(blocks, layer, i, depth, wx, wz, random, maxDepth);
if (blocks.size() >= maxDepth) {
break;
}
}
return blocks;
}
private KList<BlockState> generateLockedLayers(LayeredBiome biome, double wx, double wz, RNG random, int maxDepthLimit, int height, ColumnSlope slope) {
KList<BlockState> stacked = new KList<>();
KList<BlockState> locked = new KList<>();
int maxDepth = Math.min(maxDepthLimit, lockedLayersMax(biome));
if (maxDepth <= 0) {
return stacked;
}
LayersSettings settings = surfaceSettings(biome);
List<PaletteLayer> layers = settings.layers();
if (!layers.isEmpty()) {
KList<LayerNoise> heightNoises = surfaceHeightNoises(settings, random);
for (int i = 0; i < layers.size(); i++) {
ResolvedLayer layer = resolve(layers.get(i));
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, slope);
if (depth <= 0) {
continue;
}
stackLayerUnlimited(stacked, layer, i, depth, wx, wz, random);
}
}
if (stacked.isEmpty()) {
return locked;
}
for (int i = 0; i < maxDepth; i++) {
int offset = (LOCKED_LAYERS_REFERENCE_HEIGHT - height) - i;
locked.add(stacked.get(Math.max(offset % stacked.size(), 0)));
}
return locked;
}
private void stackLayer(KList<BlockState> blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random, int maxDepth) {
for (int j = 0; j < depth; j++) {
if (blocks.size() >= maxDepth) {
break;
}
addBlock(blocks, layer, index, j, wx, wz, random);
}
}
private void stackLayerUnlimited(KList<BlockState> blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random) {
for (int j = 0; j < depth; j++) {
addBlock(blocks, layer, index, j, wx, wz, random);
}
}
/** Adds the layer's block {@code j} blocks down; a layer that fails to pick adds nothing. */
private void addBlock(KList<BlockState> blocks, ResolvedLayer layer, int index, int j, double wx, double wz, RNG random) {
double zoom = layer.zoom();
try {
blocks.add(layer.get(random, index + j, (wx + j) / zoom, j, (wz - j) / zoom));
} catch (Throwable e) {
log.error("A biome layer failed to pick a block", e);
}
}
/** The barrier blocks a dimension puts between layers to show them apart. */
private void separateLayers(KList<BlockState> blocks, PaletteExplosion explosion, int maxDepth) {
if (!explosion.exploded()) {
return;
}
for (int j = 0; j < explosion.size(); j++) {
blocks.add(BARRIER);
if (blocks.size() >= maxDepth) {
break;
}
}
}
/** How thick the layer is at the column: nothing where the slope is outside the layer's limits. */
private double layerDepth(ResolvedLayer layer, LayerNoise heightNoise, double wx, double wz, ColumnSlope slope) {
double depth = layerThickness(layer, heightNoise, wx, wz);
SlopeClip clip = layer.slopeCondition();
if (!clip.isDefault() && !clip.isValid(slope.at(wx, wz))) {
return 0;
}
return depth;
}
private double layerThickness(ResolvedLayer layer, LayerNoise heightNoise, double wx, double wz) {
double zoom = layer.zoom();
return heightNoise.fit(layer.minHeight(), layer.maxHeight(), wx / zoom, wz / zoom);
}
private KList<LayerNoise> surfaceHeightNoises(LayersSettings settings, RNG rng) {
AtomicCache<KList<LayerNoise>> cache = surfaceHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
return heightNoises(cache, settings.layers(), SURFACE_HEIGHT_SEED, rng);
}
private KList<LayerNoise> seaHeightNoises(SeaLayersSettings settings, RNG rng) {
AtomicCache<KList<LayerNoise>> cache = seaHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
return heightNoises(cache, settings.layers(), SEA_HEIGHT_SEED, rng);
}
private KList<LayerNoise> heightNoises(AtomicCache<KList<LayerNoise>> cache, List<PaletteLayer> layers, int firstSeed, RNG rng) {
KList<LayerNoise> cached = cache.getIfPresent();
if (cached != null) {
return cached;
}
return cache.aquire(() -> {
KList<LayerNoise> noises = new KList<>();
int seed = firstSeed;
for (PaletteLayer layer : layers) {
noises.add(resolve(layer).heightNoise(rng.nextParallelRNG((seed++) * seed * seed * seed)));
}
return noises;
});
}
private static LayersSettings surfaceSettings(LayeredBiome biome) {
return biome.layers() == null ? DEFAULT_LAYERS : biome.layers();
}
private static boolean isLocked(LayeredBiome biome) {
return biome.lock() != null && biome.lock().locked();
}
private static int lockedLayersMax(LayeredBiome biome) {
return biome.lockMax() == null ? LockLayersMaxSettings.DEFAULT_LAYERS : biome.lockMax().layers();
}
}
@@ -0,0 +1,24 @@
/*
* 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.builtin.terrain;
/** The slope of the terrain at a column, asked only when a layer limits where it shows by slope. */
@FunctionalInterface
public interface ColumnSlope {
double at(double worldX, double worldZ);
}
@@ -0,0 +1,44 @@
/*
* 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.builtin.terrain;
import com.volmit.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinNumber;
/** How many barrier blocks a dimension puts between layers when it explodes its biome palettes, written as {@code "explodeBiomePaletteSize": 3}. */
@Desc("Customize the palette height explosion")
@Feature(id = "iris:terrain/explode-palette-size", name = "Explode biome palette size", key = "explodeBiomePaletteSize", root = "size", targets = Target.DIMENSION)
public final class ExplodeBiomePaletteSizeSettings implements IrisFeature {
public static final int DEFAULT_SIZE = 3;
@MinNumber(1)
@MaxNumber(16)
@Desc("Customize the palette height explosion")
private int size = DEFAULT_SIZE;
public ExplodeBiomePaletteSizeSettings() {
}
public int size() {
return size;
}
}
@@ -0,0 +1,38 @@
/*
* 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.builtin.terrain;
import com.volmit.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
/** Whether a dimension puts barrier blocks between the layers of its biomes to show them apart, written as {@code "explodeBiomePalettes": true}. */
@Desc("Vertically split up the biome palettes with barrier blocks in between to visualize them. The gap size comes from explodeBiomePaletteSize.")
@Feature(id = "iris:terrain/explode-palettes", name = "Explode biome palettes", key = "explodeBiomePalettes", root = "explode", targets = Target.DIMENSION)
public final class ExplodeBiomePalettesSettings implements IrisFeature {
@Desc("Vertically split up the biome palettes with barrier blocks in between to visualize them. The gap size comes from explodeBiomePaletteSize.")
private boolean explode = false;
public ExplodeBiomePalettesSettings() {
}
public boolean explode() {
return explode;
}
}
@@ -0,0 +1,33 @@
/*
* 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.builtin.terrain;
import java.util.List;
/** The layers of a biome's surface, which studio's layer view counts. */
public final class LayerLoad {
private static final LayersSettings DEFAULT_LAYERS = new LayersSettings();
private LayerLoad() {
}
/** The layers of the biome's surface, top first; a biome that declares no layers has the one layer of grass the settings default to. */
public static List<PaletteLayer> layersOf(LayersSettings declared) {
return (declared == null ? DEFAULT_LAYERS : declared).layers();
}
}
@@ -0,0 +1,37 @@
/*
* 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.builtin.terrain;
import com.volmit.noise.NoiseSampler;
/** The noise that sets how thick a layer is: a number between a layer's limits at every column. */
public final class LayerNoise {
private final NoiseSampler noise;
LayerNoise(NoiseSampler noise) {
this.noise = noise;
}
/** The whole number between {@code min} and {@code max} the noise gives at the column. */
public int fit(int min, int max, double x, double z) {
if (min == max) {
return min;
}
return (int) Math.round(min + noise.sample(x, z) * (max - min));
}
}
@@ -0,0 +1,29 @@
/*
* 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.builtin.terrain;
/**
* What a biome declares about the layers of its ground: the layers of its surface, of its sea floor and of its cave ceilings, whether
* they are locked to the highest height the biome reaches, and its wall. A setting the biome does not declare is null.
*/
public record LayeredBiome(LayersSettings layers, SeaLayersSettings seaLayers, CaveCeilingLayersSettings ceilingLayers,
LockLayersSettings lock, LockLayersMaxSettings lockMax, WallSettings wall) {
/** A biome that declares nothing about its layers: the one layer of grass the settings default to. */
public static final LayeredBiome UNDECLARED = new LayeredBiome(null, null, null, null, null, null);
}
@@ -0,0 +1,43 @@
/*
* 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.builtin.terrain;
import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockSpec;
import com.volmit.block.BlockState;
import java.util.ArrayList;
import java.util.List;
/** A palette's blocks, the way terrain layers and palettes always picked from them. */
final class PaletteBlocks {
private PaletteBlocks() {
}
/** The block of each spec, each repeated by its weight. */
static List<BlockState> weighted(BlockRegistry registry, List<BlockSpec> palette) {
List<BlockState> weighted = new ArrayList<>();
for (BlockSpec spec : palette) {
BlockState state = registry.resolve(spec);
for (int n = 0; n < spec.weight(); n++) {
weighted.add(state);
}
}
return List.copyOf(weighted);
}
}
@@ -0,0 +1,41 @@
/*
* 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.builtin.terrain;
import com.volmit.config.FeatureSettings;
import com.volmit.config.FeatureSettings.Entry;
import java.util.List;
/** Whether a dimension separates the layers of its biomes with barrier blocks to show them apart, and how many barriers it puts between them. */
public record PaletteExplosion(boolean exploded, int size) {
public static final PaletteExplosion NONE = new PaletteExplosion(false, ExplodeBiomePaletteSizeSettings.DEFAULT_SIZE);
/** What the dimension at the column of {@code settings} declares. */
public static PaletteExplosion of(FeatureSettings settings, int worldX, int worldZ) {
boolean exploded = dimensionValue(settings.at(ExplodeBiomePalettesSettings.class, worldX, worldZ), ExplodeBiomePalettesSettings::explode, false);
int size = dimensionValue(settings.at(ExplodeBiomePaletteSizeSettings.class, worldX, worldZ), ExplodeBiomePaletteSizeSettings::size,
ExplodeBiomePaletteSizeSettings.DEFAULT_SIZE);
return new PaletteExplosion(exploded, size);
}
private static <S extends com.volmit.IrisFeature, V> V dimensionValue(List<Entry<S>> entries, java.util.function.Function<S, V> read, V fallback) {
return entries.stream().filter(entry -> entry.level() == com.volmit.FeatureAttachment.Target.DIMENSION).findFirst()
.map(entry -> read.apply(entry.value())).orElse(fallback);
}
}
@@ -0,0 +1,112 @@
/*
* 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.builtin.terrain;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.volmlib.util.cache.AtomicCache;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.block.BlockState;
import com.volmit.noise.NoiseFactory;
import com.volmit.noise.NoiseStyle;
import java.util.List;
import java.util.function.Supplier;
/**
* One {@link PaletteLayer} made ready for one world: its blocks, and the noise that decides how thick it is here, built when first
* asked for. Which block it picks where is the world's {@link LayerBlocks}, shared with every other module that picks from the layer.
*
* <p>The thickness noise is built once, from the random of whoever asks first, as the layers of a biome always were.
*/
public final class ResolvedLayer {
/** The style of the noise that sets a layer's thickness: Iris's signature noise. */
private static final NoiseStyle THICKNESS_STYLE = NoiseStyle.of("IRIS");
private final PaletteLayer settings;
private final Supplier<LayerBlocks> layerBlocks;
private final Supplier<NoiseFactory> noise;
private final AtomicCache<List<BlockState>> blocks = new AtomicCache<>();
private final AtomicCache<LayerNoise> heightNoise = new AtomicCache<>();
private ResolvedLayer(PaletteLayer settings, Supplier<LayerBlocks> layerBlocks, Supplier<NoiseFactory> noise) {
this.settings = settings;
this.layerBlocks = layerBlocks;
this.noise = noise;
}
/** {@code settings} ready for the world whose layer blocks {@code layerBlocks} gives, asked for when first needed. */
static ResolvedLayer of(PaletteLayer settings, Supplier<LayerBlocks> layerBlocks, Supplier<NoiseFactory> noise) {
return new ResolvedLayer(settings, layerBlocks, noise);
}
public PaletteLayer settings() {
return settings;
}
public int minHeight() {
return settings.minHeight();
}
public int maxHeight() {
return settings.maxHeight();
}
public double zoom() {
return settings.zoom();
}
public SlopeClip slopeCondition() {
return settings.slopeCondition();
}
/** Whether the layer lists any block, which is not the same as picking one: a listed block may have no weight. */
public boolean hasPalette() {
return !settings.palette().isEmpty();
}
/** The noise that sets the layer's thickness, built from {@code rng} unless an earlier caller's is already kept. */
public LayerNoise heightNoise(RNG rng) {
LayerNoise cached = heightNoise.getIfPresent();
if (cached != null) {
return cached;
}
return heightNoise.aquire(() -> new LayerNoise(noise.get().sampler(THICKNESS_STYLE,
rng.nextParallelRNG(settings.minHeight() * settings.maxHeight() + blocks().size()).getSeed())));
}
/** The layer's block at the position, picked as {@link LayerBlocks#pick} says, or null when the palette has no block. */
public BlockState get(RNG parent, int signature, double x, double y, double z) {
int index = layerBlocks.get().pick(settings, parent, signature, x, y, z);
return index == LayerBlocks.NONE ? null : blocks().get(index);
}
/** {@link #get(RNG, int, double, double, double)} for a layer asked once per column, such as a slab or a wall. */
public BlockState get(RNG rng, double x, double y, double z) {
return get(rng, 0, x, y, z);
}
private List<BlockState> blocks() {
List<BlockState> cached = blocks.getIfPresent();
if (cached != null) {
return cached;
}
return blocks.aquire(() -> layerBlocks.get().blocks(settings));
}
}
@@ -0,0 +1,143 @@
/*
* 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.builtin.terrain;
import art.arcane.iris.builtin.IrisSeed;
import art.arcane.volmlib.util.cache.AtomicCache;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.FeatureAttachment.Target;
import com.volmit.block.BlockState;
import com.volmit.block.PaletteSpec;
import com.volmit.config.FeatureSettings.Entry;
import com.volmit.noise.NoiseSampler;
import com.volmit.resource.PackResources;
import com.volmit.world.PackWorld;
import com.volmit.world.UpperDimension;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* What the terrain module keeps for one world about the palettes that fill its terrain: the rock below the biomes' layers
* and the fluid of its oceans and aquifers, as a block for every column, and the rock of an upper dimension. They are the
* dimension's {@link RockPaletteSettings} and {@link FluidPaletteSettings}.
*
* <p>The noise of a palette is seeded from the world's complex seed and a signature of its own, as the complex always did, so
* a column's rock and fluid do not depend on who asks first.
*/
public final class TerrainPalettes {
private static final int ROCK_SIGNATURE = 45;
private static final int FLUID_SIGNATURE = 78;
/** The salt Iris's material palettes always added to the seed of the noise that picks their blocks. */
private static final int PALETTE_NOISE_SALT = -23_498_896;
/** A block for every column. */
@FunctionalInterface
public interface ColumnBlocks {
/** The block at the column, or null when the palette has no block. */
BlockState at(double x, double z);
}
private final PackWorld world;
private final long complexSeed;
private final AtomicCache<ColumnBlocks> rock = new AtomicCache<>();
private final AtomicCache<ColumnBlocks> fluid = new AtomicCache<>();
private final Map<String, ColumnBlocks> upperRocks = new ConcurrentHashMap<>();
TerrainPalettes(PackWorld world) {
this.world = world;
this.complexSeed = IrisSeed.COMPLEX.of(world);
}
/** The palettes of {@code world}. */
public static TerrainPalettes of(PackWorld world) {
return world.state(TerrainPalettes.class, TerrainPalettes::new);
}
/** Builds the rock and fluid noise now instead of when first asked for. */
public void warm() {
rock();
fluid();
}
/** The rock at the column, below the biome's layers. */
public BlockState rockAt(double x, double z) {
return rock().at(x, z);
}
/** The fluid at the column, above the terrain up to the fluid height. */
public BlockState fluidAt(double x, double z) {
return fluid().at(x, z);
}
/** The rock at the column of the upper dimension: the world's own when the upper dimension is the dimension itself. */
public BlockState upperRockAt(UpperDimension upper, double x, double z) {
return upperRocks.computeIfAbsent(upper.key(), key -> upperRock(upper, x, z)).at(x, z);
}
private ColumnBlocks rock() {
return rock.aquireOrThrow(() -> columns(rockPalette(world.settings().declared(RockPaletteSettings.class)), complexRng().nextParallelRNG(ROCK_SIGNATURE),
world.resources()));
}
private ColumnBlocks fluid() {
return fluid.aquireOrThrow(() -> columns(fluidPalette(world.settings().declared(FluidPaletteSettings.class)), complexRng().nextParallelRNG(FLUID_SIGNATURE),
world.resources()));
}
private RNG complexRng() {
return new RNG(complexSeed);
}
private ColumnBlocks upperRock(UpperDimension upper, double x, double z) {
if (upper.isThisDimension()) {
return rock();
}
long seedOffset = upper.key().hashCode();
RNG rng = new RNG(complexSeed ^ seedOffset);
List<Entry<RockPaletteSettings>> declared = upper.settings().at(RockPaletteSettings.class, (int) x, (int) z);
return columns(rockPalette(declared), rng.nextParallelRNG(ROCK_SIGNATURE), upper.resources());
}
private static PaletteSpec rockPalette(List<Entry<RockPaletteSettings>> declared) {
return dimensionLevel(declared).map(Entry::value).orElseGet(RockPaletteSettings::new).palette();
}
private static PaletteSpec fluidPalette(List<Entry<FluidPaletteSettings>> declared) {
return dimensionLevel(declared).map(Entry::value).orElseGet(FluidPaletteSettings::new).palette();
}
private static <S extends com.volmit.IrisFeature> java.util.Optional<Entry<S>> dimensionLevel(List<Entry<S>> declared) {
return declared.stream().filter(entry -> entry.level() == Target.DIMENSION).findFirst();
}
/** The palette's blocks over the columns, picked by its noise: the noise at a column, from 0 to 1, is how far down the weighted list the block is. */
private static ColumnBlocks columns(PaletteSpec palette, RNG rng, PackResources resources) {
List<BlockState> blocks = PaletteBlocks.weighted(resources.blocks(), palette.palette());
if (blocks.isEmpty()) {
return (x, z) -> null;
}
long seed = rng.getSeed() + (PALETTE_NOISE_SALT + blocks.size());
NoiseSampler noise = resources.noise().sampler(palette.style(), seed);
int last = blocks.size() - 1;
return (x, z) -> blocks.get((int) Math.round(noise.sample(x, z) * last));
}
}