Merge branch 'wave3/t'

This commit is contained in:
piexel committed 2026-10-10 13:04:54 +02:00
commit 0a09c007af
35 files changed
+1412 -712

No files matched your search

+9
View File
@@ -64,6 +64,15 @@ seed is the world's decorator seed, its biome's key and its place in the biome's
them ahead of generation; `iris:terrain` and `iris:objects` warm their ore generators, placements and procedural
objects the same way.
`iris:terrain` and `iris:post` own the fields that shape a column's blocks. Per biome: `layers`, `seaLayers`, `caveCeilingLayers` (lists of
`PaletteLayer`, the old biome palette layer, in `art.arcane.iris.builtin.terrain`), `slab` and `wall` (one `PaletteLayer` each), `lockLayers` (a
boolean) and `lockLayersMax` (a number). Per dimension: `rockPalette` and `fluidPalette` (a `PaletteSpec` each) in `art.arcane.iris.builtin.terrain`, and
`postProcessing`, `postProcessingSlabs`, `postProcessingWalls` (booleans) in `art.arcane.iris.builtin.post`. A key a pack leaves out has the
default Iris always had (one grass layer, no slab or wall, stone and water, post processing on). `ResolvedLayer` resolves one layer's blocks and noise
for a pack, `BiomeLayers`, the world's state, keeps them and stacks a biome's layers into the blocks of a column, and `TerrainPalettes` is the world's
rock and fluid as a block for every column; the terrain, cave, floating and post stages ask them. The slope limit of a layer, a decorator and an
object placement is the one `SlopeClip`.
Packs write each settings feature under the short key it declares: `deposits` (dimension, region, biome; a list), `decorators`
(biome; a list) and `importedStructures` (dimension; an object of `disabled`, `adjustments` and the rest). The feature ids
(`iris:deposit`, `iris:decorant`, `iris:structure`) stay the modules' identity in the stage graph and logs. A key is unique
+1
View File
@@ -1,5 +1,6 @@
art/arcane/iris/engine/actuator/**
art/arcane/iris/engine/decorator/**
art/arcane/iris/engine/terrain/**
art/arcane/iris/engine/modifier/**
art/arcane/iris/engine/mantle/components/**
art/arcane/iris/engine/object/**
@@ -18,6 +18,7 @@
package art.arcane.iris.builtin.decorant;
import art.arcane.iris.builtin.prepare.SlopeClip;
import com.volmit.block.BlockSpec;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
@@ -60,7 +61,7 @@ public final class Decorator {
private List<BlockSpec> blacklist;
@Desc("The slope at which this decorator can be placed. Range from 0 to 10 by default. Calculated from a 3-block radius from the center of the decorator placement.")
private DecoratorSlope slopeCondition = new DecoratorSlope();
private SlopeClip slopeCondition = new SlopeClip();
@Desc("If stackMax is set to true, use this to limit its max height for large caverns")
private int absoluteMaxStack = 30;
@@ -143,8 +144,8 @@ public final class Decorator {
return blacklist != null;
}
public DecoratorSlope slopeCondition() {
return slopeCondition == null ? new DecoratorSlope() : slopeCondition;
public SlopeClip slopeCondition() {
return slopeCondition == null ? new SlopeClip() : slopeCondition;
}
public int absoluteMaxStack() {
@@ -1,64 +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.builtin.decorant;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinNumber;
/** The terrain slopes a decorator may be placed on, as packs write it in a decorator's {@code slopeCondition}. */
@Desc("Limits placement to a minimum and maximum terrain slope")
public final class DecoratorSlope {
private static final double UNLIMITED_MINIMUM = 0;
private static final double UNLIMITED_MAXIMUM = 10;
@MinNumber(0)
@MaxNumber(1024)
@Desc("The minimum slope for placement")
private double minimumSlope = UNLIMITED_MINIMUM;
@MinNumber(0)
@MaxNumber(1024)
@Desc("The maximum slope for placement")
private double maximumSlope = UNLIMITED_MAXIMUM;
public DecoratorSlope() {
}
public double minimumSlope() {
return minimumSlope;
}
public double maximumSlope() {
return maximumSlope;
}
/** Whether every slope passes: the limits are the defaults, or looser. */
public boolean isDefault() {
return minimumSlope <= UNLIMITED_MINIMUM && maximumSlope >= UNLIMITED_MAXIMUM;
}
public boolean isValid(double slope) {
if (isDefault()) {
return true;
}
return !(minimumSlope > slope) && !(maximumSlope < slope);
}
}
@@ -19,7 +19,7 @@
package art.arcane.iris.builtin.floating;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer;
import art.arcane.iris.builtin.terrain.PaletteLayer;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinItems;
@@ -149,7 +149,7 @@ public final class FloatingChildBiome {
@MinItems(1)
@Desc("Custom palette layers used near the underside when bottomPaletteMode=CUSTOM. The layer format is the same as normal biome layers.")
private List<IrisBiomePaletteLayer> bottomPalette = List.of();
private List<PaletteLayer> bottomPalette = List.of();
@MinNumber(1)
@MaxNumber(512)
@@ -315,7 +315,7 @@ public final class FloatingChildBiome {
return bottomPaletteMode == null ? FloatingBottomPaletteMode.DEPTH : bottomPaletteMode;
}
public List<IrisBiomePaletteLayer> bottomPalette() {
public List<PaletteLayer> bottomPalette() {
return bottomPalette == null ? List.of() : Collections.unmodifiableList(bottomPalette);
}
@@ -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.post;
import com.volmit.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
/**
* Whether a dimension is post processed, written as {@code "postProcessing": true}. Iris has never read this flag: surface smoothing runs
* whatever it says, so it is declared to keep the key valid in packs.
*/
@Desc("Use post processing or not")
@Feature(id = "iris:post/enabled", name = "Post processing", key = "postProcessing", root = "enabled", targets = Target.DIMENSION)
public final class PostProcessingSettings implements IrisFeature {
public static final boolean DEFAULT_ENABLED = true;
@Desc("Use post processing or not")
private boolean enabled = DEFAULT_ENABLED;
public PostProcessingSettings() {
}
public boolean enabled() {
return enabled;
}
}
@@ -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.post;
import com.volmit.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
/**
* Whether post processing adds slabs on steps in a dimension, written as {@code "postProcessingSlabs": false}. A dimension without the key adds them.
*/
@Desc("Add slabs in post processing")
@Feature(id = "iris:post/slabs", name = "Post processing slabs", key = "postProcessingSlabs", root = "enabled", targets = Target.DIMENSION)
public final class PostProcessingSlabsSettings implements IrisFeature {
public static final boolean DEFAULT_ENABLED = true;
@Desc("Add slabs in post processing")
private boolean enabled = DEFAULT_ENABLED;
public PostProcessingSlabsSettings() {
}
public boolean enabled() {
return enabled;
}
}
@@ -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.post;
import com.volmit.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
/**
* Whether post processing paints walls on steep faces in a dimension, written as {@code "postProcessingWalls": false}. A dimension without the key paints them.
*/
@Desc("Add painted walls in post processing")
@Feature(id = "iris:post/walls", name = "Post processing walls", key = "postProcessingWalls", root = "enabled", targets = Target.DIMENSION)
public final class PostProcessingWallsSettings implements IrisFeature {
public static final boolean DEFAULT_ENABLED = true;
@Desc("Add painted walls in post processing")
private boolean enabled = DEFAULT_ENABLED;
public PostProcessingWallsSettings() {
}
public boolean enabled() {
return enabled;
}
}
@@ -23,7 +23,7 @@ import com.volmit.config.MaxNumber;
import com.volmit.config.MinNumber;
import com.volmit.config.Snippet;
/** The terrain slopes a placement or decorator may sit on, written as its {@code slopeCondition}. */
/** The terrain slopes an object placement, a decorator or a terrain layer may sit on, written as its {@code slopeCondition}. */
@Snippet("slope-clip")
@Desc("Limits placement to a minimum and maximum terrain slope")
public final class SlopeClip {
@@ -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.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
import java.util.List;
/**
* The layers of material on the ceilings of caves in a biome, written as {@code "caveCeilingLayers": [...]}, the list of layers.
*/
@Desc("Layers of materials placed on cave ceilings in this biome, indexed upward from the ceiling surface. Must not have more entries than layers, whose height generators it reuses. Omitting this leaves cave ceilings unchanged.")
@Feature(id = "iris:terrain/cave-ceiling-layers", name = "Cave ceiling layers", key = "caveCeilingLayers", root = "layers", targets = Target.BIOME)
public final class CaveCeilingLayersSettings implements IrisFeature {
@Desc("Layers of materials placed on cave ceilings in this biome, indexed upward from the ceiling surface. Must not have more entries than layers, whose height generators it reuses. Omitting this leaves cave ceilings unchanged.")
private List<PaletteLayer> layers = List.of();
public CaveCeilingLayersSettings() {
}
public List<PaletteLayer> layers() {
return layers == null ? List.of() : layers;
}
}
@@ -0,0 +1,47 @@
/*
* 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.block.BlockSpec;
import com.volmit.block.PaletteSpec;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
import java.util.List;
/**
* The blocks that fill ocean columns and cave aquifers of a dimension, written as {@code "fluidPalette": {...}}, a palette. A dimension without the key is water.
*/
@Desc("The dimension fluid block palette used for ocean columns and cave aquifers.")
@Feature(id = "iris:terrain/fluid-palette", name = "Fluid palette", key = "fluidPalette", root = "palette", targets = Target.DIMENSION)
public final class FluidPaletteSettings implements IrisFeature {
private static final String DEFAULT_BLOCK = "water";
@Desc("The dimension fluid block palette used for ocean columns and cave aquifers.")
private PaletteSpec palette = PaletteSpec.of(List.of(BlockSpec.of(DEFAULT_BLOCK)));
public FluidPaletteSettings() {
}
public PaletteSpec palette() {
return palette == null ? PaletteSpec.of(List.of(BlockSpec.of(DEFAULT_BLOCK))) : palette;
}
}
@@ -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 java.util.List;
/**
* The layers of material a biome is made of below its surface, written as {@code "layers": [...]}, the list of layers. A biome
* that declares none gets one layer of grass, so the settings class default is what a biome without the key has.
*/
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
@Feature(id = "iris:terrain/layers", name = "Layers", key = "layers", root = "layers", targets = Target.BIOME)
public final class LayersSettings implements IrisFeature {
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
private List<PaletteLayer> layers = List.of(new PaletteLayer());
public LayersSettings() {
}
public List<PaletteLayer> layers() {
return layers == null ? List.of() : layers;
}
}
@@ -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.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
/** How many layers a locked biome iterates below the surface, written as {@code "lockLayersMax": 7}. A biome without the key iterates seven. */
@Desc("The max layers to iterate below the surface for locked layer biomes (mesa).")
@Feature(id = "iris:terrain/lock-layers-max", name = "Lock layers max", key = "lockLayersMax", root = "layers", targets = Target.BIOME)
public final class LockLayersMaxSettings implements IrisFeature {
public static final int DEFAULT_LAYERS = 7;
@Desc("The max layers to iterate below the surface for locked layer biomes (mesa).")
private int layers = DEFAULT_LAYERS;
public LockLayersMaxSettings() {
}
public int layers() {
return layers;
}
}
@@ -0,0 +1,39 @@
/*
* 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 biome's layers are locked to its highest possible height, written as {@code "lockLayers": true}. A biome without the key is not locked. */
@Desc("Layers no longer descend from the surface block, they descend from the max possible height the biome can produce (constant) creating mesa like layers.")
@Feature(id = "iris:terrain/lock-layers", name = "Lock layers", key = "lockLayers", root = "locked", targets = Target.BIOME)
public final class LockLayersSettings implements IrisFeature {
@Desc("Layers no longer descend from the surface block, they descend from the max possible height the biome can produce (constant) creating mesa like layers.")
private boolean locked = false;
public LockLayersSettings() {
}
public boolean locked() {
return locked;
}
}
@@ -0,0 +1,103 @@
/*
* 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 com.volmit.block.BlockSpec;
import com.volmit.config.Desc;
import com.volmit.config.MaxNumber;
import com.volmit.config.MinItems;
import com.volmit.config.MinNumber;
import com.volmit.config.Required;
import com.volmit.config.Snippet;
import com.volmit.noise.NoiseStyle;
import java.util.List;
/**
* One layer of surface or subsurface material of a biome, as packs write it in the biome's layers, sea layers, cave
* ceiling layers, slab and wall, in a floating island's bottom palette or under {@code snippet/biome-palette/}. A value of
* IrisApi types only; the terrain module resolves the blocks and builds the noise.
*/
@Snippet("biome-palette")
@Desc("A layer of surface / subsurface material in biomes")
public final class PaletteLayer {
private static final String STATIC_NOISE = "STATIC";
private static final String DEFAULT_BLOCK = "grass_block";
@Desc("The style of noise")
private NoiseStyle style = NoiseStyle.of(STATIC_NOISE);
@MinNumber(0)
@MaxNumber(2032)
@Desc("The min thickness of this layer")
private int minHeight = 1;
@MinNumber(1)
@MaxNumber(2032)
@Desc("The max thickness of this layer")
private int maxHeight = 1;
@Desc("If set, this layer only shows where the terrain slope is within these bounds; outside them the layer is skipped entirely. Thickness is not scaled by slope.")
private SlopeClip slopeCondition = new SlopeClip();
@MinNumber(0.0001)
@Desc("The terrain zoom mostly for zooming in on a wispy palette")
private double zoom = 5;
@Required
@MinItems(1)
@Desc("The palette of blocks to be used in this layer")
private List<BlockSpec> palette = List.of(BlockSpec.of(DEFAULT_BLOCK));
/** A layer with every option at its default, as packs get it from {@code {}}. */
public PaletteLayer() {
}
/** A layer with the default options and no block to place, which is what a biome without a slab or wall has. */
public static PaletteLayer withoutBlocks() {
PaletteLayer layer = new PaletteLayer();
layer.palette = List.of();
return layer;
}
public NoiseStyle style() {
return style == null ? NoiseStyle.of(STATIC_NOISE) : style;
}
public int minHeight() {
return minHeight;
}
public int maxHeight() {
return maxHeight;
}
public SlopeClip slopeCondition() {
return slopeCondition == null ? new SlopeClip() : slopeCondition;
}
public double zoom() {
return zoom;
}
public List<BlockSpec> palette() {
return palette == null ? List.of() : palette;
}
}
@@ -0,0 +1,47 @@
/*
* 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.block.BlockSpec;
import com.volmit.block.PaletteSpec;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
import java.util.List;
/**
* The blocks that fill terrain below the layers of a dimension, written as {@code "rockPalette": {...}}, a palette. A dimension without the key is stone.
*/
@Desc("The palette of blocks for 'stone'")
@Feature(id = "iris:terrain/rock-palette", name = "Rock palette", key = "rockPalette", root = "palette", targets = Target.DIMENSION)
public final class RockPaletteSettings implements IrisFeature {
private static final String DEFAULT_BLOCK = "stone";
@Desc("The palette of blocks for 'stone'")
private PaletteSpec palette = PaletteSpec.of(List.of(BlockSpec.of(DEFAULT_BLOCK)));
public RockPaletteSettings() {
}
public PaletteSpec palette() {
return palette == null ? PaletteSpec.of(List.of(BlockSpec.of(DEFAULT_BLOCK))) : palette;
}
}
@@ -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.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
import java.util.List;
/**
* The layers of material filling the water column of a sea biome, written as {@code "seaLayers": [...]}, the list of layers.
*/
@Desc("Layers of materials filling the water column of sea biomes, indexed downward from the water surface. Anything below the last layer is filled with the dimension fluid palette, not stone.")
@Feature(id = "iris:terrain/sea-layers", name = "Sea layers", key = "seaLayers", root = "layers", targets = Target.BIOME)
public final class SeaLayersSettings implements IrisFeature {
@Desc("Layers of materials filling the water column of sea biomes, indexed downward from the water surface. Anything below the last layer is filled with the dimension fluid palette, not stone.")
private List<PaletteLayer> layers = List.of();
public SeaLayersSettings() {
}
public List<PaletteLayer> layers() {
return layers == null ? List.of() : layers;
}
}
@@ -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.FeatureAttachment.Target;
import com.volmit.IrisFeature;
import com.volmit.config.Desc;
import com.volmit.config.Feature;
/**
* The slab post processing places on steps in a biome, written as {@code "slab": {...}}, one layer. A biome without the key has no slab.
*/
@Desc("The default slab if iris decides to place a slab in this biome. Default is no slab.")
@Feature(id = "iris:terrain/slab", name = "Slab", key = "slab", root = "layer", targets = Target.BIOME)
public final class SlabSettings implements IrisFeature {
@Desc("The default slab if iris decides to place a slab in this biome. Default is no slab.")
private PaletteLayer layer = PaletteLayer.withoutBlocks();
public SlabSettings() {
}
public PaletteLayer layer() {
return layer == null ? PaletteLayer.withoutBlocks() : layer;
}
}
@@ -0,0 +1,42 @@
/*
* 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;
/**
* The wall post processing paints on steep faces, and caves paint on their walls, in a biome, written as {@code "wall": {...}}, one layer.
* A biome without the key has no wall.
*/
@Desc("The default wall if iris decides to place a wall higher than 2 blocks (steep hills or possibly cliffs)")
@Feature(id = "iris:terrain/wall", name = "Wall", key = "wall", root = "layer", targets = Target.BIOME)
public final class WallSettings implements IrisFeature {
@Desc("The default wall if iris decides to place a wall higher than 2 blocks (steep hills or possibly cliffs)")
private PaletteLayer layer = PaletteLayer.withoutBlocks();
public WallSettings() {
}
public PaletteLayer layer() {
return layer == null ? PaletteLayer.withoutBlocks() : layer;
}
}
@@ -19,6 +19,15 @@
package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.terrain.CaveCeilingLayersSettings;
import art.arcane.iris.builtin.terrain.FluidPaletteSettings;
import art.arcane.iris.builtin.terrain.LayersSettings;
import art.arcane.iris.builtin.terrain.LockLayersMaxSettings;
import art.arcane.iris.builtin.terrain.LockLayersSettings;
import art.arcane.iris.builtin.terrain.RockPaletteSettings;
import art.arcane.iris.builtin.terrain.SeaLayersSettings;
import art.arcane.iris.builtin.terrain.SlabSettings;
import art.arcane.iris.builtin.terrain.WallSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.modules.IrisChunk;
import art.arcane.iris.core.modules.IrisPackWorld;
@@ -30,6 +39,8 @@ import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.world.region.IrisRegion;
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.iris.util.project.context.ChunkContext;
@@ -51,7 +62,7 @@ import com.volmit.world.PackWorld;
* Module {@code iris:terrain}: the chunk's ground, fluids and biome layers. Each column is filled from bedrock up
* to its height and the fluid height with its biome's layers, with ore generators of the dimension, region and
* biome replacing blocks on the way and the upper dimension's ground filled in from the top. The ore generators' noise
* is built ahead of generation, in {@link #warmUp}.
* and the rock and fluid palettes' noise are built ahead of generation, in {@link #warmUp}.
*/
public final class TerrainModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = "built-in";
@@ -63,12 +74,23 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
@Override
public void register(FeatureRegistry registry) {
registry.registerSettings(LayersSettings.class);
registry.registerSettings(SeaLayersSettings.class);
registry.registerSettings(CaveCeilingLayersSettings.class);
registry.registerSettings(SlabSettings.class);
registry.registerSettings(WallSettings.class);
registry.registerSettings(LockLayersSettings.class);
registry.registerSettings(LockLayersMaxSettings.class);
registry.registerSettings(RockPaletteSettings.class);
registry.registerSettings(FluidPaletteSettings.class);
registry.registerLifecycle(this);
}
@Override
public void warmUp(PackWorld world) {
new OreWarmUp(IrisPackWorld.of(world).engine()).warm();
Engine engine = IrisPackWorld.of(world).engine();
TerrainPalettes.of(engine).warm();
new OreWarmUp(engine).warm();
}
@Override
@@ -86,10 +108,18 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
private static final PlatformBlockState BEDROCK = B.getState("BEDROCK");
private final Engine engine;
private final TerrainPalettes palettes;
private final BiomeLayers layers;
private final RNG rng;
TerrainShaper(Engine engine) {
this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine));
}
TerrainShaper(Engine engine, TerrainPalettes palettes, BiomeLayers layers) {
this.engine = engine;
this.palettes = palettes;
this.layers = layers;
this.rng = new RNG(engine.getSeedManager().getTerrain());
}
@@ -118,8 +148,6 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
boolean hideOres = dimension.isHideOresForHiddenOre();
ChunkedDataCache<IrisBiome> biomeCache = context.getBiome();
ChunkedDataCache<IrisRegion> regionCache = context.getRegion();
ChunkedDataCache<PlatformBlockState> fluidCache = context.getFluid();
ChunkedDataCache<PlatformBlockState> rockCache = context.getRock();
int realX = xf + x;
UpperDimensionContext upperContext = engine.getUpperContext();
// Dimension-level ore lookups are chunk-invariant; resolving them per column paid
@@ -140,8 +168,8 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
}
int topY = Math.min(hf, chunkHeight - 1);
PlatformBlockState fluid = fluidCache.get(xf, zf);
PlatformBlockState rock = rockCache.get(xf, zf);
PlatformBlockState fluid = palettes.fluidAt(realX, realZ);
PlatformBlockState rock = palettes.rockAt(realX, realZ);
PlatformBlockState mappedSurfaceBlock = complex.getImageMapRuntime().sampleSurfaceBlock(realX, realZ);
KList<IrisOreGenerator> biomeSurfaceOres = hideOres ? null : biome.getSurfaceOreGenerators();
KList<IrisOreGenerator> regionSurfaceOres = hideOres ? null : region.getSurfaceOreGenerators();
@@ -182,7 +210,7 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
if (i > he && i <= hf) {
int fdepth = hf - i;
if (fblocks == null) {
fblocks = biome.generateSeaLayers(realX, realZ, localRng, hf - he, data);
fblocks = layers.generateSeaLayers(biome, realX, realZ, localRng, hf - he, data);
}
if (fblocks.hasIndex(fdepth)) {
@@ -200,7 +228,7 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
continue;
}
if (blocks == null) {
blocks = biome.generateLayers(dimension, realX, realZ, localRng, he, he, data, complex);
blocks = layers.generateLayers(biome, dimension, realX, realZ, localRng, he, he, data, complex);
}
if (blocks.hasIndex(depth)) {
@@ -235,11 +263,11 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
if (upperSurfaceY < chunkHeight - 1) {
IrisBiome upperBiome = upperContext.getUpperBiome(realX, realZ);
PlatformBlockState upperRock = upperContext.getRockBlock(realX, realZ);
PlatformBlockState upperRock = palettes.upperRockAt(upperContext, realX, realZ);
PlatformBlockState upperMappedSurface = upperContext.getSurfaceBlock(realX, realZ);
int upperThickness = chunkHeight - 1 - upperSurfaceY;
KList<PlatformBlockState> upperBlocks = upperBiome != null
? upperBiome.generateLayers(upperContext.getDimension(),
? layers.generateLayers(upperBiome, upperContext.getDimension(),
realX, realZ, localRng, upperThickness, upperThickness,
upperContext.getData(), complex)
: null;
@@ -23,6 +23,7 @@ import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.UpperDimensionContext;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.mantle.MantleWriter;
import art.arcane.iris.engine.terrain.TerrainPalettes;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
@@ -466,7 +467,7 @@ public class CaveCarving {
private void prefillProfileFieldSamples(int startX, int startZ, IrisComplex complex, BlendScratch blendScratch) {
fillFieldHeights(complex.getHeightStream(), startX, startZ, blendScratch.fieldSurfaceHeights);
fillFieldFluidPresence(complex.getFluidStream(), startX, startZ, blendScratch.fieldHasFluid);
fillFieldFluidPresence(TerrainPalettes.of(engine), startX, startZ, blendScratch.fieldHasFluid);
fillFieldObjects(complex.getRegionStream(), startX, startZ, blendScratch.fieldRegions);
fillFieldObjects(complex.getTrueBiomeStream(), startX, startZ, blendScratch.fieldSurfaceBiomes);
fillFieldObjects(complex.getCaveBiomeStream(), startX, startZ, blendScratch.fieldCaveBiomes);
@@ -490,11 +491,11 @@ public class CaveCarving {
}
}
private void fillFieldFluidPresence(ProceduralStream<PlatformBlockState> stream, int startX, int startZ, boolean[] target) {
private void fillFieldFluidPresence(TerrainPalettes palettes, int startX, int startZ, boolean[] target) {
for (int fieldX = 0; fieldX < FIELD_SIZE; fieldX++) {
int worldX = startX + fieldX;
for (int fieldZ = 0; fieldZ < FIELD_SIZE; fieldZ++) {
target[(fieldX * FIELD_SIZE) + fieldZ] = B.isFluid(stream.get(worldX, startZ + fieldZ));
target[(fieldX * FIELD_SIZE) + fieldZ] = B.isFluid(palettes.fluidAt(worldX, startZ + fieldZ));
}
}
}
@@ -21,6 +21,8 @@ package art.arcane.iris.engine.modifier;
import art.arcane.iris.engine.UpperDimensionContext;
import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.engine.decorator.BiomeDecorators;
import art.arcane.iris.engine.terrain.BiomeLayers;
import art.arcane.iris.engine.terrain.TerrainPalettes;
import art.arcane.iris.engine.decorator.IrisCeilingDecorator;
import art.arcane.iris.engine.decorator.IrisSurfaceDecorator;
import art.arcane.iris.engine.framework.Engine;
@@ -66,6 +68,8 @@ public class CaveApplying {
private final PlatformBlockState AIR = B.getState("CAVE_AIR");
private final PlatformBlockState LAVA = B.getState("LAVA");
private final BiomeDecorators decorators;
private final BiomeLayers layers;
private final TerrainPalettes palettes;
private final IrisSurfaceDecorator surfaceDecorator;
private final IrisCeilingDecorator ceilingDecorator;
@@ -73,6 +77,8 @@ public class CaveApplying {
this.engine = engine;
rng = new RNG(engine.getSeedManager().getCarve());
decorators = BiomeDecorators.of(engine);
layers = BiomeLayers.of(engine);
palettes = TerrainPalettes.of(engine);
surfaceDecorator = new IrisSurfaceDecorator(engine);
ceilingDecorator = new IrisCeilingDecorator(engine);
}
@@ -151,7 +157,7 @@ public class CaveApplying {
if (explicitCarveIntent) {
// Only a fluid cavern consumes the fluid sample, and on the maintenance path that
// sample is a full procedural stream evaluation, so never take it per voxel.
PlatformBlockState fluid = isFluidIntent(cavern) ? context.getFluid().get(rx, rz) : null;
PlatformBlockState fluid = isFluidIntent(cavern) ? palettes.fluidAt(chunkBlockX + rx, chunkBlockZ + rz) : null;
output.setRaw(rx, yy, rz, resolveExplicitCarveState(cavern, fluid, LAVA, AIR));
} else if (usesDefaultLava(caveLavaHeight, yy)) {
output.setRaw(rx, yy, rz, LAVA);
@@ -178,7 +184,7 @@ public class CaveApplying {
: resolveCustomBiome(customBiomeCache, customBiome);
if (biome != null) {
PlatformBlockState data = biome.getWall().get(rng, worldX, yy, worldZ, engine.getData());
PlatformBlockState data = layers.wall(biome, engine.getData()).get(rng, worldX, yy, worldZ);
int columnIndex = PowerOfTwoCoordinates.packLocal16(rx, rz);
if (data != null && B.isSolid(output.getRaw(rx, yy, rz)) && yy < surfaceHeights[columnIndex]) {
@@ -516,7 +522,7 @@ public class CaveApplying {
}
if (floorBiome != null) {
KList<PlatformBlockState> floorLayers = floorBiome.generateLayers(
KList<PlatformBlockState> floorLayers = layers.generateLayers(floorBiome,
engine.getDimension(), worldX, worldZ, rng, 3, zoneFloor, engine.getData(), engine.getComplex());
for (int i = 0; i < zoneFloor - 1; i++) {
if (!floorLayers.hasIndex(i)) {
@@ -541,7 +547,7 @@ public class CaveApplying {
if (ceilingBiome != null) {
int worldMaxY = engine.getWorld().maxHeight() - engine.getWorld().minHeight();
KList<PlatformBlockState> ceilingLayers = ceilingBiome.generateCeilingLayers(
KList<PlatformBlockState> ceilingLayers = layers.generateCeilingLayers(ceilingBiome,
engine.getDimension(), worldX, worldZ, rng, 3, zoneCeiling, engine.getData(), engine.getComplex());
for (int i = 0; i < ceilingLayers.size(); i++) {
int ceilingY = zoneCeiling + i + 1;
@@ -603,7 +609,7 @@ public class CaveApplying {
}
if (floorBiome != null) {
KList<PlatformBlockState> floorBlocks = floorBiome.generateLayers(engine.getDimension(), xx, zz, rng, 3, zone.floor, engine.getData(), engine.getComplex());
KList<PlatformBlockState> floorBlocks = layers.generateLayers(floorBiome, engine.getDimension(), xx, zz, rng, 3, zone.floor, engine.getData(), engine.getComplex());
for (int i = 0; i < zone.floor - 1; i++) {
if (!floorBlocks.hasIndex(i)) {
break;
@@ -623,7 +629,7 @@ public class CaveApplying {
}
if (ceilingBiome != null) {
KList<PlatformBlockState> ceilingBlocks = ceilingBiome.generateCeilingLayers(engine.getDimension(), xx, zz, rng, 3, zone.ceiling, engine.getData(), engine.getComplex());
KList<PlatformBlockState> ceilingBlocks = layers.generateCeilingLayers(ceilingBiome, engine.getDimension(), xx, zz, rng, 3, zone.ceiling, engine.getData(), engine.getComplex());
for (int i = 0; i < ceilingBlocks.size(); i++) {
int cy = zone.ceiling + i + 1;
if (cy >= maxY) {
@@ -22,6 +22,7 @@ package art.arcane.iris.engine.modifier;
import art.arcane.iris.engine.object.terrain.floating.ResolvedFloatingChild;
import art.arcane.iris.builtin.floating.FloatingBottomPaletteMode;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.builtin.terrain.PaletteLayer;
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.IrisComplex;
@@ -32,7 +33,8 @@ import art.arcane.iris.engine.framework.EngineDecorator;
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandBoundarySampler;
import art.arcane.iris.engine.object.terrain.floating.FloatingIslandSample;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer;
import art.arcane.iris.engine.terrain.BiomeLayers;
import art.arcane.iris.engine.terrain.ResolvedLayer;
import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisLogging;
@@ -64,15 +66,16 @@ public class FloatingIslands {
private final Engine engine;
private final RNG rng;
private final EngineDecorator seaSurfaceDecorator;
private final BiomeLayers biomeLayers;
private static KList<PlatformBlockState> generateBottomPaletteLayers(ResolvedFloatingChild entry, IrisDimension dimension, double wx, double wz, RNG random, int paletteDepth, IrisData data, IrisComplex complex) {
private KList<PlatformBlockState> generateBottomPaletteLayers(ResolvedFloatingChild entry, IrisDimension dimension, double wx, double wz, RNG random, int paletteDepth, IrisData data, IrisComplex complex) {
if (entry == null || entry.settings().bottomPaletteMode() != FloatingBottomPaletteMode.CUSTOM || entry.settings().bottomPalette() == null || entry.settings().bottomPalette().isEmpty()) {
return null;
}
return generatePaletteLayers(dimension, new KList<>(entry.settings().bottomPalette()), wx, wz, random.nextParallelRNG(0xB0770B), paletteDepth, data, complex);
}
private static KList<PlatformBlockState> generatePaletteLayers(IrisDimension dimension, KList<IrisBiomePaletteLayer> layers, double wx, double wz, RNG random, int maxDepth, IrisData data, IrisComplex complex) {
private KList<PlatformBlockState> generatePaletteLayers(IrisDimension dimension, KList<PaletteLayer> layers, double wx, double wz, RNG random, int maxDepth, IrisData data, IrisComplex complex) {
KList<PlatformBlockState> generated = new KList<>();
if (layers == null || layers.isEmpty() || maxDepth <= 0) {
return generated;
@@ -80,13 +83,13 @@ public class FloatingIslands {
int generatorSeed = 7235;
for (int i = 0; i < layers.size(); i++) {
IrisBiomePaletteLayer layer = layers.get(i);
CNG heightGenerator = layer.getHeightGenerator(random.nextParallelRNG((generatorSeed++) * generatorSeed * generatorSeed * generatorSeed), data);
ResolvedLayer layer = biomeLayers.resolve(layers.get(i), data);
CNG heightGenerator = layer.heightNoise(random.nextParallelRNG((generatorSeed++) * generatorSeed * generatorSeed * generatorSeed));
if (heightGenerator == null) {
continue;
}
double layerDepth = heightGenerator.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / layer.getZoom(), wz / layer.getZoom());
SlopeClip slopeClip = layer.getSlopeCondition();
double layerDepth = heightGenerator.fit(layer.minHeight(), layer.maxHeight(), wx / layer.zoom(), wz / layer.zoom());
SlopeClip slopeClip = layer.slopeCondition();
if (slopeClip != null && !slopeClip.isDefault() && complex != null && !slopeClip.isValid(complex.getSlopeStream().get(wx, wz))) {
layerDepth = 0;
@@ -102,7 +105,7 @@ public class FloatingIslands {
}
try {
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.getZoom(), j, (wz - j) / layer.getZoom(), data));
generated.add(layer.get(random.nextParallelRNG(i + j), (wx + j) / layer.zoom(), j, (wz - j) / layer.zoom()));
} catch (Throwable e) {
IrisLogging.reportError(e);
}
@@ -183,9 +186,9 @@ public class FloatingIslands {
IrisBiome target = entry == null ? parent : entry.getRealBiome(parent, data);
int entrySeed = entry == null || entry.settings().biome() == null ? 0 : entry.settings().biome().hashCode();
RNG layerRng = rng.nextParallelRNG((int) (colSeed ^ 0x7A4E ^ entrySeed));
KList<PlatformBlockState> topBlocks = target == null ? null : target.generateLayers(dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
KList<PlatformBlockState> topBlocks = target == null ? null : biomeLayers.generateLayers(target, dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
if (topBlocks == null || topBlocks.isEmpty()) {
topBlocks = parent.generateLayers(dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
topBlocks = biomeLayers.generateLayers(parent, dimension, wx, wz, layerRng, paletteDepth, paletteDepth, data, complex);
}
KList<PlatformBlockState> bottomBlocks = generateBottomPaletteLayers(entry, dimension, wx, wz, layerRng, paletteDepth, data, complex);
return new PaletteContext(topBlocks, bottomBlocks, B.getState("minecraft:stone"));
@@ -207,6 +210,7 @@ public class FloatingIslands {
this.engine = engine;
rng = new RNG(engine.getSeedManager().getTerrain() ^ 0x7EB0A73F1DCE514DL);
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine);
biomeLayers = BiomeLayers.of(engine);
}
/** Fills the islands' solids into the chunk whose first block is {@code x}, {@code z}. */
@@ -19,7 +19,11 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.post.PostProcessingSettings;
import art.arcane.iris.builtin.post.PostProcessingSlabsSettings;
import art.arcane.iris.builtin.post.PostProcessingWallsSettings;
import art.arcane.iris.core.modules.IrisChunk;
import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.stage.ChunkStageContext;
@@ -37,6 +41,13 @@ public final class PostModule implements IrisModule {
return ModuleInfo.of("iris:post", "Post-processing", VERSION);
}
@Override
public void register(FeatureRegistry registry) {
registry.registerSettings(PostProcessingSettings.class);
registry.registerSettings(PostProcessingSlabsSettings.class);
registry.registerSettings(PostProcessingWallsSettings.class);
}
@Override
public void install(StageGraph graph) {
graph.define(IrisStages.Post.SMOOTH).requires(IrisStages.Carve.APPLY).run(PostModule::smooth);
@@ -18,12 +18,16 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.post.PostProcessingSlabsSettings;
import art.arcane.iris.builtin.post.PostProcessingWallsSettings;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.mantle.EngineMantle;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
import art.arcane.iris.engine.terrain.BiomeLayers;
import art.arcane.iris.engine.terrain.ResolvedLayer;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.hunk.Hunk;
@@ -42,10 +46,12 @@ public class SurfaceSmoothing {
}
private final Engine engine;
private final BiomeLayers layers;
private final RNG rng;
public SurfaceSmoothing(Engine engine) {
this.engine = engine;
layers = BiomeLayers.of(engine);
rng = new RNG(engine.getSeedManager().getPost());
}
@@ -60,8 +66,10 @@ public class SurfaceSmoothing {
int planeWidth = width + 2;
int[] heights = heightPlane(x, z, width, depth, planeWidth);
IrisDimension dimension = engine.getDimension();
boolean walls = dimension.isPostProcessingWalls();
boolean slabs = dimension.isPostProcessingSlabs();
boolean walls = dimension.getModuleSettings().find(PostProcessingWallsSettings.class)
.map(PostProcessingWallsSettings::enabled).orElse(PostProcessingWallsSettings.DEFAULT_ENABLED);
boolean slabs = dimension.getModuleSettings().find(PostProcessingSlabsSettings.class)
.map(PostProcessingSlabsSettings::enabled).orElse(PostProcessingSlabsSettings.DEFAULT_ENABLED);
int fluidHeight = dimension.getFluidHeight();
for (int i = 0; i < width; i++) {
for (int j = 0; j < depth; j++) {
@@ -176,13 +184,14 @@ public class SurfaceSmoothing {
IrisBiome biome = context.getBiome().get(currentPostX, currentPostZ);
if (walls) {
if (!biome.getWall().getPalette().isEmpty()) {
ResolvedLayer wall = layers.wall(biome, engine.getData());
if (wall.hasPalette()) {
if (ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2) {
boolean brokeGround = false;
int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd))));
for (int i = h; i > h - max; i--) {
PlatformBlockState d = biome.getWall().get(rng, x + i, i + h, z + i, engine.getData());
PlatformBlockState d = wall.get(rng, x + i, i + h, z + i);
if (d != null) {
if (isAirOrWater(x, i, z, originX, originZ, currentData)) {
@@ -210,8 +219,9 @@ public class SurfaceSmoothing {
|| (hd == h + 1 && isSolidNonSlab(x, hd, z - 1, originX, originZ, currentData)))
//@done
{
SlopeClip sc = biome.getSlab().getSlopeCondition();
PlatformBlockState d = sc.isValid(engine.getComplex().getSlopeStream().get(x, z)) ? biome.getSlab().get(rng, x, h, z, engine.getData()) : null;
ResolvedLayer slab = layers.slab(biome, engine.getData());
SlopeClip sc = slab.slopeCondition();
PlatformBlockState d = sc.isValid(engine.getComplex().getSlopeStream().get(x, z)) ? slab.get(rng, x, h, z) : null;
if (d != null) {
boolean cancel = B.isAir(d);
@@ -24,9 +24,9 @@ import art.arcane.iris.builtin.vacuum.VacuumSettings;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.blocks.WrittenBlocks;
import art.arcane.iris.core.modules.IrisPlacement;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.terrain.TerrainPalettes;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.noise.SimplexNoise;
@@ -82,7 +82,7 @@ public final class VacuumModule implements IrisModule {
private final IrisPlacement placement;
private final PreparedPlacement prepared;
private final PlacementWorld world;
private final IrisComplex complex;
private final TerrainPalettes palettes;
private final int radius;
private final int step;
private final double falloff;
@@ -98,7 +98,7 @@ public final class VacuumModule implements IrisModule {
this.placement = IrisPlacement.current();
this.prepared = prepared;
this.world = new PlacementWorld(context.access(), placement.states());
this.complex = engine.getComplex();
this.palettes = engine.getComplex() == null ? null : TerrainPalettes.of(engine);
VacuumSettings settings = prepared.config().getVacuumSettings();
this.radius = IrisObjectVacuum.resolveRadius(vacuum, settings);
this.step = vacuum.columnStepBlocks();
@@ -161,7 +161,7 @@ public final class VacuumModule implements IrisModule {
}
private void raise(int x, int z, int fromY, int toY) {
PlatformBlockState fill = complex != null ? complex.getRockStream().get(x, z) : null;
PlatformBlockState fill = palettes != null ? palettes.rockAt(x, z) : null;
if (B.isAir(fill)) {
fill = IrisObject.States.STONE;
}
@@ -1,360 +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.object.terrain;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.biome.IrisBiomeGeneratorLink;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
/**
* Layer (block palette) generation for {@link IrisBiome}. IrisBiome is Gson deserialized from pack
* JSON, so its fields stay put and only the behavior lives here.
*/
public final class IrisBiomeLayerGenerator {
private static final class States {
private static final PlatformBlockState BARRIER = B.getState("BARRIER");
}
private IrisBiomeLayerGenerator() {
}
public static KList<PlatformBlockState> generateLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
if (biome.isLockLayers()) {
return generateLockedLayers(biome, wx, wz, random, maxDepth, height, rdata, complex);
}
KList<PlatformBlockState> data = new KList<>();
if (maxDepth <= 0) {
return data;
}
KList<IrisBiomePaletteLayer> layers = biome.getLayers();
int layerCount = layers.size();
if (layerCount <= 0) {
return data;
}
KList<CNG> heightGenerators = getLayerHeightGenerators(biome, random, rdata);
for (int i = 0; i < layerCount; i++) {
IrisBiomePaletteLayer layer = layers.get(i);
double zoom = layer.getZoom();
CNG hgen = heightGenerators.get(i);
double d = hgen.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / zoom, wz / zoom);
SlopeClip sc = layer.getSlopeCondition();
if (!sc.isDefault()) {
if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
d = 0;
}
}
if (d <= 0) {
continue;
}
for (int j = 0; j < d; j++) {
if (data.size() >= maxDepth) {
break;
}
try {
data.add(layer.get(random, i + j, (wx + j) / zoom, j, (wz - j) / zoom, rdata));
} catch (Throwable e) {
IrisLogging.reportError(e);
}
}
if (data.size() >= maxDepth) {
break;
}
if (dim.isExplodeBiomePalettes()) {
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
data.add(States.BARRIER);
if (data.size() >= maxDepth) {
break;
}
}
}
}
return data;
}
public static KList<PlatformBlockState> generateCeilingLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
KList<PlatformBlockState> data = new KList<>();
if (maxDepth <= 0) {
return data;
}
KList<IrisBiomePaletteLayer> ceilingLayers = biome.getCaveCeilingLayers();
int layerCount = ceilingLayers.size();
if (layerCount <= 0) {
return data;
}
KList<CNG> heightGenerators = getLayerHeightGenerators(biome, random, rdata);
// Ceiling layers reuse the surface-layer height generators, so entries beyond layers.size() have no generator; skip them.
int usableLayers = Math.min(layerCount, heightGenerators.size());
for (int i = 0; i < usableLayers; i++) {
IrisBiomePaletteLayer layer = ceilingLayers.get(i);
double zoom = layer.getZoom();
CNG hgen = heightGenerators.get(i);
double d = hgen.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / zoom, wz / zoom);
if (d <= 0) {
continue;
}
for (int j = 0; j < d; j++) {
if (data.size() >= maxDepth) {
break;
}
try {
data.add(layer.get(random, i + j, (wx + j) / zoom, j, (wz - j) / zoom, rdata));
} catch (Throwable e) {
IrisLogging.reportError(e);
}
}
if (data.size() >= maxDepth) {
break;
}
if (dim.isExplodeBiomePalettes()) {
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
data.add(States.BARRIER);
if (data.size() >= maxDepth) {
break;
}
}
}
}
return data;
}
public static KList<PlatformBlockState> generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthf, int height, IrisData rdata, IrisComplex complex) {
KList<PlatformBlockState> data = new KList<>();
KList<PlatformBlockState> real = new KList<>();
int maxDepth = Math.min(maxDepthf, biome.getLockLayersMax());
if (maxDepth <= 0) {
return data;
}
KList<IrisBiomePaletteLayer> layers = biome.getLayers();
int layerCount = layers.size();
if (layerCount > 0) {
KList<CNG> heightGenerators = getLayerHeightGenerators(biome, random, rdata);
for (int i = 0; i < layerCount; i++) {
IrisBiomePaletteLayer layer = layers.get(i);
double zoom = layer.getZoom();
CNG hgen = heightGenerators.get(i);
double d = hgen.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / zoom, wz / zoom);
SlopeClip sc = layer.getSlopeCondition();
if (!sc.isDefault()) {
if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
d = 0;
}
}
if (d <= 0) {
continue;
}
for (int j = 0; j < d; j++) {
try {
data.add(layer.get(random, i + j, (wx + j) / zoom, j, (wz - j) / zoom, rdata));
} catch (Throwable e) {
IrisLogging.reportError(e);
}
}
}
}
if (data.isEmpty()) {
return real;
}
for (int i = 0; i < maxDepth; i++) {
int offset = (512 - height) - i;
int index = offset % data.size();
real.add(data.get(Math.max(index, 0)));
}
return real;
}
public static KList<PlatformBlockState> generateSeaLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepth, IrisData rdata) {
KList<PlatformBlockState> data = new KList<>();
KList<IrisBiomePaletteLayer> seaLayers = biome.getSeaLayers();
int layerCount = seaLayers.size();
if (layerCount <= 0) {
return data;
}
KList<CNG> heightGenerators = getLayerSeaHeightGenerators(biome, random, rdata);
for (int i = 0; i < layerCount; i++) {
IrisBiomePaletteLayer layer = seaLayers.get(i);
double zoom = layer.getZoom();
CNG hgen = heightGenerators.get(i);
int d = hgen.fit(layer.getMinHeight(), layer.getMaxHeight(), wx / zoom, wz / zoom);
if (d < 0) {
continue;
}
for (int j = 0; j < d; j++) {
if (data.size() >= maxDepth) {
break;
}
try {
data.add(layer.get(random, i + j, (wx + j) / zoom, j, (wz - j) / zoom, rdata));
} catch (Throwable e) {
IrisLogging.reportError(e);
}
}
if (data.size() >= maxDepth) {
break;
}
}
return data;
}
public static KList<CNG> getLayerHeightGenerators(IrisBiome biome, RNG rng, IrisData rdata) {
AtomicCache<KList<CNG>> cache = biome.getLayerHeightGenerators();
KList<CNG> cached = cache.getIfPresent();
if (cached != null) {
return cached;
}
return cache.aquire(() ->
{
KList<CNG> layerHeightGenerators = new KList<>();
int m = 7235;
for (IrisBiomePaletteLayer i : biome.getLayers()) {
layerHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), rdata));
}
return layerHeightGenerators;
});
}
public static KList<CNG> getLayerSeaHeightGenerators(IrisBiome biome, RNG rng, IrisData data) {
AtomicCache<KList<CNG>> cache = biome.getLayerSeaHeightGenerators();
KList<CNG> cached = cache.getIfPresent();
if (cached != null) {
return cached;
}
return cache.aquire(() ->
{
KList<CNG> layerSeaHeightGenerators = new KList<>();
int m = 7735;
for (IrisBiomePaletteLayer i : biome.getSeaLayers()) {
layerSeaHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), data));
}
return layerSeaHeightGenerators;
});
}
public static PlatformBlockState getSurfaceBlock(IrisBiome biome, int x, int z, RNG rng, IrisData idm) {
KList<IrisBiomePaletteLayer> layers = biome.getLayers();
if (layers.isEmpty()) {
return B.getState("AIR");
}
return layers.get(0).get(rng, x, 0, z, idm);
}
public static int getMaxHeight(IrisBiome biome, Engine engine) {
return biome.getMaxHeight().aquire(() ->
{
int maxHeight = 0;
for (IrisBiomeGeneratorLink i : biome.getGenerators()) {
maxHeight += i.getMax();
}
return maxHeight;
});
}
public static int getMaxWithObjectHeight(IrisBiome biome, IrisData data, Engine engine) {
return biome.getMaxWithObjectHeight().aquire(() ->
{
int maxHeight = 0;
for (IrisBiomeGeneratorLink i : biome.getGenerators()) {
maxHeight += i.getMax();
}
int gg = 0;
for (IrisObjectPlacement i : biome.getObjects()) {
for (IrisObject j : data.getObjectLoader().loadAll(i.getPlace())) {
gg = Math.max(gg, j.getH());
}
}
return maxHeight + gg + 3;
});
}
}
@@ -1,165 +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.object.terrain;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.engine.object.material.IrisBlockData;
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
import art.arcane.iris.engine.object.noise.NoiseStyle;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.DependsOn;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.MaxNumber;
import art.arcane.iris.engine.object.annotations.MinNumber;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.iris.util.project.noise.CNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import art.arcane.iris.spi.PlatformBlockState;
import lombok.experimental.Accessors;
@Snippet("biome-palette")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A layer of surface / subsurface material in biomes")
@Data
public class IrisBiomePaletteLayer {
private final transient AtomicCache<KList<PlatformBlockState>> blockData = new AtomicCache<>();
private final transient AtomicCache<CNG> layerGenerator = new AtomicCache<>();
private final transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
@Desc("The style of noise")
private IrisGeneratorStyle style = NoiseStyle.STATIC.style();
@DependsOn({"minHeight", "maxHeight"})
@MinNumber(0)
@MaxNumber(2032)
@Desc("The min thickness of this layer")
private int minHeight = 1;
@DependsOn({"minHeight", "maxHeight"})
@MinNumber(1)
@MaxNumber(2032)
@Desc("The max thickness of this layer")
private int maxHeight = 1;
@Desc("If set, this layer only shows where the terrain slope is within these bounds; outside them the layer is skipped entirely. Thickness is not scaled by slope.")
private SlopeClip slopeCondition = new SlopeClip();
@MinNumber(0.0001)
@Desc("The terrain zoom mostly for zooming in on a wispy palette")
private double zoom = 5;
@Required
@ArrayType(min = 1, type = IrisBlockData.class)
@Desc("The palette of blocks to be used in this layer")
private KList<IrisBlockData> palette = new KList<IrisBlockData>().qadd(new IrisBlockData("GRASS_BLOCK"));
public CNG getHeightGenerator(RNG rng, IrisData data) {
CNG cached = heightGenerator.getIfPresent();
if (cached != null) {
return cached;
}
return heightGenerator.aquire(() -> CNG.signature(rng.nextParallelRNG(minHeight * maxHeight + getBlockData(data).size())));
}
public PlatformBlockState get(RNG rng, double x, double y, double z, IrisData data) {
return get(rng, 0, x, y, z, data);
}
/**
* Resolves a block for this layer without allocating a child RNG per call. The child RNG is
* only built inside the lazy layer generator initializer, using the exact same seed derivation
* as {@code parent.nextParallelRNG(signature)} followed by the generator signature.
*/
public PlatformBlockState get(RNG parent, int signature, double x, double y, double z, IrisData data) {
KList<PlatformBlockState> localBlockData = getBlockData(data);
if (localBlockData.isEmpty()) {
return null;
}
if (localBlockData.size() == 1) {
return localBlockData.get(0);
}
double localZoom = zoom;
double scaledX = x / localZoom;
double scaledY = y / localZoom;
double scaledZ = z / localZoom;
return getLayerGenerator(parent, signature, data).fit(localBlockData, scaledX, scaledY, scaledZ);
}
public CNG getLayerGenerator(RNG rng, IrisData data) {
return getLayerGenerator(rng, 0, data);
}
public CNG getLayerGenerator(RNG parent, int signature, IrisData data) {
CNG cached = layerGenerator.getIfPresent();
if (cached != null) {
return cached;
}
return layerGenerator.aquire(() ->
{
RNG rngx = parent.nextParallelRNG(signature).nextParallelRNG(minHeight + maxHeight + getBlockData(data).size());
return style.create(rngx, data);
});
}
public KList<IrisBlockData> add(String b) {
palette.add(new IrisBlockData(b));
return palette;
}
public KList<PlatformBlockState> getBlockData(IrisData data) {
KList<PlatformBlockState> cached = blockData.getIfPresent();
if (cached != null) {
return cached;
}
return blockData.aquire(() ->
{
KList<PlatformBlockState> blockData = new KList<>();
for (IrisBlockData ix : palette) {
PlatformBlockState bx = ix.getBlockData(data);
if (bx != null) {
for (int i = 0; i < ix.getWeight(); i++) {
blockData.add(bx);
}
}
}
return blockData;
});
}
public IrisBiomePaletteLayer zero() {
palette.clear();
return this;
}
}
@@ -29,8 +29,6 @@ import art.arcane.iris.engine.object.noise.NoiseStyle;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.object.procedural.IrisProceduralObjects;
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
import art.arcane.iris.engine.object.terrain.IrisBiomeLayerGenerator;
import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer;
import art.arcane.iris.engine.object.terrain.deposit.IrisBiomeOres;
import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant;
import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
@@ -78,7 +76,7 @@ import java.util.Objects;
* Represents a biome in a pack. This type is Gson deserialized straight out of user pack JSON, so
* the field block and the transient {@link AtomicCache} block below are load bearing and must not
* move. Behavior lives in the same-package companions:
* {@link IrisBiomeLayerGenerator}, {@link IrisBiomeDerivatives}, {@link IrisBiomeOres},
* {@link IrisBiomeDerivatives}, {@link IrisBiomeOres},
* {@link IrisBiomeColorRenderer} and {@link IrisBiomeGenLinks}.
*/
@Accessors(chain = true)
@@ -106,12 +104,8 @@ public class IrisBiome extends IrisRegistrant implements IRare {
@Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE)
private transient volatile SeededBiomeGenerator recentBiomeGenerator;
private final transient AtomicCache<Integer> maxHeight = new AtomicCache<>();
private final transient AtomicCache<Integer> maxWithObjectHeight = new AtomicCache<>();
private final transient AtomicCache<IrisBiome> realCarveBiome = new AtomicCache<>();
private final transient AtomicCache<KList<IrisBiome>> realChildren = new AtomicCache<>();
private final transient AtomicCache<KList<CNG>> layerHeightGenerators = new AtomicCache<>();
private final transient AtomicCache<KList<CNG>> layerSeaHeightGenerators = new AtomicCache<>();
private final transient AtomicCache<KList<IrisOreGenerator>> surfaceOreCache = new AtomicCache<>();
private final transient AtomicCache<KList<IrisOreGenerator>> undergroundOreCache = new AtomicCache<>();
private final transient AtomicCache<IrisOreGeneratorBounds> surfaceOreBoundsCache = new AtomicCache<>();
@@ -142,10 +136,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
private KList<IrisBlockDrops> blockDrops = new KList<>();
@Desc("Reference loot tables in this area")
private IrisLootReference loot = new IrisLootReference();
@Desc("Layers no longer descend from the surface block, they descend from the max possible height the biome can produce (constant) creating mesa like layers.")
private boolean lockLayers = false;
@Desc("The max layers to iterate below the surface for locked layer biomes (mesa).")
private int lockLayersMax = 7;
@Desc("Profile-driven 3D cave configuration")
private CaveProfile caveProfile = new CaveProfile();
@MinNumber(1)
@@ -187,20 +177,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
@MaxNumber(256)
@Desc("Minimum depth below terrain surface required before this cave biome can be selected.")
private int caveMinDepthBelowSurface = 0;
@Desc("The default slab if iris decides to place a slab in this biome. Default is no slab.")
private IrisBiomePaletteLayer slab = new IrisBiomePaletteLayer().zero();
@Desc("The default wall if iris decides to place a wall higher than 2 blocks (steep hills or possibly cliffs)")
private IrisBiomePaletteLayer wall = new IrisBiomePaletteLayer().zero();
@Required
@ArrayType(type = IrisBiomePaletteLayer.class)
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
private KList<IrisBiomePaletteLayer> layers = new KList<IrisBiomePaletteLayer>().qadd(new IrisBiomePaletteLayer());
@ArrayType(type = IrisBiomePaletteLayer.class)
@Desc("Layers of materials placed on cave ceilings in this biome, indexed upward from the ceiling surface. Must not have more entries than layers, whose height generators it reuses. Omitting this leaves cave ceilings unchanged.")
private KList<IrisBiomePaletteLayer> caveCeilingLayers = new KList<>();
@ArrayType(type = IrisBiomePaletteLayer.class)
@Desc("Layers of materials filling the water column of sea biomes, indexed downward from the water surface. Anything below the last layer is filled with the dimension fluid palette, not stone.")
private KList<IrisBiomePaletteLayer> seaLayers = new KList<>();
@ArrayType(min = 1, type = IrisObjectPlacement.class)
@Desc("Objects define what schematics (iob files) iris will place in this biome")
private KList<IrisObjectPlacement> objects = new KList<>();
@@ -292,6 +268,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
variant.setLoader(data);
variant.setLoadKey(getLoadKey());
variant.setLoadFile(getLoadFile());
variant.setModuleSettings(getModuleSettings());
variant.inferredType = type;
inferredVariants.put(type, variant);
return variant;
@@ -483,46 +460,6 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return childrenCell.aquire(() -> getChildStyle().create(random.nextParallelRNG(sig * 2137), getLoader()).bake().scale(scale).bake());
}
public KList<PlatformBlockState> generateLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
return IrisBiomeLayerGenerator.generateLayers(this, dim, wx, wz, random, maxDepth, height, rdata, complex);
}
public KList<PlatformBlockState> generateCeilingLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
return IrisBiomeLayerGenerator.generateCeilingLayers(this, dim, wx, wz, random, maxDepth, height, rdata, complex);
}
public KList<PlatformBlockState> generateLockedLayers(double wx, double wz, RNG random, int maxDepthf, int height, IrisData rdata, IrisComplex complex) {
return IrisBiomeLayerGenerator.generateLockedLayers(this, wx, wz, random, maxDepthf, height, rdata, complex);
}
public KList<PlatformBlockState> generateSeaLayers(double wx, double wz, RNG random, int maxDepth, IrisData rdata) {
return IrisBiomeLayerGenerator.generateSeaLayers(this, wx, wz, random, maxDepth, rdata);
}
/**
* Note the arity split: {@code getMaxHeight()} is the Lombok getter for the height cache field,
* {@code getMaxHeight(Engine)} is the resolved biome height.
*/
public int getMaxHeight(Engine engine) {
return IrisBiomeLayerGenerator.getMaxHeight(this, engine);
}
public int getMaxWithObjectHeight(IrisData data, Engine engine) {
return IrisBiomeLayerGenerator.getMaxWithObjectHeight(this, data, engine);
}
public KList<CNG> getLayerHeightGenerators(RNG rng, IrisData rdata) {
return IrisBiomeLayerGenerator.getLayerHeightGenerators(this, rng, rdata);
}
public KList<CNG> getLayerSeaHeightGenerators(RNG rng, IrisData data) {
return IrisBiomeLayerGenerator.getLayerSeaHeightGenerators(this, rng, data);
}
public PlatformBlockState getSurfaceBlock(int x, int z, RNG rng, IrisData idm) {
return IrisBiomeLayerGenerator.getSurfaceBlock(this, x, z, rng, idm);
}
public boolean isLand() {
if (inferredType == null) {
return true;
@@ -19,6 +19,7 @@
package art.arcane.iris.engine.object.world.biome;
import art.arcane.iris.engine.decorator.BiomeDecorators;
import art.arcane.iris.engine.terrain.BiomeLayers;
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.render.RenderType;
@@ -81,7 +82,10 @@ final class IrisBiomeColorRenderer {
});
}
case LAYER_LOAD -> {
return biome.getCacheColorLayerLoad().aquire(() -> Color.getHSBColor(0.625f, (float) (biome.getLayers().size() / engine.getMaxBiomeLayerDensity()), 1f));
return biome.getCacheColorLayerLoad().aquire(() -> {
BiomeLayers layers = BiomeLayers.of(engine);
return Color.getHSBColor(0.625f, (float) (BiomeLayers.layersOf(biome).size() / layers.busiestLayerCount(engine)), 1f);
});
}
}
@@ -27,7 +27,6 @@ import art.arcane.iris.engine.object.image.IrisImageMapApplication;
import art.arcane.iris.engine.object.image.IrisImageMapBinding;
import art.arcane.iris.engine.object.loot.IrisBlockDrops;
import art.arcane.iris.engine.object.loot.IrisLootReference;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
import art.arcane.iris.engine.object.noise.IrisShapedGeneratorStyle;
import art.arcane.iris.engine.object.noise.NoiseStyle;
@@ -178,12 +177,6 @@ public class IrisDimension extends IrisRegistrant {
private boolean decorate = true;
@Desc("When true, every ore block the generator would place (terrain ores, deposits, ores inside objects) is replaced with its base material such as stone, deepslate or netherrack, so drop-control plugins like HiddenOre can manage ore rewards themselves")
private boolean hideOresForHiddenOre = false;
@Desc("Use post processing or not")
private boolean postProcessing = true;
@Desc("Add slabs in post processing")
private boolean postProcessingSlabs = true;
@Desc("Add painted walls in post processing")
private boolean postProcessingWalls = true;
@Desc("Enable or disable all carving for this dimension")
private boolean carvingEnabled = true;
@ArrayType(type = IrisDimensionCarvingEntry.class, min = 1)
@@ -281,10 +274,6 @@ public class IrisDimension extends IrisRegistrant {
@ArrayType(min = 1, type = IrisShapedGeneratorStyle.class)
@Desc("Overlay additional noise on top of the interoplated terrain.")
private KList<IrisShapedGeneratorStyle> overlayNoise = new KList<>();
@Desc("The palette of blocks for 'stone'")
private IrisMaterialPalette rockPalette = new IrisMaterialPalette().qclear().qadd("stone");
@Desc("The dimension fluid block palette used for ocean columns and cave aquifers.")
private IrisMaterialPalette fluidPalette = new IrisMaterialPalette().qclear().qadd("water");
@Desc("Collection of ores to be generated")
@ArrayType(type = IrisOreGenerator.class, min = 1)
private KList<IrisOreGenerator> ores = new KList<>();
@@ -0,0 +1,344 @@
/*
* 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.engine.terrain;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.builtin.terrain.CaveCeilingLayersSettings;
import art.arcane.iris.builtin.terrain.LayersSettings;
import art.arcane.iris.builtin.terrain.LockLayersMaxSettings;
import art.arcane.iris.builtin.terrain.LockLayersSettings;
import art.arcane.iris.builtin.terrain.PaletteLayer;
import art.arcane.iris.builtin.terrain.SeaLayersSettings;
import art.arcane.iris.builtin.terrain.SlabSettings;
import art.arcane.iris.builtin.terrain.WallSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.modules.IrisValues;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.noise.NoiseStyle;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 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 class States {
private static final PlatformBlockState BARRIER = B.getState("BARRIER");
}
private final Map<PaletteLayer, ResolvedLayer> resolved = new ConcurrentHashMap<>();
private final Map<LayersSettings, AtomicCache<KList<CNG>>> surfaceHeights = new ConcurrentHashMap<>();
private final Map<SeaLayersSettings, AtomicCache<KList<CNG>>> seaHeights = new ConcurrentHashMap<>();
private volatile Double busiestBiomeLayerCount;
/** The layers of the world {@code engine} generates now. */
public static BiomeLayers of(Engine engine) {
return engine.getGeneration().state(BiomeLayers.class, ignored -> new BiomeLayers());
}
/** {@code layer} ready for the pack of {@code data}; the pack of the first caller is the one kept. */
public ResolvedLayer resolve(PaletteLayer layer, IrisData data) {
return resolved.computeIfAbsent(layer, declared -> ResolvedLayer.of(declared, data));
}
/** The biome's slab, which places no block when the biome declares none. */
public ResolvedLayer slab(IrisBiome biome, IrisData data) {
PaletteLayer layer = biome.getModuleSettings().find(SlabSettings.class).map(SlabSettings::layer).orElse(NO_LAYER);
return resolve(layer, data);
}
/** The biome's wall, which places no block when the biome declares none. */
public ResolvedLayer wall(IrisBiome biome, IrisData data) {
PaletteLayer layer = biome.getModuleSettings().find(WallSettings.class).map(WallSettings::layer).orElse(NO_LAYER);
return resolve(layer, data);
}
/** The layers of the biome's surface, top first. */
public static List<PaletteLayer> layersOf(IrisBiome biome) {
return surfaceSettings(biome).layers();
}
/** The noise style of each layer of the biome's surface, top first, as Iris's generators know them. */
public static List<NoiseStyle> layerStyles(IrisBiome biome) {
return layersOf(biome).stream().map(layer -> IrisValues.generatorStyle(layer.style()).getStyle()).toList();
}
/** The most layers any biome the dimension reaches has, which is what studio's layer load view compares a biome with. */
public double busiestLayerCount(Engine engine) {
Double cached = busiestBiomeLayerCount;
if (cached != null) {
return cached;
}
double busiest = 0D;
for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
busiest = Math.max(busiest, layersOf(biome).size());
}
busiestBiomeLayerCount = busiest;
return busiest;
}
/** The blocks the biome's layers stack up to at the column, top first, at most {@code maxDepth} of them. */
public KList<PlatformBlockState> generateLayers(IrisBiome biome, IrisDimension dimension, double wx, double wz, RNG random, int maxDepth, int height, IrisData data, IrisComplex complex) {
if (isLocked(biome)) {
return generateLockedLayers(biome, wx, wz, random, maxDepth, height, data, complex);
}
KList<PlatformBlockState> blocks = new KList<>();
if (maxDepth <= 0) {
return blocks;
}
LayersSettings settings = surfaceSettings(biome);
List<PaletteLayer> layers = settings.layers();
if (layers.isEmpty()) {
return blocks;
}
KList<CNG> heightNoises = surfaceHeightNoises(settings, random, data);
for (int i = 0; i < layers.size(); i++) {
ResolvedLayer layer = resolve(layers.get(i), data);
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, complex);
if (depth <= 0) {
continue;
}
stackLayer(blocks, layer, i, depth, wx, wz, random, maxDepth);
if (blocks.size() >= maxDepth) {
break;
}
separateLayers(blocks, dimension, 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<PlatformBlockState> generateCeilingLayers(IrisBiome biome, IrisDimension dimension, double wx, double wz, RNG random, int maxDepth, int height, IrisData data, IrisComplex complex) {
KList<PlatformBlockState> blocks = new KList<>();
if (maxDepth <= 0) {
return blocks;
}
List<PaletteLayer> ceilingLayers = biome.getModuleSettings().find(CaveCeilingLayersSettings.class)
.map(CaveCeilingLayersSettings::layers).orElse(List.of());
if (ceilingLayers.isEmpty()) {
return blocks;
}
KList<CNG> heightNoises = surfaceHeightNoises(surfaceSettings(biome), random, data);
// 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), data);
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, dimension, 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<PlatformBlockState> generateSeaLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepth, IrisData data) {
KList<PlatformBlockState> blocks = new KList<>();
SeaLayersSettings settings = biome.getModuleSettings().find(SeaLayersSettings.class).orElse(null);
if (settings == null || settings.layers().isEmpty()) {
return blocks;
}
List<PaletteLayer> layers = settings.layers();
KList<CNG> heightNoises = seaHeightNoises(settings, random, data);
for (int i = 0; i < layers.size(); i++) {
ResolvedLayer layer = resolve(layers.get(i), data);
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<PlatformBlockState> generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthLimit, int height, IrisData data, IrisComplex complex) {
KList<PlatformBlockState> stacked = new KList<>();
KList<PlatformBlockState> 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<CNG> heightNoises = surfaceHeightNoises(settings, random, data);
for (int i = 0; i < layers.size(); i++) {
ResolvedLayer layer = resolve(layers.get(i), data);
double depth = layerDepth(layer, heightNoises.get(i), wx, wz, complex);
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<PlatformBlockState> 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<PlatformBlockState> 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<PlatformBlockState> 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) {
IrisLogging.reportError(e);
}
}
/** The barrier blocks a dimension puts between layers to show them apart. */
private void separateLayers(KList<PlatformBlockState> blocks, IrisDimension dimension, int maxDepth) {
if (!dimension.isExplodeBiomePalettes()) {
return;
}
for (int j = 0; j < dimension.getExplodeBiomePaletteSize(); j++) {
blocks.add(States.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, CNG heightNoise, double wx, double wz, IrisComplex complex) {
double depth = layerThickness(layer, heightNoise, wx, wz);
SlopeClip slope = layer.slopeCondition();
if (!slope.isDefault() && !slope.isValid(complex.getSlopeStream().get(wx, wz))) {
return 0;
}
return depth;
}
private double layerThickness(ResolvedLayer layer, CNG heightNoise, double wx, double wz) {
double zoom = layer.zoom();
return heightNoise.fit(layer.minHeight(), layer.maxHeight(), wx / zoom, wz / zoom);
}
private KList<CNG> surfaceHeightNoises(LayersSettings settings, RNG rng, IrisData data) {
AtomicCache<KList<CNG>> cache = surfaceHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
return heightNoises(cache, settings.layers(), SURFACE_HEIGHT_SEED, rng, data);
}
private KList<CNG> seaHeightNoises(SeaLayersSettings settings, RNG rng, IrisData data) {
AtomicCache<KList<CNG>> cache = seaHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
return heightNoises(cache, settings.layers(), SEA_HEIGHT_SEED, rng, data);
}
private KList<CNG> heightNoises(AtomicCache<KList<CNG>> cache, List<PaletteLayer> layers, int firstSeed, RNG rng, IrisData data) {
KList<CNG> cached = cache.getIfPresent();
if (cached != null) {
return cached;
}
return cache.aquire(() -> {
KList<CNG> noises = new KList<>();
int seed = firstSeed;
for (PaletteLayer layer : layers) {
noises.add(resolve(layer, data).heightNoise(rng.nextParallelRNG((seed++) * seed * seed * seed)));
}
return noises;
});
}
private static LayersSettings surfaceSettings(IrisBiome biome) {
return biome.getModuleSettings().find(LayersSettings.class).orElse(DEFAULT_LAYERS);
}
private static boolean isLocked(IrisBiome biome) {
return biome.getModuleSettings().find(LockLayersSettings.class).map(LockLayersSettings::locked).orElse(false);
}
private static int lockedLayersMax(IrisBiome biome) {
return biome.getModuleSettings().find(LockLayersMaxSettings.class).map(LockLayersMaxSettings::layers).orElse(LockLayersMaxSettings.DEFAULT_LAYERS);
}
}
@@ -0,0 +1,48 @@
/*
* 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.engine.terrain;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockSpec;
import java.util.ArrayList;
import java.util.List;
/** A palette's blocks as the platform's, the way terrain layers and palettes always picked from them. */
final class PaletteBlocks {
private PaletteBlocks() {
}
/** The platform's block of each spec that has one, each repeated by its weight. */
static List<PlatformBlockState> weighted(BlockRegistry registry, List<BlockSpec> palette) {
List<PlatformBlockState> weighted = new ArrayList<>();
for (BlockSpec spec : palette) {
PlatformBlockState state = B.getState(registry.resolve(spec).key());
if (state == null) {
continue;
}
for (int n = 0; n < spec.weight(); n++) {
weighted.add(state);
}
}
return List.copyOf(weighted);
}
}
@@ -0,0 +1,139 @@
/*
* 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.engine.terrain;
import art.arcane.iris.builtin.prepare.SlopeClip;
import art.arcane.iris.builtin.terrain.PaletteLayer;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.modules.IrisPackResources;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.noise.NoiseFactory;
import com.volmit.noise.NoiseSampler;
import java.util.List;
/**
* One {@link PaletteLayer} made ready for one pack: its palette resolved to the platform's blocks, and the noise that
* decides how thick it is here and which block of the palette it picks, built when first asked for. What the layer
* describes stays in the settings; everything that needs the platform, the pack or a seed is here.
*
* <p>Both noises are built once, from the random of whoever asks first, as the layers of a biome always were: a layer's
* noise is a function of that random, the signature it was first asked with and the layer's own size.
*/
public final class ResolvedLayer {
private final PaletteLayer settings;
private final IrisPackResources resources;
private final AtomicCache<List<PlatformBlockState>> blocks = new AtomicCache<>();
private final AtomicCache<NoiseSampler> blockNoise = new AtomicCache<>();
private final AtomicCache<CNG> heightNoise = new AtomicCache<>();
private ResolvedLayer(PaletteLayer settings, IrisPackResources resources) {
this.settings = settings;
this.resources = resources;
}
/** {@code settings} ready for the blocks and noise of the pack of {@code data}. */
static ResolvedLayer of(PaletteLayer settings, IrisData data) {
return new ResolvedLayer(settings, data.getPackResources());
}
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 CNG heightNoise(RNG rng) {
CNG cached = heightNoise.getIfPresent();
if (cached != null) {
return cached;
}
return heightNoise.aquire(() -> CNG.signature(rng.nextParallelRNG(settings.minHeight() * settings.maxHeight() + blocks().size())));
}
/** The layer's block at the position, picked with the noise seeded from {@code parent} and {@code signature}, or null when the palette has no block. */
public PlatformBlockState get(RNG parent, int signature, double x, double y, double z) {
List<PlatformBlockState> palette = blocks();
if (palette.isEmpty()) {
return null;
}
if (palette.size() == 1) {
return palette.get(0);
}
double zoom = settings.zoom();
double noise = blockNoise(parent, signature, palette.size()).sample(x / zoom, y / zoom, z / zoom);
try {
return palette.get((int) Math.round(noise * (palette.size() - 1)));
} catch (IndexOutOfBoundsException outOfRange) {
IrisLogging.reportError(outOfRange);
return palette.get(0);
}
}
/** {@link #get(RNG, int, double, double, double)} for a layer asked once per column, such as a slab or a wall. */
public PlatformBlockState get(RNG rng, double x, double y, double z) {
return get(rng, 0, x, y, z);
}
private List<PlatformBlockState> blocks() {
List<PlatformBlockState> cached = blocks.getIfPresent();
if (cached != null) {
return cached;
}
return blocks.aquire(() -> PaletteBlocks.weighted(resources.blocks(), settings.palette()));
}
private NoiseSampler blockNoise(RNG parent, int signature, int paletteSize) {
NoiseSampler cached = blockNoise.getIfPresent();
if (cached != null) {
return cached;
}
NoiseFactory noise = resources.noise();
long seed = parent.nextParallelRNG(signature).nextParallelRNG(settings.minHeight() + settings.maxHeight() + paletteSize).getSeed();
return blockNoise.aquireOrThrow(() -> noise.sampler(settings.style(), seed));
}
}
@@ -0,0 +1,137 @@
/*
* 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.engine.terrain;
import art.arcane.iris.builtin.terrain.FluidPaletteSettings;
import art.arcane.iris.builtin.terrain.RockPaletteSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.modules.IrisPackResources;
import art.arcane.iris.engine.UpperDimensionContext;
import art.arcane.iris.engine.data.cache.AtomicCache;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.block.PaletteSpec;
import com.volmit.noise.NoiseSampler;
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. */
PlatformBlockState at(double x, double z);
}
private final Engine engine;
private final AtomicCache<ColumnBlocks> rock = new AtomicCache<>();
private final AtomicCache<ColumnBlocks> fluid = new AtomicCache<>();
private final Map<UpperDimensionContext, ColumnBlocks> upperRocks = new ConcurrentHashMap<>();
TerrainPalettes(Engine engine) {
this.engine = engine;
}
/** The palettes of the world {@code engine} generates now. */
public static TerrainPalettes of(Engine engine) {
return engine.getGeneration().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 PlatformBlockState rockAt(double x, double z) {
return rock().at(x, z);
}
/** The fluid at the column, above the terrain up to the fluid height. */
public PlatformBlockState 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 PlatformBlockState upperRockAt(UpperDimensionContext upper, double x, double z) {
return upperRocks.computeIfAbsent(upper, this::upperRock).at(x, z);
}
private ColumnBlocks rock() {
return rock.aquireOrThrow(() -> columns(rockPalette(engine.getDimension()), complexRng().nextParallelRNG(ROCK_SIGNATURE), engine.getData()));
}
private ColumnBlocks fluid() {
return fluid.aquireOrThrow(() -> columns(fluidPalette(engine.getDimension()), complexRng().nextParallelRNG(FLUID_SIGNATURE), engine.getData()));
}
private RNG complexRng() {
return new RNG(engine.getSeedManager().getComplex());
}
private ColumnBlocks upperRock(UpperDimensionContext upper) {
if (upper.isSelfReferencing()) {
return rock();
}
long seedOffset = upper.getDimension().getLoadKey().hashCode();
RNG rng = new RNG(engine.getSeedManager().getComplex() ^ seedOffset);
return columns(rockPalette(upper.getDimension()), rng.nextParallelRNG(ROCK_SIGNATURE), upper.getData());
}
private static PaletteSpec rockPalette(IrisDimension dimension) {
return dimension.getModuleSettings().find(RockPaletteSettings.class).orElseGet(RockPaletteSettings::new).palette();
}
private static PaletteSpec fluidPalette(IrisDimension dimension) {
return dimension.getModuleSettings().find(FluidPaletteSettings.class).orElseGet(FluidPaletteSettings::new).palette();
}
/** 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, IrisData data) {
IrisPackResources resources = data.getPackResources();
List<PlatformBlockState> 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));
}
}