diff --git a/README.md b/README.md
index db74d2c4d..180280cfe 100644
--- a/README.md
+++ b/README.md
@@ -63,13 +63,15 @@ The settings of both modules are `builtin.loot` and `builtin.spawn` types of Iri
`iris:spawn` declares `entitySpawners` (list of spawner keys) for the same and `effects` (list, `iris:spawn/effects`) for
regions and biomes. The loot tables, spawners, entities and markers are plain module types too (`LootTable`, `Spawner`,
`EntityDefinition`, `SpawnMarker`). `PlacementLoot` picks the table an object placement gives one of its chests.
-`iris:decorant` keeps its per-world `Decorating` in the world's state store (`context.world().state(...)`); the other
-built-ins still reach the same store through `IrisChunk.state(...)` / `engine.getGeneration().state(...)`.
+`iris:decorant`, `iris:terrain` and `iris:deposit` ship in the built-ins jar and keep their per-world workers (`BiomeDecorators`, `TerrainShaper`,
+`DepositPlacer`) in the world's state store (`context.world().state(...)`); the modules still compiled into Iris reach the same store through
+`IrisChunk.state(...)` / `engine.getGeneration().state(...)`.
Settings move off Iris's classes one feature at a time. `iris:deposit` is the first whose settings are IrisApi types
only: `DepositSettings` holds `DepositGenerator`s (blocks as `BlockSpec`, its enums beside it in
`art.arcane.iris.builtin.deposit`), and packs write `"deposits": [...]`, as they always have (`@Feature(key = "deposits", root = "generators")`: the key holds the one option's list). What needs Iris (resolving the
-palette, ore checks, clump shapes per world seed) lives in the module's own code, `ResolvedDeposit`.
+palette, ore checks, clump shapes per world seed) lives in the module's own code, `ResolvedDeposit`. The deposits run one generator after the other, each
+with a random of its own; they used to spread over threads on a multicore pregen, which no module can do (stages run on the host's threads).
Settings that live inside a class of Iris's own, such as an object placement's clamp, stilt, vacuum and edit settings, its slope condition
or a procedural coral, are module-owned classes too (`art.arcane.iris.builtin.validate`,
@@ -83,7 +85,9 @@ worker (`ResolvedReplace`, `ResolvedCaveProfile`, `ResolvedFloatingChild`, `Reso
`iris:decorant` is the second: `DecorantSettings` (biome level) holds `Decorator`s in `art.arcane.iris.builtin.decorant`,
written `"decorators": [...]` as always (`@Feature(key = "decorators", root = "decorators")`).
`ResolvedDecorator` resolves one decorator's blocks and noise for a world; `BiomeDecorators`, the world's state, keeps them
-per biome and place. Other modules that decorate (`iris:cave`'s ceilings, floating islands) ask it. A decorator's noise
+per biome and place. A chunk's decorators place into a `DecorationScene` (its blocks, the planned blocks around it, the terrain and the pack's block
+rules); other modules that decorate (the caves' floors and ceilings, floating islands) build one from their chunk's stage context. Whether a
+dimension decorates at all is its `decorate` key (`DecorateSettings`). A decorator's noise
seed is the world's decorator seed, its biome's key and its place in the biome's list. The module's `warmUp` builds
them ahead of generation; `iris:terrain` and `iris:objects` warm their ore generators, placements and procedural
objects the same way.
@@ -91,10 +95,13 @@ 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
+`postProcessing`, `postProcessingSlabs`, `postProcessingWalls` (booleans) in `art.arcane.iris.builtin.post`; `bedrock`, `explodeBiomePalettes` and
+`explodeBiomePaletteSize` are dimension keys of `iris:terrain` too. 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
+rock and fluid as a block for every column; the terrain, cave, floating and post stages ask them. Both live in `art.arcane.iris.builtin.terrain`, which
+Iris exposes, so the jar's terrain and the carving compiled into Iris share one copy of them: a biome's layer thickness noise is built once, from the random
+of whoever asks first, as it always was. The slope limit of a layer, a decorator and an
object placement is the one `SlopeClip`.
Caves, floating islands and ores are settings of their modules too, written under the keys they always had. `iris:carve` owns
diff --git a/builtin-modules.txt b/builtin-modules.txt
index c0cb6ccdd..f1fa10c09 100644
--- a/builtin-modules.txt
+++ b/builtin-modules.txt
@@ -60,3 +60,13 @@ include art/arcane/iris/engine/object/terrain/carving/CaveProfileSampler*.class
include art/arcane/iris/engine/object/terrain/carving/DeclaredByLevel.class
include art/arcane/iris/engine/object/terrain/carving/DeclaredCaveProfiles.class
include art/arcane/iris/engine/object/terrain/carving/ResolvedCarvingEntry.class
+module art.arcane.iris.engine.modifier.DepositModule
+include art/arcane/iris/engine/modifier/DepositPlacer*.class
+include art/arcane/iris/engine/modifier/DepositClump*.class
+include art/arcane/iris/engine/modifier/ResolvedDeposit*.class
+module art.arcane.iris.engine.actuator.DecorantModule
+include art/arcane/iris/engine/decorator/**
+module art.arcane.iris.engine.actuator.TerrainModule
+include art/arcane/iris/engine/actuator/Terrain*.class
+include art/arcane/iris/engine/actuator/ResolvedOre*.class
+include art/arcane/iris/engine/actuator/OreWarmUp*.class
diff --git a/source-patterns.txt b/source-patterns.txt
index 78bd0fcb1..2d5787b2a 100644
--- a/source-patterns.txt
+++ b/source-patterns.txt
@@ -1,6 +1,5 @@
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/**
diff --git a/src/main/java/art/arcane/iris/builtin/IrisSeed.java b/src/main/java/art/arcane/iris/builtin/IrisSeed.java
index 9e589b67e..9f141f2d8 100644
--- a/src/main/java/art/arcane/iris/builtin/IrisSeed.java
+++ b/src/main/java/art/arcane/iris/builtin/IrisSeed.java
@@ -27,7 +27,7 @@ import com.volmit.world.PackWorld;
* from {@link PackWorld#seed()}.
*/
public enum IrisSeed {
- BIOME, CARVE, COMPONENT, DECORATOR, DEPOSIT, ENTITY, LOOT, MANTLE, POST, TERRAIN;
+ BIOME, CARVE, COMPLEX, COMPONENT, DECORATOR, DEPOSIT, ENTITY, LOOT, MANTLE, POST, TERRAIN;
/** This seed of {@code world}, which must be a world Iris generates. */
public long of(PackWorld world) {
diff --git a/src/main/java/art/arcane/iris/builtin/decorant/DecorateSettings.java b/src/main/java/art/arcane/iris/builtin/decorant/DecorateSettings.java
new file mode 100644
index 000000000..bdcaf244c
--- /dev/null
+++ b/src/main/java/art/arcane/iris/builtin/decorant/DecorateSettings.java
@@ -0,0 +1,38 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.builtin.decorant;
+
+import com.volmit.FeatureAttachment.Target;
+import com.volmit.IrisFeature;
+import com.volmit.config.Desc;
+import com.volmit.config.Feature;
+
+/** Whether a dimension decorates at all, written as {@code "decorate": false}. A dimension without the key decorates. */
+@Desc("Generate decorations or not")
+@Feature(id = "iris:decorant/decorate", name = "Decorate", key = "decorate", root = "decorate", targets = Target.DIMENSION)
+public final class DecorateSettings implements IrisFeature {
+ @Desc("Generate decorations or not")
+ private boolean decorate = true;
+
+ public DecorateSettings() {
+ }
+
+ public boolean decorate() {
+ return decorate;
+ }
+}
diff --git a/src/main/java/art/arcane/iris/builtin/decorant/DecoratorLoad.java b/src/main/java/art/arcane/iris/builtin/decorant/DecoratorLoad.java
new file mode 100644
index 000000000..a73ef0c18
--- /dev/null
+++ b/src/main/java/art/arcane/iris/builtin/decorant/DecoratorLoad.java
@@ -0,0 +1,52 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.builtin.decorant;
+
+/** How loaded with decorating a biome is, which studio's decorator load view colours it by. */
+public final class DecoratorLoad {
+ private static final int COLUMNS_PER_CHUNK = 256;
+
+ private DecoratorLoad() {
+ }
+
+ /** The sum of the decorators' chances times their stack heights, at least one block each; 0 for a biome without decorators. */
+ public static double of(DecorantSettings settings) {
+ if (settings == null) {
+ return 0D;
+ }
+
+ double load = 0D;
+ for (Decorator decorator : settings.decorators()) {
+ load += Math.max(decorator.stackMax(), 1) * decorator.chance();
+ }
+ return load;
+ }
+
+ /** The sum of the decorators' chances over a chunk's columns, which is how strongly the view colours the biome. */
+ public static double colour(DecorantSettings settings) {
+ if (settings == null) {
+ return 0D;
+ }
+
+ double load = 0D;
+ for (Decorator decorator : settings.decorators()) {
+ load += decorator.chance() * Math.min(1, decorator.stackMax()) * COLUMNS_PER_CHUNK;
+ }
+ return load;
+ }
+}
diff --git a/src/main/java/art/arcane/iris/builtin/package-info.java b/src/main/java/art/arcane/iris/builtin/package-info.java
index a4e5d1d06..0e7881d56 100644
--- a/src/main/java/art/arcane/iris/builtin/package-info.java
+++ b/src/main/java/art/arcane/iris/builtin/package-info.java
@@ -30,7 +30,8 @@
* Besides those, it holds what the compiled-in built-ins and the built-ins jar must share, since each sees its own copy
* of every other class: narrow facades only Iris's own built-ins use, interfaces Iris's worlds implement
* ({@link art.arcane.iris.builtin.IrisSeed}, {@link art.arcane.iris.builtin.LiveWorld}), and per-world state several of them use
- * ({@link art.arcane.iris.builtin.terrain.LayerBlocks}). Keep them few: each is a promise.
+ * ({@link art.arcane.iris.builtin.terrain.LayerBlocks}, {@link art.arcane.iris.builtin.terrain.BiomeLayers},
+ * {@link art.arcane.iris.builtin.terrain.TerrainPalettes}). Keep them few: each is a promise.
*
* The placement stages ({@code iris:prepare} to {@code iris:snow}) reach the object being placed through
* {@link art.arcane.iris.builtin.placement.ObjectPlacement}, a facade Iris implements for each placement. Its types
diff --git a/src/main/java/art/arcane/iris/builtin/terrain/BedrockSettings.java b/src/main/java/art/arcane/iris/builtin/terrain/BedrockSettings.java
new file mode 100644
index 000000000..b92e2190d
--- /dev/null
+++ b/src/main/java/art/arcane/iris/builtin/terrain/BedrockSettings.java
@@ -0,0 +1,38 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.builtin.terrain;
+
+import com.volmit.FeatureAttachment.Target;
+import com.volmit.IrisFeature;
+import com.volmit.config.Desc;
+import com.volmit.config.Feature;
+
+/** Whether a dimension has a layer of bedrock at its bottom, written as {@code "bedrock": false}. A dimension without the key has it. */
+@Desc("Should bedrock be generated or not.")
+@Feature(id = "iris:terrain/bedrock", name = "Bedrock", key = "bedrock", root = "bedrock", targets = Target.DIMENSION)
+public final class BedrockSettings implements IrisFeature {
+ @Desc("Should bedrock be generated or not.")
+ private boolean bedrock = true;
+
+ public BedrockSettings() {
+ }
+
+ public boolean bedrock() {
+ return bedrock;
+ }
+}
diff --git a/src/main/java/art/arcane/iris/engine/terrain/BiomeLayers.java b/src/main/java/art/arcane/iris/builtin/terrain/BiomeLayers.java
similarity index 53%
rename from src/main/java/art/arcane/iris/engine/terrain/BiomeLayers.java
rename to src/main/java/art/arcane/iris/builtin/terrain/BiomeLayers.java
index 310c8d546..ed0105594 100644
--- a/src/main/java/art/arcane/iris/engine/terrain/BiomeLayers.java
+++ b/src/main/java/art/arcane/iris/builtin/terrain/BiomeLayers.java
@@ -15,33 +15,19 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
-package art.arcane.iris.engine.terrain;
+package art.arcane.iris.builtin.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.LayerBlocks;
-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.WallSettings;
-import art.arcane.iris.core.loader.IrisData;
-import art.arcane.iris.core.modules.IrisValues;
-import art.arcane.iris.engine.IrisComplex;
import art.arcane.volmlib.util.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.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 com.volmit.ModuleLog;
+import com.volmit.block.BlockState;
+import com.volmit.config.FeatureSettings;
+import com.volmit.noise.NoiseFactory;
+import com.volmit.resource.ResourceId;
+import com.volmit.world.PackWorld;
+
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -61,73 +47,62 @@ public final class BiomeLayers {
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 static final BlockState BARRIER = new BlockState("minecraft:barrier");
private final Supplier layerBlocks;
+ private final Supplier noise;
private final ModuleLog log;
private final Map resolved = new ConcurrentHashMap<>();
- private final Map>> surfaceHeights = new ConcurrentHashMap<>();
- private final Map>> seaHeights = new ConcurrentHashMap<>();
- private volatile Double busiestBiomeLayerCount;
+ private final Map>> surfaceHeights = new ConcurrentHashMap<>();
+ private final Map>> seaHeights = new ConcurrentHashMap<>();
+ private final Map biomes = new ConcurrentHashMap<>();
- /** The layers of the world {@code engine} generates now, reporting failures to {@code log}. */
- public static BiomeLayers of(Engine engine, ModuleLog log) {
- return engine.getGeneration().state(BiomeLayers.class,
- generating -> new BiomeLayers(() -> LayerBlocks.of(generating.getGeneration().world()), log));
+ /** The layers of {@code world}. */
+ public static BiomeLayers of(PackWorld world) {
+ return world.state(BiomeLayers.class, generating -> new BiomeLayers(() -> LayerBlocks.of(generating), () -> generating.resources().noise(), generating.log()));
}
- /** The layers of a world whose layer blocks {@code layerBlocks} gives, asked for when a layer first picks a block. */
- public BiomeLayers(Supplier layerBlocks, ModuleLog log) {
+ /** The layers of a world whose layer blocks {@code layerBlocks} and noise {@code noise} give, asked for when a layer first needs them. */
+ public BiomeLayers(Supplier layerBlocks, Supplier noise, ModuleLog log) {
this.layerBlocks = layerBlocks;
+ this.noise = noise;
this.log = log;
}
/** {@code layer} ready for this world; its block picks are the world's {@link LayerBlocks}. */
public ResolvedLayer resolve(PaletteLayer layer) {
- return resolved.computeIfAbsent(layer, declared -> ResolvedLayer.of(declared, layerBlocks));
+ return resolved.computeIfAbsent(layer, declared -> ResolvedLayer.of(declared, layerBlocks, noise));
+ }
+
+ /** What the biome {@code id} declares about its layers, read once from {@code settings}. */
+ public LayeredBiome biome(ResourceId id, FeatureSettings settings) {
+ LayeredBiome known = biomes.get(id);
+ if (known != null) {
+ return known;
+ }
+ return biomes.computeIfAbsent(id, ignored -> new LayeredBiome(
+ settings.declaredBy(id, LayersSettings.class).orElse(null),
+ settings.declaredBy(id, SeaLayersSettings.class).orElse(null),
+ settings.declaredBy(id, CaveCeilingLayersSettings.class).orElse(null),
+ settings.declaredBy(id, LockLayersSettings.class).orElse(null),
+ settings.declaredBy(id, LockLayersMaxSettings.class).orElse(null),
+ settings.declaredBy(id, WallSettings.class).orElse(null)));
}
/** The biome's wall, which places no block when the biome declares none. */
- public ResolvedLayer wall(IrisBiome biome) {
- PaletteLayer layer = biome.getModuleSettings().find(WallSettings.class).map(WallSettings::layer).orElse(NO_LAYER);
+ public ResolvedLayer wall(LayeredBiome biome) {
+ PaletteLayer layer = biome.wall() == null ? NO_LAYER : biome.wall().layer();
return resolve(layer);
}
- /** The layers of the biome's surface, top first. */
- public static List 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 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 generateLayers(IrisBiome biome, IrisDimension dimension, double wx, double wz, RNG random, int maxDepth, int height, IrisData data, IrisComplex complex) {
+ public KList generateLayers(LayeredBiome biome, PaletteExplosion explosion, double wx, double wz, RNG random, int maxDepth, int height,
+ ColumnSlope slope) {
if (isLocked(biome)) {
- return generateLockedLayers(biome, wx, wz, random, maxDepth, height, complex);
+ return generateLockedLayers(biome, wx, wz, random, maxDepth, height, slope);
}
- KList blocks = new KList<>();
+ KList blocks = new KList<>();
if (maxDepth <= 0) {
return blocks;
}
@@ -138,10 +113,10 @@ public final class BiomeLayers {
return blocks;
}
- KList heightNoises = surfaceHeightNoises(settings, random);
+ KList heightNoises = surfaceHeightNoises(settings, random);
for (int i = 0; i < layers.size(); i++) {
ResolvedLayer layer = resolve(layers.get(i));
- double depth = layerDepth(layer, heightNoises.get(i), wx, wz, complex);
+ double depth = layerDepth(layer, heightNoises.get(i), wx, wz, slope);
if (depth <= 0) {
continue;
}
@@ -151,26 +126,25 @@ public final class BiomeLayers {
break;
}
- separateLayers(blocks, dimension, maxDepth);
+ separateLayers(blocks, explosion, maxDepth);
}
return blocks;
}
/** The blocks the biome's cave ceiling layers stack up to at the column, nearest the ceiling first, at most {@code maxDepth} of them. */
- public KList generateCeilingLayers(IrisBiome biome, IrisDimension dimension, double wx, double wz, RNG random, int maxDepth, int height, IrisData data, IrisComplex complex) {
- KList blocks = new KList<>();
+ public KList generateCeilingLayers(LayeredBiome biome, PaletteExplosion explosion, double wx, double wz, RNG random, int maxDepth) {
+ KList blocks = new KList<>();
if (maxDepth <= 0) {
return blocks;
}
- List ceilingLayers = biome.getModuleSettings().find(CaveCeilingLayersSettings.class)
- .map(CaveCeilingLayersSettings::layers).orElse(List.of());
+ List ceilingLayers = biome.ceilingLayers() == null ? List.of() : biome.ceilingLayers().layers();
if (ceilingLayers.isEmpty()) {
return blocks;
}
- KList heightNoises = surfaceHeightNoises(surfaceSettings(biome), random);
+ KList heightNoises = surfaceHeightNoises(surfaceSettings(biome), random);
// Ceiling layers reuse the surface-layer height noise, so entries beyond the surface layers have none; skip them.
int usableLayers = Math.min(ceilingLayers.size(), heightNoises.size());
for (int i = 0; i < usableLayers; i++) {
@@ -185,22 +159,22 @@ public final class BiomeLayers {
break;
}
- separateLayers(blocks, dimension, maxDepth);
+ separateLayers(blocks, explosion, maxDepth);
}
return blocks;
}
/** The blocks of the biome's sea layers at the column, from the water surface down, at most {@code maxDepth} of them. */
- public KList generateSeaLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepth, IrisData data) {
- KList blocks = new KList<>();
- SeaLayersSettings settings = biome.getModuleSettings().find(SeaLayersSettings.class).orElse(null);
+ public KList generateSeaLayers(LayeredBiome biome, double wx, double wz, RNG random, int maxDepth) {
+ KList blocks = new KList<>();
+ SeaLayersSettings settings = biome.seaLayers();
if (settings == null || settings.layers().isEmpty()) {
return blocks;
}
List layers = settings.layers();
- KList heightNoises = seaHeightNoises(settings, random);
+ KList heightNoises = seaHeightNoises(settings, random);
for (int i = 0; i < layers.size(); i++) {
ResolvedLayer layer = resolve(layers.get(i));
int depth = heightNoises.get(i).fit(layer.minHeight(), layer.maxHeight(), wx / layer.zoom(), wz / layer.zoom());
@@ -217,9 +191,9 @@ public final class BiomeLayers {
return blocks;
}
- private KList generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthLimit, int height, IrisComplex complex) {
- KList stacked = new KList<>();
- KList locked = new KList<>();
+ private KList generateLockedLayers(LayeredBiome biome, double wx, double wz, RNG random, int maxDepthLimit, int height, ColumnSlope slope) {
+ KList stacked = new KList<>();
+ KList locked = new KList<>();
int maxDepth = Math.min(maxDepthLimit, lockedLayersMax(biome));
if (maxDepth <= 0) {
return stacked;
@@ -228,10 +202,10 @@ public final class BiomeLayers {
LayersSettings settings = surfaceSettings(biome);
List layers = settings.layers();
if (!layers.isEmpty()) {
- KList heightNoises = surfaceHeightNoises(settings, random);
+ KList heightNoises = surfaceHeightNoises(settings, random);
for (int i = 0; i < layers.size(); i++) {
ResolvedLayer layer = resolve(layers.get(i));
- double depth = layerDepth(layer, heightNoises.get(i), wx, wz, complex);
+ double depth = layerDepth(layer, heightNoises.get(i), wx, wz, slope);
if (depth <= 0) {
continue;
}
@@ -252,7 +226,7 @@ public final class BiomeLayers {
return locked;
}
- private void stackLayer(KList blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random, int maxDepth) {
+ private void stackLayer(KList 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;
@@ -262,14 +236,14 @@ public final class BiomeLayers {
}
}
- private void stackLayerUnlimited(KList blocks, ResolvedLayer layer, int index, double depth, double wx, double wz, RNG random) {
+ private void stackLayerUnlimited(KList 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 blocks, ResolvedLayer layer, int index, int j, double wx, double wz, RNG random) {
+ private void addBlock(KList 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));
@@ -279,13 +253,13 @@ public final class BiomeLayers {
}
/** The barrier blocks a dimension puts between layers to show them apart. */
- private void separateLayers(KList blocks, IrisDimension dimension, int maxDepth) {
- if (!dimension.isExplodeBiomePalettes()) {
+ private void separateLayers(KList blocks, PaletteExplosion explosion, int maxDepth) {
+ if (!explosion.exploded()) {
return;
}
- for (int j = 0; j < dimension.getExplodeBiomePaletteSize(); j++) {
- blocks.add(States.BARRIER);
+ for (int j = 0; j < explosion.size(); j++) {
+ blocks.add(BARRIER);
if (blocks.size() >= maxDepth) {
break;
}
@@ -293,39 +267,39 @@ public final class BiomeLayers {
}
/** 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) {
+ private double layerDepth(ResolvedLayer layer, LayerNoise heightNoise, double wx, double wz, ColumnSlope slope) {
double depth = layerThickness(layer, heightNoise, wx, wz);
- SlopeClip slope = layer.slopeCondition();
- if (!slope.isDefault() && !slope.isValid(complex.getSlopeStream().get(wx, wz))) {
+ SlopeClip clip = layer.slopeCondition();
+ if (!clip.isDefault() && !clip.isValid(slope.at(wx, wz))) {
return 0;
}
return depth;
}
- private double layerThickness(ResolvedLayer layer, CNG heightNoise, double wx, double wz) {
+ private double layerThickness(ResolvedLayer layer, LayerNoise heightNoise, double wx, double wz) {
double zoom = layer.zoom();
return heightNoise.fit(layer.minHeight(), layer.maxHeight(), wx / zoom, wz / zoom);
}
- private KList surfaceHeightNoises(LayersSettings settings, RNG rng) {
- AtomicCache> cache = surfaceHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
+ private KList surfaceHeightNoises(LayersSettings settings, RNG rng) {
+ AtomicCache> cache = surfaceHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
return heightNoises(cache, settings.layers(), SURFACE_HEIGHT_SEED, rng);
}
- private KList seaHeightNoises(SeaLayersSettings settings, RNG rng) {
- AtomicCache> cache = seaHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
+ private KList seaHeightNoises(SeaLayersSettings settings, RNG rng) {
+ AtomicCache> cache = seaHeights.computeIfAbsent(settings, declared -> new AtomicCache<>());
return heightNoises(cache, settings.layers(), SEA_HEIGHT_SEED, rng);
}
- private KList heightNoises(AtomicCache> cache, List layers, int firstSeed, RNG rng) {
- KList cached = cache.getIfPresent();
+ private KList heightNoises(AtomicCache> cache, List layers, int firstSeed, RNG rng) {
+ KList cached = cache.getIfPresent();
if (cached != null) {
return cached;
}
return cache.aquire(() -> {
- KList noises = new KList<>();
+ KList noises = new KList<>();
int seed = firstSeed;
for (PaletteLayer layer : layers) {
noises.add(resolve(layer).heightNoise(rng.nextParallelRNG((seed++) * seed * seed * seed)));
@@ -334,15 +308,15 @@ public final class BiomeLayers {
});
}
- private static LayersSettings surfaceSettings(IrisBiome biome) {
- return biome.getModuleSettings().find(LayersSettings.class).orElse(DEFAULT_LAYERS);
+ private static LayersSettings surfaceSettings(LayeredBiome biome) {
+ return biome.layers() == null ? DEFAULT_LAYERS : biome.layers();
}
- private static boolean isLocked(IrisBiome biome) {
- return biome.getModuleSettings().find(LockLayersSettings.class).map(LockLayersSettings::locked).orElse(false);
+ private static boolean isLocked(LayeredBiome biome) {
+ return biome.lock() != null && biome.lock().locked();
}
- private static int lockedLayersMax(IrisBiome biome) {
- return biome.getModuleSettings().find(LockLayersMaxSettings.class).map(LockLayersMaxSettings::layers).orElse(LockLayersMaxSettings.DEFAULT_LAYERS);
+ private static int lockedLayersMax(LayeredBiome biome) {
+ return biome.lockMax() == null ? LockLayersMaxSettings.DEFAULT_LAYERS : biome.lockMax().layers();
}
}
diff --git a/src/main/java/art/arcane/iris/builtin/terrain/ColumnSlope.java b/src/main/java/art/arcane/iris/builtin/terrain/ColumnSlope.java
new file mode 100644
index 000000000..9a0da0a4b
--- /dev/null
+++ b/src/main/java/art/arcane/iris/builtin/terrain/ColumnSlope.java
@@ -0,0 +1,24 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.builtin.terrain;
+
+/** The slope of the terrain at a column, asked only when a layer limits where it shows by slope. */
+@FunctionalInterface
+public interface ColumnSlope {
+ double at(double worldX, double worldZ);
+}
diff --git a/src/main/java/art/arcane/iris/builtin/terrain/ExplodeBiomePaletteSizeSettings.java b/src/main/java/art/arcane/iris/builtin/terrain/ExplodeBiomePaletteSizeSettings.java
new file mode 100644
index 000000000..85a1b81d2
--- /dev/null
+++ b/src/main/java/art/arcane/iris/builtin/terrain/ExplodeBiomePaletteSizeSettings.java
@@ -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 .
+ */
+package art.arcane.iris.builtin.terrain;
+
+import com.volmit.FeatureAttachment.Target;
+import com.volmit.IrisFeature;
+import com.volmit.config.Desc;
+import com.volmit.config.Feature;
+import com.volmit.config.MaxNumber;
+import com.volmit.config.MinNumber;
+
+/** How many barrier blocks a dimension puts between layers when it explodes its biome palettes, written as {@code "explodeBiomePaletteSize": 3}. */
+@Desc("Customize the palette height explosion")
+@Feature(id = "iris:terrain/explode-palette-size", name = "Explode biome palette size", key = "explodeBiomePaletteSize", root = "size", targets = Target.DIMENSION)
+public final class ExplodeBiomePaletteSizeSettings implements IrisFeature {
+ public static final int DEFAULT_SIZE = 3;
+
+ @MinNumber(1)
+ @MaxNumber(16)
+ @Desc("Customize the palette height explosion")
+ private int size = DEFAULT_SIZE;
+
+ public ExplodeBiomePaletteSizeSettings() {
+ }
+
+ public int size() {
+ return size;
+ }
+}
diff --git a/src/main/java/art/arcane/iris/builtin/terrain/ExplodeBiomePalettesSettings.java b/src/main/java/art/arcane/iris/builtin/terrain/ExplodeBiomePalettesSettings.java
new file mode 100644
index 000000000..7a47733aa
--- /dev/null
+++ b/src/main/java/art/arcane/iris/builtin/terrain/ExplodeBiomePalettesSettings.java
@@ -0,0 +1,38 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.builtin.terrain;
+
+import com.volmit.FeatureAttachment.Target;
+import com.volmit.IrisFeature;
+import com.volmit.config.Desc;
+import com.volmit.config.Feature;
+
+/** Whether a dimension puts barrier blocks between the layers of its biomes to show them apart, written as {@code "explodeBiomePalettes": true}. */
+@Desc("Vertically split up the biome palettes with barrier blocks in between to visualize them. The gap size comes from explodeBiomePaletteSize.")
+@Feature(id = "iris:terrain/explode-palettes", name = "Explode biome palettes", key = "explodeBiomePalettes", root = "explode", targets = Target.DIMENSION)
+public final class ExplodeBiomePalettesSettings implements IrisFeature {
+ @Desc("Vertically split up the biome palettes with barrier blocks in between to visualize them. The gap size comes from explodeBiomePaletteSize.")
+ private boolean explode = false;
+
+ public ExplodeBiomePalettesSettings() {
+ }
+
+ public boolean explode() {
+ return explode;
+ }
+}
diff --git a/src/main/java/art/arcane/iris/engine/actuator/HiddenOres.java b/src/main/java/art/arcane/iris/builtin/terrain/LayerLoad.java
similarity index 58%
rename from src/main/java/art/arcane/iris/engine/actuator/HiddenOres.java
rename to src/main/java/art/arcane/iris/builtin/terrain/LayerLoad.java
index 48b5a3535..8cf6d635a 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/HiddenOres.java
+++ b/src/main/java/art/arcane/iris/builtin/terrain/LayerLoad.java
@@ -15,18 +15,19 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+package art.arcane.iris.builtin.terrain;
-package art.arcane.iris.engine.actuator;
+import java.util.List;
-import art.arcane.iris.builtin.terrain.HideOresSettings;
-import art.arcane.iris.engine.object.world.dimension.IrisDimension;
+/** The layers of a biome's surface, which studio's layer view counts. */
+public final class LayerLoad {
+ private static final LayersSettings DEFAULT_LAYERS = new LayersSettings();
-/** Whether a dimension hides its ores ({@code hideOresForHiddenOre}): the terrain places none and the perfection pass turns the rest into their base blocks. */
-public final class HiddenOres {
- private HiddenOres() {
+ private LayerLoad() {
}
- public static boolean in(IrisDimension dimension) {
- return dimension.getModuleSettings().find(HideOresSettings.class).map(HideOresSettings::hide).orElse(false);
+ /** The layers of the biome's surface, top first; a biome that declares no layers has the one layer of grass the settings default to. */
+ public static List layersOf(LayersSettings declared) {
+ return (declared == null ? DEFAULT_LAYERS : declared).layers();
}
}
diff --git a/src/main/java/art/arcane/iris/builtin/terrain/LayerNoise.java b/src/main/java/art/arcane/iris/builtin/terrain/LayerNoise.java
new file mode 100644
index 000000000..c99dad96d
--- /dev/null
+++ b/src/main/java/art/arcane/iris/builtin/terrain/LayerNoise.java
@@ -0,0 +1,37 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.builtin.terrain;
+
+import com.volmit.noise.NoiseSampler;
+
+/** The noise that sets how thick a layer is: a number between a layer's limits at every column. */
+public final class LayerNoise {
+ private final NoiseSampler noise;
+
+ LayerNoise(NoiseSampler noise) {
+ this.noise = noise;
+ }
+
+ /** The whole number between {@code min} and {@code max} the noise gives at the column. */
+ public int fit(int min, int max, double x, double z) {
+ if (min == max) {
+ return min;
+ }
+ return (int) Math.round(min + noise.sample(x, z) * (max - min));
+ }
+}
diff --git a/src/main/java/art/arcane/iris/builtin/terrain/LayeredBiome.java b/src/main/java/art/arcane/iris/builtin/terrain/LayeredBiome.java
new file mode 100644
index 000000000..4cde1683d
--- /dev/null
+++ b/src/main/java/art/arcane/iris/builtin/terrain/LayeredBiome.java
@@ -0,0 +1,29 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.builtin.terrain;
+
+
+/**
+ * What a biome declares about the layers of its ground: the layers of its surface, of its sea floor and of its cave ceilings, whether
+ * they are locked to the highest height the biome reaches, and its wall. A setting the biome does not declare is null.
+ */
+public record LayeredBiome(LayersSettings layers, SeaLayersSettings seaLayers, CaveCeilingLayersSettings ceilingLayers,
+ LockLayersSettings lock, LockLayersMaxSettings lockMax, WallSettings wall) {
+ /** A biome that declares nothing about its layers: the one layer of grass the settings default to. */
+ public static final LayeredBiome UNDECLARED = new LayeredBiome(null, null, null, null, null, null);
+}
diff --git a/src/main/java/art/arcane/iris/engine/terrain/PaletteBlocks.java b/src/main/java/art/arcane/iris/builtin/terrain/PaletteBlocks.java
similarity index 64%
rename from src/main/java/art/arcane/iris/engine/terrain/PaletteBlocks.java
rename to src/main/java/art/arcane/iris/builtin/terrain/PaletteBlocks.java
index 3cedf3006..cf69aef45 100644
--- a/src/main/java/art/arcane/iris/engine/terrain/PaletteBlocks.java
+++ b/src/main/java/art/arcane/iris/builtin/terrain/PaletteBlocks.java
@@ -15,30 +15,25 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+package art.arcane.iris.builtin.terrain;
-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 com.volmit.block.BlockState;
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. */
+/** A palette's blocks, 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 weighted(BlockRegistry registry, List palette) {
- List weighted = new ArrayList<>();
+ /** The block of each spec, each repeated by its weight. */
+ static List weighted(BlockRegistry registry, List palette) {
+ List weighted = new ArrayList<>();
for (BlockSpec spec : palette) {
- PlatformBlockState state = B.getState(registry.resolve(spec).key());
- if (state == null) {
- continue;
- }
+ BlockState state = registry.resolve(spec);
for (int n = 0; n < spec.weight(); n++) {
weighted.add(state);
}
diff --git a/src/main/java/art/arcane/iris/builtin/terrain/PaletteExplosion.java b/src/main/java/art/arcane/iris/builtin/terrain/PaletteExplosion.java
new file mode 100644
index 000000000..0e0201678
--- /dev/null
+++ b/src/main/java/art/arcane/iris/builtin/terrain/PaletteExplosion.java
@@ -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 .
+ */
+package art.arcane.iris.builtin.terrain;
+
+import com.volmit.config.FeatureSettings;
+import com.volmit.config.FeatureSettings.Entry;
+
+import java.util.List;
+
+/** Whether a dimension separates the layers of its biomes with barrier blocks to show them apart, and how many barriers it puts between them. */
+public record PaletteExplosion(boolean exploded, int size) {
+ public static final PaletteExplosion NONE = new PaletteExplosion(false, ExplodeBiomePaletteSizeSettings.DEFAULT_SIZE);
+
+ /** What the dimension at the column of {@code settings} declares. */
+ public static PaletteExplosion of(FeatureSettings settings, int worldX, int worldZ) {
+ boolean exploded = dimensionValue(settings.at(ExplodeBiomePalettesSettings.class, worldX, worldZ), ExplodeBiomePalettesSettings::explode, false);
+ int size = dimensionValue(settings.at(ExplodeBiomePaletteSizeSettings.class, worldX, worldZ), ExplodeBiomePaletteSizeSettings::size,
+ ExplodeBiomePaletteSizeSettings.DEFAULT_SIZE);
+ return new PaletteExplosion(exploded, size);
+ }
+
+ private static V dimensionValue(List> entries, java.util.function.Function read, V fallback) {
+ return entries.stream().filter(entry -> entry.level() == com.volmit.FeatureAttachment.Target.DIMENSION).findFirst()
+ .map(entry -> read.apply(entry.value())).orElse(fallback);
+ }
+}
diff --git a/src/main/java/art/arcane/iris/engine/terrain/ResolvedLayer.java b/src/main/java/art/arcane/iris/builtin/terrain/ResolvedLayer.java
similarity index 66%
rename from src/main/java/art/arcane/iris/engine/terrain/ResolvedLayer.java
rename to src/main/java/art/arcane/iris/builtin/terrain/ResolvedLayer.java
index d2d44d4b3..413669206 100644
--- a/src/main/java/art/arcane/iris/engine/terrain/ResolvedLayer.java
+++ b/src/main/java/art/arcane/iris/builtin/terrain/ResolvedLayer.java
@@ -15,42 +15,43 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
-package art.arcane.iris.engine.terrain;
+package art.arcane.iris.builtin.terrain;
import art.arcane.iris.builtin.prepare.SlopeClip;
-import art.arcane.iris.builtin.terrain.LayerBlocks;
-import art.arcane.iris.builtin.terrain.PaletteLayer;
import art.arcane.volmlib.util.cache.AtomicCache;
-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.math.RNG;
+import com.volmit.block.BlockState;
+import com.volmit.noise.NoiseFactory;
+import com.volmit.noise.NoiseStyle;
import java.util.List;
import java.util.function.Supplier;
/**
- * One {@link PaletteLayer} made ready for one world: its blocks as the platform's, and the noise that decides how thick
- * it is here, built when first asked for. Which block it picks where is the world's {@link LayerBlocks}, shared with
- * every other module that picks from the layer.
+ * One {@link PaletteLayer} made ready for one world: its blocks, and the noise that decides how thick it is here, built when first
+ * asked for. Which block it picks where is the world's {@link LayerBlocks}, shared with every other module that picks from the layer.
*
* The thickness noise is built once, from the random of whoever asks first, as the layers of a biome always were.
*/
public final class ResolvedLayer {
+ /** The style of the noise that sets a layer's thickness: Iris's signature noise. */
+ private static final NoiseStyle THICKNESS_STYLE = NoiseStyle.of("IRIS");
+
private final PaletteLayer settings;
private final Supplier layerBlocks;
- private final AtomicCache> blocks = new AtomicCache<>();
- private final AtomicCache heightNoise = new AtomicCache<>();
+ private final Supplier noise;
+ private final AtomicCache> blocks = new AtomicCache<>();
+ private final AtomicCache heightNoise = new AtomicCache<>();
- private ResolvedLayer(PaletteLayer settings, Supplier layerBlocks) {
+ private ResolvedLayer(PaletteLayer settings, Supplier layerBlocks, Supplier noise) {
this.settings = settings;
this.layerBlocks = layerBlocks;
+ this.noise = noise;
}
/** {@code settings} ready for the world whose layer blocks {@code layerBlocks} gives, asked for when first needed. */
- static ResolvedLayer of(PaletteLayer settings, Supplier layerBlocks) {
- return new ResolvedLayer(settings, layerBlocks);
+ static ResolvedLayer of(PaletteLayer settings, Supplier layerBlocks, Supplier noise) {
+ return new ResolvedLayer(settings, layerBlocks, noise);
}
public PaletteLayer settings() {
@@ -79,32 +80,33 @@ public final class ResolvedLayer {
}
/** 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();
+ public LayerNoise heightNoise(RNG rng) {
+ LayerNoise cached = heightNoise.getIfPresent();
if (cached != null) {
return cached;
}
- return heightNoise.aquire(() -> CNG.signature(rng.nextParallelRNG(settings.minHeight() * settings.maxHeight() + blocks().size())));
+ return heightNoise.aquire(() -> new LayerNoise(noise.get().sampler(THICKNESS_STYLE,
+ rng.nextParallelRNG(settings.minHeight() * settings.maxHeight() + blocks().size()).getSeed())));
}
/** The layer's block at the position, picked as {@link LayerBlocks#pick} says, or null when the palette has no block. */
- public PlatformBlockState get(RNG parent, int signature, double x, double y, double z) {
+ public BlockState get(RNG parent, int signature, double x, double y, double z) {
int index = layerBlocks.get().pick(settings, parent, signature, x, y, z);
return index == LayerBlocks.NONE ? null : blocks().get(index);
}
/** {@link #get(RNG, int, double, double, double)} for a layer asked once per column, such as a slab or a wall. */
- public PlatformBlockState get(RNG rng, double x, double y, double z) {
+ public BlockState get(RNG rng, double x, double y, double z) {
return get(rng, 0, x, y, z);
}
- private List blocks() {
- List cached = blocks.getIfPresent();
+ private List blocks() {
+ List cached = blocks.getIfPresent();
if (cached != null) {
return cached;
}
- return blocks.aquire(() -> layerBlocks.get().blocks(settings).stream().map(block -> B.getState(block.key())).toList());
+ return blocks.aquire(() -> layerBlocks.get().blocks(settings));
}
}
diff --git a/src/main/java/art/arcane/iris/engine/terrain/TerrainPalettes.java b/src/main/java/art/arcane/iris/builtin/terrain/TerrainPalettes.java
similarity index 56%
rename from src/main/java/art/arcane/iris/engine/terrain/TerrainPalettes.java
rename to src/main/java/art/arcane/iris/builtin/terrain/TerrainPalettes.java
index b98a20459..1d991d0ae 100644
--- a/src/main/java/art/arcane/iris/engine/terrain/TerrainPalettes.java
+++ b/src/main/java/art/arcane/iris/builtin/terrain/TerrainPalettes.java
@@ -15,21 +15,19 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+package art.arcane.iris.builtin.terrain;
-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.builtin.IrisSeed;
import art.arcane.volmlib.util.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.FeatureAttachment.Target;
+import com.volmit.block.BlockState;
import com.volmit.block.PaletteSpec;
+import com.volmit.config.FeatureSettings.Entry;
import com.volmit.noise.NoiseSampler;
+import com.volmit.resource.PackResources;
+import com.volmit.world.PackWorld;
+import com.volmit.world.UpperDimension;
import java.util.List;
import java.util.Map;
@@ -53,21 +51,23 @@ public final class TerrainPalettes {
@FunctionalInterface
public interface ColumnBlocks {
/** The block at the column, or null when the palette has no block. */
- PlatformBlockState at(double x, double z);
+ BlockState at(double x, double z);
}
- private final Engine engine;
+ private final PackWorld world;
+ private final long complexSeed;
private final AtomicCache rock = new AtomicCache<>();
private final AtomicCache fluid = new AtomicCache<>();
- private final Map upperRocks = new ConcurrentHashMap<>();
+ private final Map upperRocks = new ConcurrentHashMap<>();
- TerrainPalettes(Engine engine) {
- this.engine = engine;
+ TerrainPalettes(PackWorld world) {
+ this.world = world;
+ this.complexSeed = IrisSeed.COMPLEX.of(world);
}
- /** The palettes of the world {@code engine} generates now. */
- public static TerrainPalettes of(Engine engine) {
- return engine.getGeneration().state(TerrainPalettes.class, TerrainPalettes::new);
+ /** The palettes of {@code world}. */
+ public static TerrainPalettes of(PackWorld world) {
+ return world.state(TerrainPalettes.class, TerrainPalettes::new);
}
/** Builds the rock and fluid noise now instead of when first asked for. */
@@ -77,54 +77,60 @@ public final class TerrainPalettes {
}
/** The rock at the column, below the biome's layers. */
- public PlatformBlockState rockAt(double x, double z) {
+ public BlockState rockAt(double x, double z) {
return rock().at(x, z);
}
/** The fluid at the column, above the terrain up to the fluid height. */
- public PlatformBlockState fluidAt(double x, double z) {
+ public BlockState fluidAt(double x, double z) {
return fluid().at(x, z);
}
/** The rock at the column of the upper dimension: the world's own when the upper dimension is the dimension itself. */
- public PlatformBlockState upperRockAt(UpperDimensionContext upper, double x, double z) {
- return upperRocks.computeIfAbsent(upper, this::upperRock).at(x, z);
+ public BlockState upperRockAt(UpperDimension upper, double x, double z) {
+ return upperRocks.computeIfAbsent(upper.key(), key -> upperRock(upper, x, z)).at(x, z);
}
private ColumnBlocks rock() {
- return rock.aquireOrThrow(() -> columns(rockPalette(engine.getDimension()), complexRng().nextParallelRNG(ROCK_SIGNATURE), engine.getData()));
+ return rock.aquireOrThrow(() -> columns(rockPalette(world.settings().declared(RockPaletteSettings.class)), complexRng().nextParallelRNG(ROCK_SIGNATURE),
+ world.resources()));
}
private ColumnBlocks fluid() {
- return fluid.aquireOrThrow(() -> columns(fluidPalette(engine.getDimension()), complexRng().nextParallelRNG(FLUID_SIGNATURE), engine.getData()));
+ return fluid.aquireOrThrow(() -> columns(fluidPalette(world.settings().declared(FluidPaletteSettings.class)), complexRng().nextParallelRNG(FLUID_SIGNATURE),
+ world.resources()));
}
private RNG complexRng() {
- return new RNG(engine.getSeedManager().getComplex());
+ return new RNG(complexSeed);
}
- private ColumnBlocks upperRock(UpperDimensionContext upper) {
- if (upper.isSelfReferencing()) {
+ private ColumnBlocks upperRock(UpperDimension upper, double x, double z) {
+ if (upper.isThisDimension()) {
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());
+ long seedOffset = upper.key().hashCode();
+ RNG rng = new RNG(complexSeed ^ seedOffset);
+ List> declared = upper.settings().at(RockPaletteSettings.class, (int) x, (int) z);
+ return columns(rockPalette(declared), rng.nextParallelRNG(ROCK_SIGNATURE), upper.resources());
}
- private static PaletteSpec rockPalette(IrisDimension dimension) {
- return dimension.getModuleSettings().find(RockPaletteSettings.class).orElseGet(RockPaletteSettings::new).palette();
+ private static PaletteSpec rockPalette(List> declared) {
+ return dimensionLevel(declared).map(Entry::value).orElseGet(RockPaletteSettings::new).palette();
}
- private static PaletteSpec fluidPalette(IrisDimension dimension) {
- return dimension.getModuleSettings().find(FluidPaletteSettings.class).orElseGet(FluidPaletteSettings::new).palette();
+ private static PaletteSpec fluidPalette(List> declared) {
+ return dimensionLevel(declared).map(Entry::value).orElseGet(FluidPaletteSettings::new).palette();
+ }
+
+ private static java.util.Optional> dimensionLevel(List> declared) {
+ return declared.stream().filter(entry -> entry.level() == Target.DIMENSION).findFirst();
}
/** The palette's blocks over the columns, picked by its noise: the noise at a column, from 0 to 1, is how far down the weighted list the block is. */
- private static ColumnBlocks columns(PaletteSpec palette, RNG rng, IrisData data) {
- IrisPackResources resources = data.getPackResources();
- List blocks = PaletteBlocks.weighted(resources.blocks(), palette.palette());
+ private static ColumnBlocks columns(PaletteSpec palette, RNG rng, PackResources resources) {
+ List blocks = PaletteBlocks.weighted(resources.blocks(), palette.palette());
if (blocks.isEmpty()) {
return (x, z) -> null;
}
diff --git a/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java b/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java
index a86b1b286..9c5499e39 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java
+++ b/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java
@@ -19,40 +19,36 @@
package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.IrisStages;
-import art.arcane.iris.core.modules.IrisChunk;
-import art.arcane.iris.core.modules.IrisPackWorld;
+import art.arcane.iris.builtin.decorant.DecorantSettings;
+import art.arcane.iris.builtin.decorant.DecorateSettings;
import art.arcane.iris.engine.decorator.BiomeDecorators;
+import art.arcane.iris.engine.decorator.DecoratedBiome;
+import art.arcane.iris.engine.decorator.DecorationScene;
import art.arcane.iris.engine.decorator.IrisSeaFloorDecorator;
import art.arcane.iris.engine.decorator.IrisSeaSurfaceDecorator;
import art.arcane.iris.engine.decorator.IrisShoreLineDecorator;
import art.arcane.iris.engine.decorator.IrisSurfaceDecorator;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.framework.EngineDecorator;
-import art.arcane.iris.builtin.decorant.DecorantSettings;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
-import art.arcane.iris.spi.PlatformBlockState;
-import art.arcane.iris.util.common.data.B;
-import art.arcane.iris.util.project.context.ChunkContext;
-import art.arcane.iris.util.project.hunk.Hunk;
-import art.arcane.volmlib.util.documentation.BlockCoordinates;
-import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLifecycle;
+import com.volmit.block.BlockState;
+import com.volmit.config.FeatureSettings;
+import com.volmit.hunk.Hunk;
import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.StageGraph;
+import com.volmit.world.BiomeKind;
import com.volmit.world.PackWorld;
-
-import java.util.function.Predicate;
+import com.volmit.world.TerrainSampler;
/**
* Module {@code iris:decorant}: the biomes' decorators ({@link DecorantSettings}), placed on the surface the mantle's
* blocks left: the surface itself, the sea surface and floor, and the shore line. A dimension turns decorating off with
- * {@code decorate}. The decorators' noise is built ahead of generation, in {@link #warmUp}.
+ * {@link DecorateSettings}. The decorators' noise is built ahead of generation, in {@link #warmUp}.
*/
public final class DecorantModule implements IrisModule, ModuleLifecycle {
private static final String VERSION = "built-in";
+ private static final int CHUNK_CENTRE = 7;
@Override
public ModuleInfo info() {
@@ -62,6 +58,7 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
@Override
public void register(FeatureRegistry registry) {
registry.registerSettings(DecorantSettings.class);
+ registry.registerSettings(DecorateSettings.class);
registry.registerLifecycle(this);
}
@@ -77,87 +74,62 @@ public final class DecorantModule implements IrisModule, ModuleLifecycle {
}
private static void decorate(ChunkStageContext context) {
- IrisChunk chunk = IrisChunk.current();
- decorating(context.world()).decorate(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.context());
+ if (!decorates(context)) {
+ return;
+ }
+ decorate(DecorationScene.of(context), context.settings(), context.originX(), context.originZ());
}
- /** The world's decorating, kept in its state store. */
- static Decorating decorating(PackWorld world) {
- return world.state(Decorating.class, Decorating::new);
+ /** A dimension decorates unless it says {@code decorate: false}. */
+ private static boolean decorates(ChunkStageContext context) {
+ return context.settings().at(DecorateSettings.class, context.originX() + CHUNK_CENTRE, context.originZ() + CHUNK_CENTRE).stream()
+ .allMatch(entry -> entry.value().decorate());
}
- /** What decorating keeps for one world: one decorator per kind of place. */
- static final class Decorating {
- private static final Predicate PREDICATE_SOLID = (s) -> s != null && !B.isAirOrFluid(s);
+ /** Decorates the 16 x 16 columns of the chunk whose first block is {@code x}, {@code z}, a biome's decorators on the surface its blocks left. */
+ static void decorate(DecorationScene scene, FeatureSettings settings, int x, int z) {
+ Hunk output = scene.blocks();
+ TerrainSampler terrain = scene.terrain();
+ BiomeDecorators decorators = scene.decorators();
+ IrisSurfaceDecorator surfaceDecorator = new IrisSurfaceDecorator(scene);
+ IrisSeaSurfaceDecorator seaSurfaceDecorator = new IrisSeaSurfaceDecorator(scene);
+ IrisSeaFloorDecorator seaFloorDecorator = new IrisSeaFloorDecorator(scene);
+ IrisShoreLineDecorator shoreLineDecorator = new IrisShoreLineDecorator(scene);
+ int fluidHeight = scene.fluidHeight();
+ int worldHeight = scene.worldHeight();
- private final Engine engine;
- private final BiomeDecorators decorators;
- private final IrisSurfaceDecorator surfaceDecorator;
- private final EngineDecorator seaSurfaceDecorator;
- private final EngineDecorator seaFloorDecorator;
- private final EngineDecorator shoreLineDecorator;
+ for (int i = 0; i < output.getWidth(); i++) {
+ int realX = Math.round(x + i);
+ for (int j = 0; j < output.getDepth(); j++) {
+ int realZ = Math.round(z + j);
+ DecoratedBiome biome = BiomeDecorators.biomeOf(settings, realX, realZ, terrain.surfaceKind(realX, realZ));
+ if (!decorators.hasDecorators(biome)) {
+ continue;
+ }
+ int height = (int) Math.round(terrain.surfaceY(realX, realZ));
- Decorating(PackWorld world) {
- this(IrisPackWorld.of(world).engine());
- }
+ if (height >= 0 && height < fluidHeight && scene.isSolid(output.get(i, height, j))
+ && height + 1 < output.getHeight() && scene.isWater(output.get(i, height + 1, j))) {
+ seaSurfaceDecorator.decorate(i, j,
+ realX, Math.round(i + 1), Math.round(x + i - 1),
+ realZ, Math.round(z + j + 1), Math.round(z + j - 1),
+ biome, fluidHeight, worldHeight);
+ seaFloorDecorator.decorate(i, j,
+ realX, realZ, biome, height + 1,
+ fluidHeight + 1);
+ }
- Decorating(Engine engine) {
- this.engine = engine;
- decorators = BiomeDecorators.of(engine);
- surfaceDecorator = new IrisSurfaceDecorator(engine);
- seaSurfaceDecorator = new IrisSeaSurfaceDecorator(engine);
- shoreLineDecorator = new IrisShoreLineDecorator(engine);
- seaFloorDecorator = new IrisSeaFloorDecorator(engine);
- }
+ if (height == fluidHeight) {
+ shoreLineDecorator.decorate(i, j,
+ realX, Math.round(x + i + 1), Math.round(x + i - 1),
+ realZ, Math.round(z + j + 1), Math.round(z + j - 1),
+ biome, height, worldHeight);
+ }
- /** Decorates the 16 x 16 columns of the chunk whose first block is {@code x}, {@code z}, a biome's decorators on the surface its blocks left. */
- @BlockCoordinates
- void decorate(int x, int z, Hunk output, ChunkContext context) {
- if (!engine.getDimension().isDecorate()) {
- return;
- }
-
- PrecisionStopwatch p = PrecisionStopwatch.start();
-
- for (int i = 0; i < output.getWidth(); i++) {
- int height;
- int realX = Math.round(x + i);
- int realZ;
- IrisBiome biome;
- for (int j = 0; j < output.getDepth(); j++) {
- realZ = Math.round(z + j);
- height = context.getRoundedHeight(i, j);
- biome = context.getBiome().get(i, j);
-
- if (!decorators.hasDecorators(biome)) {
- continue;
- }
-
- if (height < engine.getDimension().getFluidHeight() && PREDICATE_SOLID.test(output.get(i, height, j))
- && height + 1 < output.getHeight() && B.isWater(output.get(i, height + 1, j))) {
- seaSurfaceDecorator.decorate(i, j,
- realX, Math.round(i + 1), Math.round(x + i - 1),
- realZ, Math.round(z + j + 1), Math.round(z + j - 1),
- output, biome, engine.getDimension().getFluidHeight(), engine.getHeight());
- seaFloorDecorator.decorate(i, j,
- realX, realZ, output, biome, height + 1,
- engine.getDimension().getFluidHeight() + 1);
- }
-
- if (height == engine.getDimension().getFluidHeight()) {
- shoreLineDecorator.decorate(i, j,
- realX, Math.round(x + i + 1), Math.round(x + i - 1),
- realZ, Math.round(z + j + 1), Math.round(z + j - 1),
- output, biome, height, engine.getHeight());
- }
-
- if (height >= 0 && height < output.getHeight()) {
- surfaceDecorator.decorate(i, j, realX, realZ, output, biome, height, engine.getHeight() - height);
- }
+ if (height >= 0 && height < output.getHeight()) {
+ surfaceDecorator.decorate(i, j, realX, realZ, biome, height, worldHeight - height);
}
}
-
- engine.getMetrics().getDecoration().put(p.getMilliseconds());
}
}
}
diff --git a/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java b/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java
index 11935ef1f..f3812b71a 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java
+++ b/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java
@@ -15,16 +15,18 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.actuator;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
-import art.arcane.iris.engine.object.world.region.IrisRegion;
-import art.arcane.volmlib.util.collection.KList;
+import art.arcane.iris.builtin.IrisSeed;
+import art.arcane.iris.builtin.terrain.OreSettings;
import art.arcane.volmlib.util.math.RNG;
+import com.volmit.FeatureAttachment.Target;
+import com.volmit.config.FeatureSettings.Entry;
+import com.volmit.resource.ResourceId;
+import com.volmit.world.PackWorld;
import java.util.Comparator;
+import java.util.List;
import java.util.function.LongSupplier;
/**
@@ -35,36 +37,40 @@ import java.util.function.LongSupplier;
final class OreWarmUp {
private static final long ROOT_SEED_SALT = 7777L;
- private final Engine engine;
+ private final PackWorld world;
private final TerrainOres ores;
private final RNG root;
private int warmed;
- OreWarmUp(Engine engine) {
- this(engine, TerrainOres.of(engine));
+ OreWarmUp(PackWorld world) {
+ this(world, TerrainOres.of(world));
}
- OreWarmUp(Engine engine, TerrainOres ores) {
- this.engine = engine;
+ OreWarmUp(PackWorld world, TerrainOres ores) {
+ this.world = world;
this.ores = ores;
- this.root = new RNG(engine.getSeedManager().getComponent() + ROOT_SEED_SALT);
+ this.root = new RNG(IrisSeed.COMPONENT.of(world) + ROOT_SEED_SALT);
}
void warm() {
LongSupplier seeds = () -> root.nextParallelRNG(warmed++).getSeed();
- KList biomes = engine.getAllBiomes();
- biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
- for (IrisBiome biome : biomes) {
- ores.of(biome).warm(seeds);
- }
+ List> declared = world.settings().declared(OreSettings.class);
+ warmLevel(declared, Target.BIOME, seeds);
+ warmLevel(declared, Target.REGION, seeds);
+ warmLevel(declared, Target.DIMENSION, seeds);
+ }
- KList regions = engine.getDimension().getAllRegions(engine);
- regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
- for (IrisRegion region : regions) {
- ores.of(region).warm(seeds);
- }
+ /** The ores of every owner at {@code level}, ordered by the key of the biome, region or dimension that declares them. */
+ private void warmLevel(List> declared, Target level, LongSupplier seeds) {
+ declared.stream()
+ .filter(entry -> entry.level() == level)
+ .sorted(Comparator.comparing((Entry entry) -> key(entry.source())))
+ .forEach(entry -> ores.of(entry.value()).warm(seeds));
+ }
- ores.of(engine.getDimension()).warm(seeds);
+ private static String key(ResourceId source) {
+ String path = source.path();
+ return path.substring(path.indexOf('/') + 1);
}
}
diff --git a/src/main/java/art/arcane/iris/engine/actuator/ResolvedOre.java b/src/main/java/art/arcane/iris/engine/actuator/ResolvedOre.java
index ec1d1c72c..9593b00cb 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/ResolvedOre.java
+++ b/src/main/java/art/arcane/iris/engine/actuator/ResolvedOre.java
@@ -15,25 +15,23 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.terrain.OreGenerator;
import art.arcane.volmlib.util.cache.AtomicCache;
-import art.arcane.iris.engine.framework.Engine;
-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 com.volmit.block.BlockState;
import com.volmit.block.PaletteSampler;
import com.volmit.noise.NoiseFactory;
import com.volmit.noise.NoiseSampler;
+import com.volmit.resource.PackResources;
import java.util.ArrayList;
import java.util.List;
/**
- * One {@link OreGenerator} made ready for one world: its palette resolved to the platform's blocks and the noise that
+ * One {@link OreGenerator} made ready for one world: its palette resolved to blocks and the noise that
* decides where it places ore, built from the seed it is warmed with or, when nothing warmed it, from the terrain seed
* of its first use. The palette picks with the terrain seed. What the generator describes stays in the settings;
* everything that needs the platform, the pack or the world seed is here.
@@ -43,7 +41,7 @@ final class ResolvedOre {
private final NoiseFactory noise;
private final BlockRegistry blockRegistry;
private final long terrainSeed;
- private final List blocks;
+ private final List blocks;
private final AtomicCache chance = new AtomicCache<>();
private final AtomicCache palette = new AtomicCache<>();
@@ -51,7 +49,7 @@ final class ResolvedOre {
* @param terrainSeed the seed the palette picks with, and the noise is built from when nothing warmed it first
* @param blocks the palette as the platform's blocks, each repeated by its weight
*/
- ResolvedOre(OreGenerator settings, NoiseFactory noise, BlockRegistry blockRegistry, long terrainSeed, List blocks) {
+ ResolvedOre(OreGenerator settings, NoiseFactory noise, BlockRegistry blockRegistry, long terrainSeed, List blocks) {
this.settings = settings;
this.noise = noise;
this.blockRegistry = blockRegistry;
@@ -59,20 +57,16 @@ final class ResolvedOre {
this.blocks = List.copyOf(blocks);
}
- /** {@code settings} ready for {@code engine}: its blocks resolved through the pack, its picks seeded with the terrain seed. */
- static ResolvedOre of(OreGenerator settings, Engine engine) {
- var resources = engine.getData().getPackResources();
+ /** {@code settings} ready for a world with {@code resources}: its blocks resolved through the pack, its picks seeded with the terrain seed. */
+ static ResolvedOre of(OreGenerator settings, PackResources resources, long terrainSeed) {
BlockRegistry registry = resources.blocks();
- return new ResolvedOre(settings, resources.noise(), registry, engine.getSeedManager().getTerrain(), weighted(registry, settings.palette().palette()));
+ return new ResolvedOre(settings, resources.noise(), registry, terrainSeed, weighted(registry, settings.palette().palette()));
}
- private static List weighted(BlockRegistry registry, List specs) {
- List weighted = new ArrayList<>();
+ private static List weighted(BlockRegistry registry, List specs) {
+ List weighted = new ArrayList<>();
for (BlockSpec spec : specs) {
- PlatformBlockState state = B.getState(registry.resolve(spec).key());
- if (state == null) {
- continue;
- }
+ BlockState state = registry.resolve(spec);
for (int n = 0; n < spec.weight(); n++) {
weighted.add(state);
}
@@ -98,7 +92,7 @@ final class ResolvedOre {
}
/** The ore block at the position, or null when the position is out of the band, the chance noise is above the threshold or the palette has no block. */
- PlatformBlockState generate(int x, int y, int z) {
+ BlockState generate(int x, int y, int z) {
if (!settings.range().contains(y)) {
return null;
}
@@ -120,7 +114,7 @@ final class ResolvedOre {
return chance.aquire(() -> noise.sampler(settings.chanceStyle(), terrainSeed));
}
- private PlatformBlockState pick(int x, int y, int z) {
+ private BlockState pick(int x, int y, int z) {
if (blocks.isEmpty()) {
return null;
}
@@ -128,6 +122,6 @@ final class ResolvedOre {
return blocks.getFirst();
}
PaletteSampler sampler = palette.aquire(() -> blockRegistry.palette(settings.palette(), terrainSeed));
- return B.getState(sampler.at(x, y, z).key());
+ return sampler.at(x, y, z);
}
}
diff --git a/src/main/java/art/arcane/iris/engine/actuator/ResolvedOres.java b/src/main/java/art/arcane/iris/engine/actuator/ResolvedOres.java
index e3df4ad35..ed313ea66 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/ResolvedOres.java
+++ b/src/main/java/art/arcane/iris/engine/actuator/ResolvedOres.java
@@ -15,13 +15,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.terrain.OreGenerator;
import art.arcane.iris.builtin.terrain.OreSettings;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.spi.PlatformBlockState;
+import com.volmit.block.BlockState;
+import com.volmit.resource.PackResources;
import java.util.ArrayList;
import java.util.List;
@@ -49,12 +48,12 @@ final class ResolvedOres {
this.undergroundBand = YBand.of(underground);
}
- /** {@code settings} ready for {@code engine}; generators the pack wrote as {@code null} are left out. */
- static ResolvedOres of(OreSettings settings, Engine engine) {
+ /** {@code settings} ready for a world with {@code resources}; generators the pack wrote as {@code null} are left out. */
+ static ResolvedOres of(OreSettings settings, PackResources resources, long terrainSeed) {
List ores = new ArrayList<>();
for (OreGenerator generator : settings.generators()) {
if (generator != null) {
- ores.add(ResolvedOre.of(generator, engine));
+ ores.add(ResolvedOre.of(generator, resources, terrainSeed));
}
}
return ores.isEmpty() ? NONE : new ResolvedOres(ores);
@@ -77,17 +76,17 @@ final class ResolvedOres {
}
}
- PlatformBlockState generateSurface(int x, int y, int z) {
+ BlockState generateSurface(int x, int y, int z) {
return firstOre(surface, x, y, z);
}
- PlatformBlockState generateUnderground(int x, int y, int z) {
+ BlockState generateUnderground(int x, int y, int z) {
return firstOre(underground, x, y, z);
}
- private static PlatformBlockState firstOre(List ores, int x, int y, int z) {
+ private static BlockState firstOre(List ores, int x, int y, int z) {
for (int index = 0; index < ores.size(); index++) {
- PlatformBlockState ore = ores.get(index).generate(x, y, z);
+ BlockState ore = ores.get(index).generate(x, y, z);
if (ore != null) {
return ore;
}
diff --git a/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java b/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java
index 9237e9ea4..3ddcba9e3 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java
+++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java
@@ -15,51 +15,33 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.IrisStages;
+import art.arcane.iris.builtin.terrain.BedrockSettings;
import art.arcane.iris.builtin.terrain.CaveCeilingLayersSettings;
+import art.arcane.iris.builtin.terrain.ExplodeBiomePaletteSizeSettings;
+import art.arcane.iris.builtin.terrain.ExplodeBiomePalettesSettings;
import art.arcane.iris.builtin.terrain.FluidPaletteSettings;
+import art.arcane.iris.builtin.terrain.HideOresSettings;
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.OreSettings;
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.builtin.terrain.HideOresSettings;
-import art.arcane.iris.builtin.terrain.OreSettings;
-import art.arcane.iris.core.loader.IrisData;
-import art.arcane.iris.core.modules.IrisChunk;
-import art.arcane.iris.core.modules.IrisPackWorld;
-import art.arcane.iris.engine.IrisComplex;
-import art.arcane.iris.engine.UpperDimensionContext;
-import art.arcane.iris.engine.actuator.ResolvedOres.YBand;
-import art.arcane.iris.engine.framework.Engine;
-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;
-import art.arcane.iris.util.project.context.ChunkedDataCache;
-import art.arcane.iris.util.project.hunk.Hunk;
-import art.arcane.volmlib.util.collection.KList;
-import art.arcane.volmlib.util.documentation.BlockCoordinates;
-import art.arcane.volmlib.util.math.RNG;
-import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleLifecycle;
-import com.volmit.ModuleLog;
import com.volmit.stage.ChunkStageContext;
import com.volmit.stage.StageGraph;
import com.volmit.world.PackWorld;
+import art.arcane.iris.builtin.terrain.TerrainPalettes;
+
/**
* 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
@@ -87,14 +69,16 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
registry.registerSettings(FluidPaletteSettings.class);
registry.registerSettings(OreSettings.class);
registry.registerSettings(HideOresSettings.class);
+ registry.registerSettings(BedrockSettings.class);
+ registry.registerSettings(ExplodeBiomePalettesSettings.class);
+ registry.registerSettings(ExplodeBiomePaletteSizeSettings.class);
registry.registerLifecycle(this);
}
@Override
public void warmUp(PackWorld world) {
- Engine engine = IrisPackWorld.of(world).engine();
- TerrainPalettes.of(engine).warm();
- new OreWarmUp(engine).warm();
+ TerrainPalettes.of(world).warm();
+ new OreWarmUp(world).warm();
}
@Override
@@ -103,198 +87,6 @@ public final class TerrainModule implements IrisModule, ModuleLifecycle {
}
private static void shape(ChunkStageContext context) {
- IrisChunk chunk = IrisChunk.current();
- ModuleLog log = context.log();
- chunk.state(TerrainShaper.class, generating -> new TerrainShaper(generating, log)).shape(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.context());
- }
-
- /** What shaping terrain keeps for one engine runtime: the terrain stream's random. */
- static final class TerrainShaper {
- private static final PlatformBlockState BEDROCK = B.getState("BEDROCK");
-
- private final Engine engine;
- private final TerrainPalettes palettes;
- private final BiomeLayers layers;
- private final TerrainOres ores;
- private final RNG rng;
-
- TerrainShaper(Engine engine, ModuleLog log) {
- this(engine, TerrainPalettes.of(engine), BiomeLayers.of(engine, log), TerrainOres.of(engine));
- }
-
- TerrainShaper(Engine engine, TerrainPalettes palettes, BiomeLayers layers, TerrainOres ores) {
- this.engine = engine;
- this.palettes = palettes;
- this.layers = layers;
- this.ores = ores;
- this.rng = new RNG(engine.getSeedManager().getTerrain());
- }
-
- /** Fills the 16 x 16 columns of the chunk whose first block is {@code originX}, {@code originZ}, one slice along x at a time. */
- @BlockCoordinates
- void shape(int originX, int originZ, Hunk blocks, ChunkContext context) {
- PrecisionStopwatch stopwatch = PrecisionStopwatch.start();
- for (int sliceX = 0; sliceX < blocks.getWidth(); sliceX++) {
- shapeSliver(originX, originZ, sliceX, blocks, context);
- }
- engine.getMetrics().getTerrain().put(stopwatch.getMilliseconds());
- }
-
- /** One plane from the sky to bedrock, one block thick along x. */
- @BlockCoordinates
- private void shapeSliver(int x, int z, int xf, Hunk h, ChunkContext context) {
- int chunkHeight = h.getHeight();
- int chunkDepth = h.getDepth();
- IrisDimension dimension = engine.getDimension();
- IrisData data = engine.getData();
- IrisComplex complex = engine.getComplex();
- RNG localRng = rng;
- int fluidHeight = dimension.getFluidHeight();
- int clampedFluidHeight = Math.min(chunkHeight, fluidHeight);
- boolean bedrockEnabled = dimension.isBedrock();
- boolean hideOres = HiddenOres.in(dimension);
- ChunkedDataCache biomeCache = context.getBiome();
- ChunkedDataCache regionCache = context.getRegion();
- int realX = xf + x;
- UpperDimensionContext upperContext = engine.getUpperContext();
- // Dimension-level ore lookups are chunk-invariant; resolving them per column paid
- // the settings lookup times 256 per chunk for a constant.
- ResolvedOres dimensionOres = hideOres ? ResolvedOres.NONE : ores.of(dimension);
- YBand dimensionSurfaceBand = dimensionOres.surfaceBand();
- YBand dimensionUndergroundBand = dimensionOres.undergroundBand();
-
- for (int zf = 0; zf < chunkDepth; zf++) {
- int realZ = zf + z;
- IrisBiome biome = biomeCache.get(xf, zf);
- IrisRegion region = regionCache.get(xf, zf);
- int he = Math.min(chunkHeight, context.getRoundedHeight(xf, zf));
- int hf = Math.max(clampedFluidHeight, he);
- if (hf < 0) {
- continue;
- }
-
- int topY = Math.min(hf, chunkHeight - 1);
- PlatformBlockState fluid = palettes.fluidAt(realX, realZ);
- PlatformBlockState rock = palettes.rockAt(realX, realZ);
- PlatformBlockState mappedSurfaceBlock = complex.getImageMapRuntime().sampleSurfaceBlock(realX, realZ);
- ResolvedOres biomeOres = hideOres ? ResolvedOres.NONE : ores.of(biome);
- ResolvedOres regionOres = hideOres ? ResolvedOres.NONE : ores.of(region);
- YBand biomeSurfaceBand = biomeOres.surfaceBand();
- YBand regionSurfaceBand = regionOres.surfaceBand();
- YBand biomeUndergroundBand = biomeOres.undergroundBand();
- YBand regionUndergroundBand = regionOres.undergroundBand();
- boolean hasSurfaceOres = biomeSurfaceBand.hasOres() || regionSurfaceBand.hasOres() || dimensionSurfaceBand.hasOres();
- boolean hasUndergroundOres = biomeUndergroundBand.hasOres() || regionUndergroundBand.hasOres() || dimensionUndergroundBand.hasOres();
- KList blocks = null;
- KList fblocks = null;
-
- for (int i = topY; i >= 0; i--) {
- if (i == 0 && bedrockEnabled) {
- h.setRaw(xf, i, zf, BEDROCK);
- continue;
- }
-
- PlatformBlockState ore = null;
- if (hasSurfaceOres) {
- if (biomeSurfaceBand.contains(i)) {
- ore = biomeOres.generateSurface(realX, i, realZ);
- }
- if (ore == null && regionSurfaceBand.contains(i)) {
- ore = regionOres.generateSurface(realX, i, realZ);
- }
- if (ore == null && dimensionSurfaceBand.contains(i)) {
- ore = dimensionOres.generateSurface(realX, i, realZ);
- }
- }
- if (ore != null) {
- h.setRaw(xf, i, zf, ore);
- continue;
- }
-
- if (i > he && i <= hf) {
- int fdepth = hf - i;
- if (fblocks == null) {
- fblocks = layers.generateSeaLayers(biome, realX, realZ, localRng, hf - he, data);
- }
-
- if (fblocks.hasIndex(fdepth)) {
- h.setRaw(xf, i, zf, fblocks.get(fdepth));
- } else {
- h.setRaw(xf, i, zf, fluid);
- }
- continue;
- }
-
- if (i <= he) {
- int depth = he - i;
- if (depth == 0 && mappedSurfaceBlock != null) {
- h.setRaw(xf, i, zf, mappedSurfaceBlock);
- continue;
- }
- if (blocks == null) {
- blocks = layers.generateLayers(biome, dimension, realX, realZ, localRng, he, he, data, complex);
- }
-
- if (blocks.hasIndex(depth)) {
- h.setRaw(xf, i, zf, blocks.get(depth));
- continue;
- }
-
- if (hasUndergroundOres) {
- if (biomeUndergroundBand.contains(i)) {
- ore = biomeOres.generateUnderground(realX, i, realZ);
- }
- if (ore == null && regionUndergroundBand.contains(i)) {
- ore = regionOres.generateUnderground(realX, i, realZ);
- }
- if (ore == null && dimensionUndergroundBand.contains(i)) {
- ore = dimensionOres.generateUnderground(realX, i, realZ);
- }
- }
-
- if (ore != null) {
- h.setRaw(xf, i, zf, ore);
- } else {
- h.setRaw(xf, i, zf, rock);
- }
- }
- }
-
- if (upperContext != null) {
- int rawUpperSurface = upperContext.getUpperSurfaceY(realX, realZ);
- int upperGap = dimension.getUpperDimensionGap();
- int upperSurfaceY = Math.max(rawUpperSurface, he + upperGap);
-
- if (upperSurfaceY < chunkHeight - 1) {
- IrisBiome upperBiome = upperContext.getUpperBiome(realX, realZ);
- PlatformBlockState upperRock = palettes.upperRockAt(upperContext, realX, realZ);
- PlatformBlockState upperMappedSurface = upperContext.getSurfaceBlock(realX, realZ);
- int upperThickness = chunkHeight - 1 - upperSurfaceY;
- KList upperBlocks = upperBiome != null
- ? layers.generateLayers(upperBiome, upperContext.getDimension(),
- realX, realZ, localRng, upperThickness, upperThickness,
- upperContext.getData(), complex)
- : null;
-
- for (int y = chunkHeight - 1; y >= upperSurfaceY; y--) {
- if (y == chunkHeight - 1 && bedrockEnabled) {
- h.setRaw(xf, y, zf, BEDROCK);
- continue;
- }
- if (y == upperSurfaceY && upperMappedSurface != null) {
- h.setRaw(xf, y, zf, upperMappedSurface);
- continue;
- }
- int depthFromFace = y - upperSurfaceY;
- if (upperBlocks != null && upperBlocks.hasIndex(depthFromFace)) {
- h.setRaw(xf, y, zf, upperBlocks.get(depthFromFace));
- } else {
- h.setRaw(xf, y, zf, upperRock);
- }
- }
- }
- }
- }
- }
+ TerrainShaper.of(context.world()).shape(context);
}
}
diff --git a/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java b/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java
index 1eb73d719..d68bb2432 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java
+++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java
@@ -15,12 +15,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.actuator;
+import art.arcane.iris.builtin.IrisSeed;
import art.arcane.iris.builtin.terrain.OreSettings;
-import art.arcane.iris.core.loader.IrisRegistrant;
-import art.arcane.iris.engine.framework.Engine;
+import com.volmit.resource.PackResources;
+import com.volmit.world.PackWorld;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -30,24 +30,25 @@ import java.util.concurrent.ConcurrentHashMap;
* ({@link ResolvedOres}), built from their {@link OreSettings} when first asked for or ahead of generation by {@link OreWarmUp}.
*/
final class TerrainOres {
- private final Engine engine;
+ private final PackResources resources;
+ private final long terrainSeed;
private final Map resolved = new ConcurrentHashMap<>();
- TerrainOres(Engine engine) {
- this.engine = engine;
+ TerrainOres(PackWorld world) {
+ this.resources = world.resources();
+ this.terrainSeed = IrisSeed.TERRAIN.of(world);
}
- /** The ores of the world {@code engine} generates now. */
- static TerrainOres of(Engine engine) {
- return engine.getGeneration().state(TerrainOres.class, TerrainOres::new);
+ /** The ores of {@code world}. */
+ static TerrainOres of(PackWorld world) {
+ return world.state(TerrainOres.class, TerrainOres::new);
}
/**
- * The ore generators {@code owner}, a dimension, region or biome, declares; {@link ResolvedOres#NONE} when it declares none. The
- * terrain asks this for two owners per column, so a resolved set is read without taking the map's lock.
+ * The ore generators {@code settings}, those a dimension, region or biome declares, make ready; {@link ResolvedOres#NONE} when it
+ * declares none. The terrain asks this for two owners per column, so a resolved set is read without taking the map's lock.
*/
- ResolvedOres of(IrisRegistrant owner) {
- OreSettings settings = owner.getModuleSettings().find(OreSettings.class).orElse(null);
+ ResolvedOres of(OreSettings settings) {
if (settings == null) {
return ResolvedOres.NONE;
}
@@ -55,6 +56,6 @@ final class TerrainOres {
if (existing != null) {
return existing;
}
- return resolved.computeIfAbsent(settings, declared -> ResolvedOres.of(declared, engine));
+ return resolved.computeIfAbsent(settings, declared -> ResolvedOres.of(declared, resources, terrainSeed));
}
}
diff --git a/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java b/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java
new file mode 100644
index 000000000..5a5429466
--- /dev/null
+++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java
@@ -0,0 +1,321 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.engine.actuator;
+
+import art.arcane.iris.builtin.IrisSeed;
+import art.arcane.iris.builtin.terrain.BedrockSettings;
+import art.arcane.iris.builtin.terrain.HideOresSettings;
+import art.arcane.iris.builtin.terrain.OreSettings;
+import art.arcane.iris.engine.actuator.ResolvedOres.YBand;
+import art.arcane.iris.builtin.terrain.BiomeLayers;
+import art.arcane.iris.builtin.terrain.ColumnSlope;
+import art.arcane.iris.builtin.terrain.LayeredBiome;
+import art.arcane.iris.builtin.terrain.PaletteExplosion;
+import art.arcane.iris.builtin.terrain.TerrainPalettes;
+import art.arcane.volmlib.util.collection.KList;
+import art.arcane.volmlib.util.math.RNG;
+import com.volmit.FeatureAttachment.Target;
+import com.volmit.IrisFeature;
+import com.volmit.block.BlockState;
+import com.volmit.config.FeatureSettings;
+import com.volmit.config.FeatureSettings.Entry;
+import com.volmit.hunk.Hunk;
+import com.volmit.resource.ResourceId;
+import com.volmit.stage.ChunkStageContext;
+import com.volmit.world.PackWorld;
+import com.volmit.world.TerrainSampler;
+import com.volmit.world.UpperDimension;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.OptionalInt;
+import java.util.function.Function;
+
+/** What shaping terrain keeps for one world: the terrain stream's random and the palettes, layers and ores the columns are filled from. */
+final class TerrainShaper {
+ private static final BlockState BEDROCK = new BlockState("minecraft:bedrock");
+ private static final int CHUNK_CENTRE = 7;
+
+ private final TerrainPalettes palettes;
+ private final BiomeLayers layers;
+ private final TerrainOres ores;
+ private final RNG rng;
+ private final boolean levelsBelowTheDimensionDeclareOres;
+
+ static TerrainShaper of(PackWorld world) {
+ return world.state(TerrainShaper.class, TerrainShaper::new);
+ }
+
+ TerrainShaper(PackWorld world) {
+ this(world, TerrainPalettes.of(world), BiomeLayers.of(world), TerrainOres.of(world));
+ }
+
+ TerrainShaper(PackWorld world, TerrainPalettes palettes, BiomeLayers layers, TerrainOres ores) {
+ this.palettes = palettes;
+ this.layers = layers;
+ this.ores = ores;
+ this.rng = new RNG(IrisSeed.TERRAIN.of(world));
+ this.levelsBelowTheDimensionDeclareOres = world.settings().declared(OreSettings.class).stream()
+ .anyMatch(entry -> entry.level() != Target.DIMENSION);
+ }
+
+ /** Fills the 16 x 16 columns of the chunk, one slice along x at a time. */
+ void shape(ChunkStageContext context) {
+ Chunk chunk = new Chunk(context);
+ for (int sliceX = 0; sliceX < chunk.blocks.getWidth(); sliceX++) {
+ shapeSliver(chunk, sliceX);
+ }
+ }
+
+ /** One plane from the sky to bedrock, one block thick along x. */
+ private void shapeSliver(Chunk chunk, int xf) {
+ Hunk h = chunk.blocks;
+ int chunkHeight = h.getHeight();
+ int chunkDepth = h.getDepth();
+ int realX = xf + chunk.originX;
+
+ for (int zf = 0; zf < chunkDepth; zf++) {
+ int realZ = zf + chunk.originZ;
+ int he = Math.min(chunkHeight, (int) Math.round(chunk.terrain.surfaceY(realX, realZ)));
+ int hf = Math.max(chunk.clampedFluidHeight, he);
+ if (hf < 0) {
+ continue;
+ }
+
+ int topY = Math.min(hf, chunkHeight - 1);
+ BlockState fluid = palettes.fluidAt(realX, realZ);
+ BlockState rock = palettes.rockAt(realX, realZ);
+ BlockState mappedSurfaceBlock = chunk.terrain.surfaceBlock(realX, realZ).orElse(null);
+ LayeredBiome biome = layers.biome(chunk.terrain.surfaceBiome(realX, realZ), chunk.settings);
+ ColumnOres columnOres = chunk.oresAt(realX, realZ);
+ ResolvedOres biomeOres = columnOres.biome;
+ ResolvedOres regionOres = columnOres.region;
+ YBand biomeSurfaceBand = biomeOres.surfaceBand();
+ YBand regionSurfaceBand = regionOres.surfaceBand();
+ YBand biomeUndergroundBand = biomeOres.undergroundBand();
+ YBand regionUndergroundBand = regionOres.undergroundBand();
+ ResolvedOres dimensionOres = chunk.dimensionOres;
+ YBand dimensionSurfaceBand = dimensionOres.surfaceBand();
+ YBand dimensionUndergroundBand = dimensionOres.undergroundBand();
+ boolean hasSurfaceOres = biomeSurfaceBand.hasOres() || regionSurfaceBand.hasOres() || dimensionSurfaceBand.hasOres();
+ boolean hasUndergroundOres = biomeUndergroundBand.hasOres() || regionUndergroundBand.hasOres() || dimensionUndergroundBand.hasOres();
+ KList blocks = null;
+ KList fblocks = null;
+
+ for (int i = topY; i >= 0; i--) {
+ if (i == 0 && chunk.bedrockEnabled) {
+ place(h, xf, i, zf, BEDROCK);
+ continue;
+ }
+
+ BlockState ore = null;
+ if (hasSurfaceOres) {
+ if (biomeSurfaceBand.contains(i)) {
+ ore = biomeOres.generateSurface(realX, i, realZ);
+ }
+ if (ore == null && regionSurfaceBand.contains(i)) {
+ ore = regionOres.generateSurface(realX, i, realZ);
+ }
+ if (ore == null && dimensionSurfaceBand.contains(i)) {
+ ore = dimensionOres.generateSurface(realX, i, realZ);
+ }
+ }
+ if (ore != null) {
+ place(h, xf, i, zf, ore);
+ continue;
+ }
+
+ if (i > he && i <= hf) {
+ int fdepth = hf - i;
+ if (fblocks == null) {
+ fblocks = layers.generateSeaLayers(biome, realX, realZ, rng, hf - he);
+ }
+
+ if (fblocks.hasIndex(fdepth)) {
+ place(h, xf, i, zf, fblocks.get(fdepth));
+ } else {
+ place(h, xf, i, zf, fluid);
+ }
+ continue;
+ }
+
+ if (i <= he) {
+ int depth = he - i;
+ if (depth == 0 && mappedSurfaceBlock != null) {
+ place(h, xf, i, zf, mappedSurfaceBlock);
+ continue;
+ }
+ if (blocks == null) {
+ blocks = layers.generateLayers(biome, chunk.explosion, realX, realZ, rng, he, he, chunk.slope);
+ }
+
+ if (blocks.hasIndex(depth)) {
+ place(h, xf, i, zf, blocks.get(depth));
+ continue;
+ }
+
+ if (hasUndergroundOres) {
+ if (biomeUndergroundBand.contains(i)) {
+ ore = biomeOres.generateUnderground(realX, i, realZ);
+ }
+ if (ore == null && regionUndergroundBand.contains(i)) {
+ ore = regionOres.generateUnderground(realX, i, realZ);
+ }
+ if (ore == null && dimensionUndergroundBand.contains(i)) {
+ ore = dimensionOres.generateUnderground(realX, i, realZ);
+ }
+ }
+
+ place(h, xf, i, zf, ore != null ? ore : rock);
+ }
+ }
+
+ if (chunk.upper.isPresent()) {
+ fillUpperDimension(chunk, chunk.upper.get(), xf, zf, realX, realZ);
+ }
+ }
+ }
+
+ /** The upper dimension's ground, filled in from the top of the column down to where it ends. */
+ private void fillUpperDimension(Chunk chunk, UpperDimension upper, int xf, int zf, int realX, int realZ) {
+ Hunk h = chunk.blocks;
+ int chunkHeight = h.getHeight();
+ OptionalInt upperY = chunk.terrain.upperDimensionY(realX, realZ);
+ if (upperY.isEmpty()) {
+ return;
+ }
+ int upperSurfaceY = upperY.getAsInt();
+ if (upperSurfaceY >= chunkHeight - 1) {
+ return;
+ }
+
+ FeatureSettings upperSettings = upper.settings();
+ BlockState upperRock = palettes.upperRockAt(upper, realX, realZ);
+ BlockState upperMappedSurface = upper.surfaceBlock(realX, realZ).orElse(null);
+ int upperThickness = chunkHeight - 1 - upperSurfaceY;
+ LayeredBiome upperBiome = upperBiome(upperSettings, realX, realZ);
+ KList upperBlocks = layers.generateLayers(upperBiome, chunk.upperExplosion(upperSettings, realX, realZ),
+ realX, realZ, rng, upperThickness, upperThickness, chunk.slope);
+
+ for (int y = chunkHeight - 1; y >= upperSurfaceY; y--) {
+ if (y == chunkHeight - 1 && chunk.bedrockEnabled) {
+ place(h, xf, y, zf, BEDROCK);
+ continue;
+ }
+ if (y == upperSurfaceY && upperMappedSurface != null) {
+ place(h, xf, y, zf, upperMappedSurface);
+ continue;
+ }
+ int depthFromFace = y - upperSurfaceY;
+ if (upperBlocks.hasIndex(depthFromFace)) {
+ place(h, xf, y, zf, upperBlocks.get(depthFromFace));
+ } else {
+ place(h, xf, y, zf, upperRock);
+ }
+ }
+ }
+
+ /** What the biome of the upper dimension at the column declares about its layers. */
+ private LayeredBiome upperBiome(FeatureSettings upperSettings, int worldX, int worldZ) {
+ return new LayeredBiome(biomeLevel(upperSettings, art.arcane.iris.builtin.terrain.LayersSettings.class, worldX, worldZ), null, null,
+ biomeLevel(upperSettings, art.arcane.iris.builtin.terrain.LockLayersSettings.class, worldX, worldZ),
+ biomeLevel(upperSettings, art.arcane.iris.builtin.terrain.LockLayersMaxSettings.class, worldX, worldZ), null);
+ }
+
+ private static S biomeLevel(FeatureSettings settings, Class type, int worldX, int worldZ) {
+ return settings.at(type, worldX, worldZ).stream().filter(entry -> entry.level() == Target.BIOME).map(Entry::value).findFirst().orElse(null);
+ }
+
+ /** A block the palette has none of leaves the column as it is. */
+ private static void place(Hunk blocks, int x, int y, int z, BlockState block) {
+ if (block != null) {
+ blocks.set(x, y, z, block);
+ }
+ }
+
+ /** The ores of a column's region and biome. */
+ private record ColumnOres(ResolvedOres region, ResolvedOres biome) {
+ static final ColumnOres NONE = new ColumnOres(ResolvedOres.NONE, ResolvedOres.NONE);
+ }
+
+ /** What one chunk's columns share: its views, its dimension's switches and ores. */
+ private final class Chunk {
+ final Hunk blocks;
+ final TerrainSampler terrain;
+ final FeatureSettings settings;
+ final int originX;
+ final int originZ;
+ final int clampedFluidHeight;
+ final boolean bedrockEnabled;
+ final PaletteExplosion explosion;
+ final ColumnSlope slope;
+ final Optional upper;
+ final ResolvedOres dimensionOres;
+ private final boolean hideOres;
+ private PaletteExplosion upperExplosion;
+
+ Chunk(ChunkStageContext context) {
+ this.blocks = context.hunk(BlockState.class);
+ this.terrain = context.terrain();
+ this.settings = context.settings();
+ this.originX = context.originX();
+ this.originZ = context.originZ();
+ this.clampedFluidHeight = Math.min(blocks.getHeight(), terrain.fluidHeight());
+ int centreX = originX + CHUNK_CENTRE;
+ int centreZ = originZ + CHUNK_CENTRE;
+ this.bedrockEnabled = dimensionValue(settings.at(BedrockSettings.class, centreX, centreZ), BedrockSettings::bedrock, true);
+ this.hideOres = dimensionValue(settings.at(HideOresSettings.class, centreX, centreZ), HideOresSettings::hide, false);
+ this.explosion = PaletteExplosion.of(settings, centreX, centreZ);
+ this.slope = (x, z) -> terrain.column((int) x, (int) z).slope();
+ this.upper = terrain.upperDimension();
+ // Dimension-level ore lookups are chunk-invariant; resolving them per column paid the settings lookup times 256 per chunk for a constant.
+ this.dimensionOres = hideOres ? ResolvedOres.NONE : ores.of(levelValue(settings.at(OreSettings.class, centreX, centreZ), Target.DIMENSION));
+ }
+
+ /** What the upper dimension declares about exploded palettes: a setting of the dimension, so the same for every column of the chunk. */
+ PaletteExplosion upperExplosion(FeatureSettings upperSettings, int worldX, int worldZ) {
+ if (upperExplosion == null) {
+ upperExplosion = PaletteExplosion.of(upperSettings, worldX, worldZ);
+ }
+ return upperExplosion;
+ }
+
+ /** The ores of the column's region and biome; none where the levels below the dimension declare none, or the dimension hides ores. */
+ ColumnOres oresAt(int worldX, int worldZ) {
+ if (hideOres || !levelsBelowTheDimensionDeclareOres) {
+ return ColumnOres.NONE;
+ }
+ List> declared = settings.at(OreSettings.class, worldX, worldZ);
+ return new ColumnOres(ores.of(levelValue(declared, Target.REGION)), ores.of(levelValue(declared, Target.BIOME)));
+ }
+ }
+
+ private static V dimensionValue(List> entries, Function read, V fallback) {
+ S declared = levelValue(entries, Target.DIMENSION);
+ return declared == null ? fallback : read.apply(declared);
+ }
+
+ private static S levelValue(List> entries, Target level) {
+ for (Entry entry : entries) {
+ if (entry.level() == level) {
+ return entry.value();
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/BiomeDecorators.java b/src/main/java/art/arcane/iris/engine/decorator/BiomeDecorators.java
index e38734947..0a346f27a 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/BiomeDecorators.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/BiomeDecorators.java
@@ -15,16 +15,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.decorator;
+import art.arcane.iris.builtin.IrisSeed;
import art.arcane.iris.builtin.decorant.DecorantSettings;
import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.builtin.decorant.Decorator;
-import art.arcane.iris.core.modules.IrisPackWorld;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
+import com.volmit.config.FeatureSettings;
import com.volmit.ModuleLog;
+import com.volmit.config.FeatureSettings.Entry;
+import com.volmit.resource.PackResources;
+import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import java.util.ArrayList;
@@ -35,41 +36,30 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
- * What the decorant module keeps for one world: the decorators of its biomes made ready ({@link ResolvedDecorator}),
- * sorted into the places they decorate, and how loaded the busiest biome is. Built from the biomes' {@link DecorantSettings}
- * when first asked for, or ahead of generation by {@link #warm()}.
+ * What the decorant module keeps for one world: the decorators of its biomes made ready ({@link ResolvedDecorator}), sorted into
+ * the places they decorate. Built from the biomes' {@link DecorantSettings} when first asked for, or ahead of generation by
+ * {@link #warm()}.
*
* A decorator's noise seed is a function of the world's decorator seed, its biome's key and its place in the biome's
* list, so it does not depend on which column or which warm-up reached it first.
*/
public final class BiomeDecorators {
private static final ResolvedDecorator[] NO_DECORATORS = new ResolvedDecorator[0];
- private static final int COLUMNS_PER_CHUNK = 256;
+ private static final String BIOME_PATH_PREFIX = "biome/";
private static final long KEY_SEED_FACTOR = 0x9E3779B97F4A7C15L;
private static final long INDEX_SEED_FACTOR = 0xC2B2AE3D27D4EB4FL;
- private final Engine engine;
+ private final PackWorld world;
+ private final PackResources resources;
private final ModuleLog log;
+ private final long decoratorSeed;
private final Map> decorators = new ConcurrentHashMap<>();
- private volatile Double busiestBiomeLoad;
- /** @param world a world of an Iris engine */
BiomeDecorators(PackWorld world) {
- this(IrisPackWorld.of(world).engine(), world.log());
- }
-
- BiomeDecorators(Engine engine) {
- this(engine, engine.getGeneration().world().log());
- }
-
- BiomeDecorators(Engine engine, ModuleLog log) {
- this.engine = engine;
- this.log = log;
- }
-
- /** The world {@code engine} generates now. */
- public static BiomeDecorators of(Engine engine) {
- return engine.getGeneration().state(BiomeDecorators.class, BiomeDecorators::new);
+ this.world = world;
+ this.resources = world.resources();
+ this.log = world.log();
+ this.decoratorSeed = IrisSeed.DECORATOR.of(world);
}
/** The world's decorators, kept in its state store. */
@@ -77,36 +67,51 @@ public final class BiomeDecorators {
return world.state(BiomeDecorators.class, BiomeDecorators::new);
}
+ /** The key of the biome a settings entry was declared by, such as {@code desert/dunes} for {@code overworld:biome/desert/dunes}. */
+ public static String biomeKey(ResourceId source) {
+ String path = source.path();
+ return path.startsWith(BIOME_PATH_PREFIX) ? path.substring(BIOME_PATH_PREFIX.length()) : path;
+ }
+
+ /** The biome of the entry a column's settings gave, which is the column's surface biome; null when the biome declares nothing. */
+ public static DecoratedBiome biomeOf(FeatureSettings settings, int worldX, int worldZ, com.volmit.world.BiomeKind kind) {
+ List> entries = settings.at(DecorantSettings.class, worldX, worldZ);
+ if (entries.isEmpty()) {
+ return null;
+ }
+ Entry entry = entries.getLast();
+ return new DecoratedBiome(biomeKey(entry.source()), entry.value(), kind);
+ }
+
/** The log of the module that decorates, which the decorators write to. */
ModuleLog log() {
return log;
}
/** Whether the biome declares any decorator. */
- public boolean hasDecorators(IrisBiome biome) {
- DecorantSettings settings = settingsOf(biome);
- return settings != null && !settings.decorators().isEmpty();
+ public boolean hasDecorators(DecoratedBiome biome) {
+ return biome != null && biome.settings() != null && !biome.settings().decorators().isEmpty();
}
/** The biome's decorators for {@code part}, in the order the biome lists them. */
- ResolvedDecorator[] decorators(IrisBiome biome, DecorationPart part) {
- DecorantSettings settings = settingsOf(biome);
- if (settings == null) {
+ ResolvedDecorator[] decorators(DecoratedBiome biome, DecorationPart part) {
+ if (biome == null || biome.settings() == null) {
return NO_DECORATORS;
}
- return decorators.computeIfAbsent(settings, declared -> resolve(biome.getLoadKey(), declared)).getOrDefault(part, NO_DECORATORS);
+ return decorators.computeIfAbsent(biome.settings(), declared -> resolve(biome.key(), declared)).getOrDefault(part, NO_DECORATORS);
}
/** Whether the biome has a decorator for {@code part}. */
- public boolean hasDecorators(IrisBiome biome, DecorationPart part) {
+ public boolean hasDecorators(DecoratedBiome biome, DecorationPart part) {
return decorators(biome, part).length > 0;
}
/** Resolves every decorator of every biome the dimension reaches and builds its noise, so that generation finds them ready. */
public void warm() {
- List biomes = engine.getAllBiomes();
- biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
- for (IrisBiome biome : biomes) {
+ List> declared = new ArrayList<>(world.settings().declared(DecorantSettings.class));
+ declared.sort(Comparator.comparing(entry -> biomeKey(entry.source())));
+ for (Entry entry : declared) {
+ DecoratedBiome biome = new DecoratedBiome(biomeKey(entry.source()), entry.value(), null);
for (DecorationPart part : DecorationPart.values()) {
for (ResolvedDecorator decorator : decorators(biome, part)) {
decorator.warm();
@@ -115,53 +120,6 @@ public final class BiomeDecorators {
}
}
- /** The most decorating any reachable biome does, as the sum of its decorators' chances times their stack heights. */
- public double busiestBiomeLoad() {
- Double cached = busiestBiomeLoad;
- if (cached != null) {
- return cached;
- }
-
- double busiest = 0D;
- for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) {
- busiest = Math.max(busiest, load(biome));
- }
- busiestBiomeLoad = busiest;
- return busiest;
- }
-
- /** How loaded the biome is with decorators: the sum of their chances times their stack heights, at least one block each. */
- public double load(IrisBiome biome) {
- DecorantSettings settings = settingsOf(biome);
- if (settings == null) {
- return 0D;
- }
-
- double load = 0D;
- for (Decorator decorator : settings.decorators()) {
- load += Math.max(decorator.stackMax(), 1) * decorator.chance();
- }
- return load;
- }
-
- /** How strongly studio's decorator load view colours the biome: the sum of its decorators' chances over a chunk's columns. */
- public double colourLoad(IrisBiome biome) {
- DecorantSettings settings = settingsOf(biome);
- if (settings == null) {
- return 0D;
- }
-
- double load = 0D;
- for (Decorator decorator : settings.decorators()) {
- load += decorator.chance() * Math.min(1, decorator.stackMax()) * COLUMNS_PER_CHUNK;
- }
- return load;
- }
-
- private static DecorantSettings settingsOf(IrisBiome biome) {
- return biome.getModuleSettings().find(DecorantSettings.class).orElse(null);
- }
-
private Map resolve(String biomeKey, DecorantSettings settings) {
Map> staging = new EnumMap<>(DecorationPart.class);
List declared = settings.decorators();
@@ -170,7 +128,7 @@ public final class BiomeDecorators {
if (decorator == null) {
continue;
}
- ResolvedDecorator resolved = ResolvedDecorator.of(decorator, engine, decoratorSeed(biomeKey, index), log);
+ ResolvedDecorator resolved = ResolvedDecorator.of(decorator, resources, seedOf(biomeKey, index), log, biomeKey);
staging.computeIfAbsent(decorator.partOf(), part -> new ArrayList<>()).add(resolved);
}
@@ -179,7 +137,7 @@ public final class BiomeDecorators {
return buckets;
}
- private long decoratorSeed(String biomeKey, int index) {
- return engine.getSeedManager().getDecorator() + (biomeKey.hashCode() * KEY_SEED_FACTOR) + (index * INDEX_SEED_FACTOR);
+ private long seedOf(String biomeKey, int index) {
+ return decoratorSeed + (biomeKey.hashCode() * KEY_SEED_FACTOR) + (index * INDEX_SEED_FACTOR);
}
}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/DecoratedBiome.java b/src/main/java/art/arcane/iris/engine/decorator/DecoratedBiome.java
new file mode 100644
index 000000000..2bad9d80c
--- /dev/null
+++ b/src/main/java/art/arcane/iris/engine/decorator/DecoratedBiome.java
@@ -0,0 +1,28 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.engine.decorator;
+
+import art.arcane.iris.builtin.decorant.DecorantSettings;
+import com.volmit.world.BiomeKind;
+
+/**
+ * A biome as the decorators see it: the key the pack names it by, which seeds its decorators' noise, the decorators it declares
+ * (none when it declares no {@link DecorantSettings}) and what it was generated as.
+ */
+public record DecoratedBiome(String key, DecorantSettings settings, BiomeKind kind) {
+}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java b/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java
new file mode 100644
index 000000000..7df79fdc1
--- /dev/null
+++ b/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java
@@ -0,0 +1,149 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.engine.decorator;
+
+import art.arcane.iris.builtin.IrisSeed;
+import com.volmit.ModuleLog;
+import com.volmit.block.BlockRegistry;
+import com.volmit.block.BlockState;
+import com.volmit.block.BlockTrait;
+import com.volmit.hunk.Hunk;
+import com.volmit.mantle.Mantle;
+import com.volmit.mantle.MantleLayer;
+import com.volmit.stage.ChunkStageContext;
+import com.volmit.world.TerrainSampler;
+
+import java.util.EnumMap;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
+/**
+ * Everything the decorators of one chunk look at: its blocks, the blocks the mantle planned around it, the terrain, the pack's
+ * block rules and the biomes' decorators. A decorator places into {@link #blocks()} only. What it asks of a block is asked
+ * once for each distinct block instance, since a chunk holds few.
+ */
+public final class DecorationScene {
+ private final Hunk blocks;
+ private final BlockRegistry registry;
+ private final TerrainSampler terrain;
+ private final MantleLayer planned;
+ private final BiomeDecorators decorators;
+ private final long seed;
+ private final ModuleLog log;
+ private final Map> traits = new EnumMap<>(BlockTrait.class);
+ private final Map> supports = new IdentityHashMap<>();
+
+ /** The chunk of {@code context}, decorated with the world's decorators. */
+ public static DecorationScene of(ChunkStageContext context) {
+ Mantle mantle = context.mantle();
+ return new DecorationScene(context.hunk(BlockState.class), context.resources().blocks(), context.terrain(),
+ mantle == null ? null : mantle.blocks(), BiomeDecorators.of(context.world()), IrisSeed.COMPONENT.of(context.world()),
+ context.log());
+ }
+
+ public DecorationScene(Hunk blocks, BlockRegistry registry, TerrainSampler terrain, MantleLayer planned,
+ BiomeDecorators decorators, long seed, ModuleLog log) {
+ this.blocks = blocks;
+ this.registry = registry;
+ this.terrain = terrain;
+ this.planned = planned;
+ this.decorators = decorators;
+ this.seed = seed;
+ this.log = log;
+ }
+
+ public Hunk blocks() {
+ return blocks;
+ }
+
+ public BlockRegistry registry() {
+ return registry;
+ }
+
+ public TerrainSampler terrain() {
+ return terrain;
+ }
+
+ public BiomeDecorators decorators() {
+ return decorators;
+ }
+
+ /** The seed the decorators of every place draw from, each shifted by its own part. */
+ long seed() {
+ return seed;
+ }
+
+ ModuleLog log() {
+ return log;
+ }
+
+ /** The height of the chunk's volume. */
+ public int worldHeight() {
+ return blocks.getHeight();
+ }
+
+ public int fluidHeight() {
+ return terrain.fluidHeight();
+ }
+
+ /** The slope of the terrain at the column. */
+ double slopeAt(int worldX, int worldZ) {
+ return terrain.column(worldX, worldZ).slope();
+ }
+
+ /** The height of the terrain at the column, rounded. */
+ long roundedHeightAt(int worldX, int worldZ) {
+ return Math.round(terrain.surfaceY(worldX, worldZ));
+ }
+
+ /** The block a placement planned at the position, or air; positions the mantle does not cover read as air. */
+ BlockState plannedAt(int worldX, int y, int worldZ) {
+ if (planned == null || y < 0 || y >= worldHeight()) {
+ return null;
+ }
+ return planned.get(worldX, y, worldZ);
+ }
+
+ boolean has(BlockTrait trait, BlockState block) {
+ return traits.computeIfAbsent(trait, ignored -> new IdentityHashMap<>())
+ .computeIfAbsent(block, known -> registry.hasTrait(known, trait));
+ }
+
+ public boolean isAir(BlockState block) {
+ return has(BlockTrait.AIR, block);
+ }
+
+ public boolean isFluid(BlockState block) {
+ return has(BlockTrait.FLUID, block);
+ }
+
+ public boolean isSolid(BlockState block) {
+ return has(BlockTrait.SOLID, block);
+ }
+
+ public boolean isWater(BlockState block) {
+ return has(BlockTrait.WATER, block);
+ }
+
+ /** Whether {@code decoration} may stand on {@code surface}: its kind of block on that kind of block, and the surface carries a block on its top face. */
+ boolean canGoOn(BlockState decoration, BlockState surface) {
+ return supports.computeIfAbsent(decoration, ignored -> new IdentityHashMap<>())
+ .computeIfAbsent(surface, known -> registry.canPlaceOn(decoration, known)
+ && registry.canAttach(decoration, known, com.volmit.block.BlockFace.UP));
+ }
+}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/DecoratorCore.java b/src/main/java/art/arcane/iris/engine/decorator/DecoratorCore.java
index 26fc4aa2a..0dee08c3f 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/DecoratorCore.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/DecoratorCore.java
@@ -1,6 +1,6 @@
/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ * 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
@@ -15,35 +15,41 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.decorator;
import art.arcane.iris.builtin.decorant.DecorationPart;
-import art.arcane.iris.engine.mantle.EngineMantle;
-import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
-import art.arcane.iris.platform.bukkit.BukkitBlockState;
-import art.arcane.iris.spi.PlatformBlockState;
-import art.arcane.iris.util.common.data.B;
-import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.ModuleLog;
-import org.bukkit.block.BlockFace;
-import org.bukkit.block.BlockSupport;
-import org.bukkit.block.data.BlockData;
-import org.bukkit.block.data.MultipleFacing;
+import com.volmit.block.BlockFace;
+import com.volmit.block.BlockState;
+import com.volmit.block.BlockTrait;
+import com.volmit.hunk.Hunk;
+import com.volmit.resource.ResourceId;
+
+import java.util.List;
+import java.util.Map;
final class DecoratorCore {
private static final long SEED_OFFSET = 29356788L;
private static final long PART_FACTOR = 10439677L;
- private static final String WEEPING_VINES = "minecraft:weeping_vines";
- private static final String WEEPING_VINES_PLANT = "minecraft:weeping_vines_plant";
- private static final String TWISTING_VINES = "minecraft:twisting_vines";
- private static final String TWISTING_VINES_PLANT = "minecraft:twisting_vines_plant";
- private static volatile PlatformBlockState weepingVines;
- private static volatile PlatformBlockState weepingVinesPlant;
- private static volatile PlatformBlockState twistingVines;
- private static volatile PlatformBlockState twistingVinesPlant;
+ private static final String HALF = "half";
+ private static final ResourceId WEEPING_VINES = ResourceId.parse("minecraft:weeping_vines");
+ private static final ResourceId WEEPING_VINES_PLANT = ResourceId.parse("minecraft:weeping_vines_plant");
+ private static final ResourceId TWISTING_VINES = ResourceId.parse("minecraft:twisting_vines");
+ private static final ResourceId TWISTING_VINES_PLANT = ResourceId.parse("minecraft:twisting_vines_plant");
+ private static final ResourceId POINTED_DRIPSTONE = ResourceId.parse("minecraft:pointed_dripstone");
+ private static final String[] DRIPSTONE_THICKNESS = {"tip", "frustum", "base"};
+ private static final BlockState[] DRIPSTONE_UP = dripstones("up");
+ private static final BlockState[] DRIPSTONE_DOWN = dripstones("down");
+ private static final BlockState AIR = new BlockState("minecraft:air");
+ /** The faces a vine can grow on, in the order Iris looks at them, with the neighbour each faces. */
+ private static final List FACES = List.of(new Face(BlockFace.NORTH, "north", 0, 0, -1), new Face(BlockFace.EAST, "east", 1, 0, 0),
+ new Face(BlockFace.SOUTH, "south", 0, 0, 1), new Face(BlockFace.WEST, "west", -1, 0, 0), new Face(BlockFace.UP, "up", 0, 1, 0),
+ new Face(BlockFace.DOWN, "down", 0, -1, 0));
+ private static final Map OPPOSITES = Map.of(BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH, BlockFace.NORTH,
+ BlockFace.EAST, BlockFace.WEST, BlockFace.WEST, BlockFace.EAST, BlockFace.UP, BlockFace.DOWN, BlockFace.DOWN, BlockFace.UP);
+ private static final int CHUNK_LAST = 15;
static final ThreadLocal SCRATCH_OPTS = ThreadLocal.withInitial(PlaceOpts::new);
@@ -59,6 +65,9 @@ final class DecoratorCore {
}
}
+ private record Face(BlockFace face, String property, int dx, int dy, int dz) {
+ }
+
static long partSeed(long baseSeed, int partOrdinal) {
return baseSeed + SEED_OFFSET - (partOrdinal * PART_FACTOR);
}
@@ -96,77 +105,75 @@ final class DecoratorCore {
return half.equals("upper") || half.equals("lower") ? "lower" : "bottom";
}
- static void placeSurfaceSingle(ResolvedDecorator decorator,
+ static void placeSurfaceSingle(ResolvedDecorator decorator, DecorationScene scene,
int x, int z, int realX, int height, int realZ,
- Hunk data,
- boolean underwater, boolean caveSkipFluid, EngineMantle mantle, ModuleLog log) {
+ boolean underwater, boolean caveSkipFluid) {
+ Hunk data = scene.blocks();
if (height < 0 || height >= data.getHeight()) {
return;
}
- PlatformBlockState bdx = data.get(x, height, z);
- PlatformBlockState bd = decorator.pickBlock(realX, realZ);
+ BlockState bdx = data.get(x, height, z);
+ BlockState bd = decorator.pickBlock(realX, realZ);
- if (!underwater && !canGoOn(bd, bdx)
+ if (!underwater && !canGoOn(scene, bd, bdx)
&& !decorator.isForcePlace() && decorator.forceBlock() == null) {
return;
}
if (decorator.forceBlock() != null) {
- if (caveSkipFluid && B.isFluid(bdx)) {
+ if (caveSkipFluid && scene.isFluid(bdx)) {
return;
}
- data.set(x, height, z, fixFacesForHunk(
- decorator.forceBlock(), data, x, z, realX, height, realZ, mantle));
+ data.set(x, height, z, fixFacesForHunk(scene, decorator.forceBlock(), x, z, realX, height, realZ));
}
if (!decorator.isForcePlace() && decorator.rejectsSurface(bdx)) {
return;
}
- String half = bd == null ? null : IrisProceduralBlocks.propertyValue(bd, "half");
+ String half = bd == null ? null : bd.properties().get(HALF);
if (half != null) {
int lowerY = height + 1;
int upperY = height + 2;
- if (!canPlaceTwoBlockPlant(data, x, z, lowerY, upperY, caveSkipFluid)) {
+ if (!canPlaceTwoBlockPlant(scene, x, z, lowerY, upperY, caveSkipFluid)) {
return;
}
try {
- PlatformBlockState upper = bd.withProperty("half", topHalfValue(half));
- PlatformBlockState lower = fixFacesForHunk(
- bd.withProperty("half", bottomHalfValue(half)),
- data, x, z, realX, lowerY, realZ, mantle);
+ BlockState upper = bd.withProperty(HALF, topHalfValue(half));
+ BlockState lower = fixFacesForHunk(scene,
+ bd.withProperty(HALF, bottomHalfValue(half)),
+ x, z, realX, lowerY, realZ);
data.set(x, lowerY, z, lower);
data.set(x, upperY, z, upper);
} catch (Throwable e) {
- log.error("Failed to place a two-block plant", e);
+ scene.log().error("Failed to place a two-block plant", e);
}
return;
}
int targetY = height + 1;
- if (targetY < data.getHeight() && B.isAir(data.get(x, targetY, z))) {
- data.set(x, targetY, z, fixFacesForHunk(bd, data, x, z, realX, targetY, realZ, mantle));
+ if (bd != null && targetY < data.getHeight() && scene.isAir(data.get(x, targetY, z))) {
+ data.set(x, targetY, z, fixFacesForHunk(scene, bd, x, z, realX, targetY, realZ));
}
}
- static void placeSingleAt(ResolvedDecorator decorator, int x, int z,
- int realX, int height, int realZ, Hunk data,
- boolean applyFixFaces, EngineMantle mantle) {
- PlatformBlockState bd = decorator.pickBlock(realX, realZ);
+ static void placeSingleAt(ResolvedDecorator decorator, DecorationScene scene, int x, int z,
+ int realX, int height, int realZ, boolean applyFixFaces) {
+ BlockState bd = decorator.pickBlock(realX, realZ);
if (bd == null) {
return;
}
if (applyFixFaces) {
- bd = fixFacesForHunk(bd, data, x, z, realX, height, realZ, mantle);
+ bd = fixFacesForHunk(scene, bd, x, z, realX, height, realZ);
}
- data.set(x, height, z, bd);
+ scene.blocks().set(x, height, z, bd);
}
- static void placeStackUp(ResolvedDecorator decorator, int x, int z, int realX, int realZ,
- int height, int max, Hunk data,
- PlaceOpts opts) {
+ static void placeStackUp(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ,
+ int height, int max, PlaceOpts opts) {
+ Hunk data = scene.blocks();
if (height < 0 || height >= data.getHeight()) {
return;
}
@@ -184,14 +191,14 @@ final class DecoratorCore {
return;
}
- PlatformBlockState existing = data.get(x, targetY, z);
- if (!canReplaceStackTarget(existing, opts.underwater)
- || (opts.caveSkipFluid && B.isFluid(existing))) {
+ BlockState existing = data.get(x, targetY, z);
+ if (!canReplaceStackTarget(scene, existing, opts.underwater)
+ || (opts.caveSkipFluid && scene.isFluid(existing))) {
return;
}
- PlatformBlockState block = decorator.pickTopBlock(realX, realZ);
- if (block == null || (!opts.underwater && !canGoOn(block, data.get(x, height, z)))) {
+ BlockState block = decorator.pickTopBlock(realX, realZ);
+ if (block == null || (!opts.underwater && !canGoOn(scene, block, data.get(x, height, z)))) {
return;
}
@@ -200,12 +207,11 @@ final class DecoratorCore {
return;
}
- PlatformBlockState bdx = data.get(x, height, z);
+ BlockState bdx = data.get(x, height, z);
for (int i = 0; i < stack; i++) {
- int h = height + i;
double threshold = ((double) i) / (stack - 1);
- PlatformBlockState bd = threshold >= decorator.topThreshold()
+ BlockState bd = threshold >= decorator.topThreshold()
? decorator.pickTopBlock(realX, realZ)
: decorator.pickBlock(realX, realZ);
@@ -213,7 +219,7 @@ final class DecoratorCore {
break;
}
- if (i == 0 && !opts.underwater && !canGoOn(bd, bdx)) {
+ if (i == 0 && !opts.underwater && !canGoOn(scene, bd, bdx)) {
break;
}
@@ -225,14 +231,14 @@ final class DecoratorCore {
break;
}
- PlatformBlockState existing = data.get(x, height + 1 + i, z);
- if (!canReplaceStackTarget(existing, opts.underwater)
- || (opts.caveSkipFluid && B.isFluid(existing))) {
+ BlockState existing = data.get(x, height + 1 + i, z);
+ if (!canReplaceStackTarget(scene, existing, opts.underwater)
+ || (opts.caveSkipFluid && scene.isFluid(existing))) {
break;
}
- if (IrisProceduralBlocks.materialKey(bd).equals("minecraft:pointed_dripstone")) {
- bd = dripstoneBlock(stack, i, "up");
+ if (bd.material().equals(POINTED_DRIPSTONE)) {
+ bd = dripstoneBlock(stack, i, DRIPSTONE_UP);
}
bd = stackedVineBlock(bd, stack, i);
@@ -240,9 +246,9 @@ final class DecoratorCore {
}
}
- static void placeStackDown(ResolvedDecorator decorator, int x, int z, int realX, int realZ,
- int height, int minHeight, Hunk data,
- int max, PlaceOpts opts, EngineMantle mantle) {
+ static void placeStackDown(ResolvedDecorator decorator, DecorationScene scene, int x, int z, int realX, int realZ,
+ int height, int minHeight, int max, PlaceOpts opts) {
+ Hunk data = scene.blocks();
if (height < 0 || height >= data.getHeight()) {
return;
}
@@ -250,15 +256,15 @@ final class DecoratorCore {
int stack = computeStack(decorator, realX, realZ, max);
if (stack == 1) {
- if (opts.caveSkipFluid && B.isFluid(data.get(x, height, z))) {
+ if (opts.caveSkipFluid && scene.isFluid(data.get(x, height, z))) {
return;
}
- PlatformBlockState block = decorator.pickTopBlock(realX, realZ);
+ BlockState block = decorator.pickTopBlock(realX, realZ);
if (block == null) {
return;
}
block = stackedVineBlock(block, stack, 0);
- data.set(x, height, z, fixFacesForHunk(block, data, x, z, realX, height, realZ, mantle));
+ data.set(x, height, z, fixFacesForHunk(scene, block, x, z, realX, height, realZ));
return;
}
@@ -269,7 +275,7 @@ final class DecoratorCore {
}
double threshold = ((double) i) / (double) (stack - 1);
- PlatformBlockState bd = threshold >= decorator.topThreshold()
+ BlockState bd = threshold >= decorator.topThreshold()
? decorator.pickTopBlock(realX, realZ)
: decorator.pickBlock(realX, realZ);
@@ -277,41 +283,42 @@ final class DecoratorCore {
break;
}
- if (IrisProceduralBlocks.materialKey(bd).equals("minecraft:pointed_dripstone")) {
- bd = dripstoneBlock(stack, i, "down");
+ if (bd.material().equals(POINTED_DRIPSTONE)) {
+ bd = dripstoneBlock(stack, i, DRIPSTONE_DOWN);
}
bd = stackedVineBlock(bd, stack, i);
- if (opts.caveSkipFluid && B.isFluid(data.get(x, h, z))) {
+ if (opts.caveSkipFluid && scene.isFluid(data.get(x, h, z))) {
break;
}
- data.set(x, h, z, fixFacesForHunk(bd, data, x, z, realX, h, realZ, mantle));
+ data.set(x, h, z, fixFacesForHunk(scene, bd, x, z, realX, h, realZ));
}
}
- static void placeFloatingSimple(ResolvedDecorator decorator,
+ static void placeFloatingSimple(ResolvedDecorator decorator, DecorationScene scene,
int xf, int zf, int realX, int realZ,
- int height, int max, Hunk data, ModuleLog log) {
- PlatformBlockState bd = decorator.pickBlock(realX, realZ);
+ int height, int max) {
+ Hunk data = scene.blocks();
+ BlockState bd = decorator.pickBlock(realX, realZ);
if (bd == null) {
return;
}
- String half = IrisProceduralBlocks.propertyValue(bd, "half");
+ String half = bd.properties().get(HALF);
if (half != null) {
int lowerY = height + 1;
int upperY = height + 2;
- if (max <= 2 || !canPlaceTwoBlockPlant(data, xf, zf, lowerY, upperY, false)) {
+ if (max <= 2 || !canPlaceTwoBlockPlant(scene, xf, zf, lowerY, upperY, false)) {
return;
}
try {
- PlatformBlockState upper = bd.withProperty("half", topHalfValue(half));
- PlatformBlockState lower = bd.withProperty("half", bottomHalfValue(half));
+ BlockState upper = bd.withProperty(HALF, topHalfValue(half));
+ BlockState lower = bd.withProperty(HALF, bottomHalfValue(half));
data.set(xf, lowerY, zf, lower);
data.set(xf, upperY, zf, upper);
} catch (Throwable e) {
- log.error("Failed to place a two-block plant", e);
+ scene.log().error("Failed to place a two-block plant", e);
}
return;
}
@@ -321,9 +328,10 @@ final class DecoratorCore {
}
}
- static int placeFloatingStacked(ResolvedDecorator decorator,
+ static int placeFloatingStacked(ResolvedDecorator decorator, DecorationScene scene,
int xf, int zf, int realX, int realZ,
- int height, int max, Hunk data) {
+ int height, int max) {
+ Hunk data = scene.blocks();
int stack = decorator.stackHeight(realX, realZ);
if (decorator.isScaleStack()) {
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.absoluteMaxStack());
@@ -338,7 +346,7 @@ final class DecoratorCore {
break;
}
double threshold = stack == 1 ? 0.0 : ((double) i) / (stack - 1);
- PlatformBlockState bd = threshold >= decorator.topThreshold()
+ BlockState bd = threshold >= decorator.topThreshold()
? decorator.pickTopBlock(realX, realZ)
: decorator.pickBlock(realX, realZ);
if (bd == null) {
@@ -351,94 +359,85 @@ final class DecoratorCore {
return placed;
}
- static PlatformBlockState fixFacesForHunk(PlatformBlockState b, Hunk hunk, int rX, int rZ,
- int x, int y, int z, EngineMantle mantle) {
- if (!B.isVineBlock(b)) {
+ /**
+ * A vine placed at {@code x}, {@code y}, {@code z} (the chunk's local column {@code rX}, {@code rZ}) faces the neighbours that
+ * can hold it: the blocks the mantle planned there, else the chunk's own blocks. A vine with no such neighbour faces down,
+ * or up when it cannot face down. Any other block is returned as it is.
+ */
+ static BlockState fixFacesForHunk(DecorationScene scene, BlockState b, int rX, int rZ, int x, int y, int z) {
+ if (b == null || !scene.has(BlockTrait.VINE, b)) {
return b;
}
- DecoratorPlatformHooks.FaceFixer fixer = DecoratorPlatformHooks.faceFixer();
- if (fixer != null) {
- return fixer.fixFaces(b, hunk, rX, rZ, x, y, z, mantle);
+ Hunk hunk = scene.blocks();
+ BlockState fixed = b;
+ for (Face face : FACES) {
+ if (b.properties().containsKey(face.property())) {
+ fixed = fixed.withProperty(face.property(), "false");
+ }
}
- BlockData rawB = (BlockData) b.nativeHandle();
- BlockData cloned = rawB.clone();
- MultipleFacing data = (MultipleFacing) cloned;
- data.getFaces().forEach(f -> data.setFace(f, false));
boolean found = false;
- for (BlockFace f : BlockFace.values()) {
- if (!f.isCartesian()) {
- continue;
- }
- int yy = y + f.getModY();
+ for (Face face : FACES) {
+ int yy = y + face.dy();
+ BlockFace opposite = OPPOSITES.get(face.face());
- PlatformBlockState rs = null;
- if (mantle != null) {
- rs = mantle.getMantle().get(x + f.getModX(), yy, z + f.getModZ(), PlatformBlockState.class);
- }
- BlockData r = rs == null ? (BlockData) EngineMantle.AIR.nativeHandle() : (BlockData) rs.nativeHandle();
- if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) {
- if (data.getAllowedFaces().contains(f)) {
+ BlockState planned = scene.plannedAt(x + face.dx(), yy, z + face.dz());
+ BlockState support = planned == null ? AIR : planned;
+ if (scene.registry().canAttach(b, support, opposite)) {
+ if (b.properties().containsKey(face.property())) {
found = true;
- data.setFace(f, true);
+ fixed = fixed.withProperty(face.property(), "true");
}
continue;
}
- int xx = rX + f.getModX();
- int zz = rZ + f.getModZ();
- if (xx < 0 || xx > 15 || zz < 0 || zz > 15 || yy < 0 || yy >= hunk.getHeight()) {
+ int xx = rX + face.dx();
+ int zz = rZ + face.dz();
+ if (xx < 0 || xx > CHUNK_LAST || zz < 0 || zz > CHUNK_LAST || yy < 0 || yy >= hunk.getHeight()) {
continue;
}
- r = (BlockData) hunk.get(xx, yy, zz).nativeHandle();
- if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) {
- if (data.getAllowedFaces().contains(f)) {
+ if (scene.registry().canAttach(b, hunk.get(xx, yy, zz), opposite)) {
+ if (b.properties().containsKey(face.property())) {
found = true;
- data.setFace(f, true);
+ fixed = fixed.withProperty(face.property(), "true");
}
}
}
if (!found) {
- BlockFace fallback = data.getAllowedFaces().contains(BlockFace.DOWN) ? BlockFace.DOWN : BlockFace.UP;
- if (data.getAllowedFaces().contains(fallback)) {
- data.setFace(fallback, true);
+ String fallback = b.properties().containsKey("down") ? "down" : "up";
+ if (b.properties().containsKey(fallback)) {
+ fixed = fixed.withProperty(fallback, "true");
}
}
- return BukkitBlockState.of(cloned);
+ return fixed;
}
- static boolean canGoOn(PlatformBlockState decorator, PlatformBlockState surface) {
- if (!B.canPlaceOnto(decorator, surface)) {
- return false;
- }
- DecoratorPlatformHooks.SurfaceSturdiness sturdiness = DecoratorPlatformHooks.surfaceSturdiness();
- if (sturdiness != null) {
- return sturdiness.canGoOn(surface);
- }
- return ((BlockData) surface.nativeHandle()).isFaceSturdy(BlockFace.UP, BlockSupport.FULL);
+ static boolean canGoOn(DecorationScene scene, BlockState decorator, BlockState surface) {
+ return decorator != null && surface != null && scene.canGoOn(decorator, surface);
}
- static boolean isValidShorelineSupport(ResolvedDecorator decorator, PlatformBlockState decorant, PlatformBlockState surface) {
+ static boolean isValidShorelineSupport(DecorationScene scene, ResolvedDecorator decorator, BlockState decorant, BlockState surface) {
return surface != null
- && B.isSolid(surface)
- && (decorator.isForcePlace() || canGoOn(decorant, surface));
+ && scene.isSolid(surface)
+ && (decorator.isForcePlace() || canGoOn(scene, decorant, surface));
}
- static boolean canReplaceStackTarget(PlatformBlockState state, boolean allowFluid) {
- return B.isAir(state) || allowFluid && B.isFluid(state);
+ static boolean canReplaceStackTarget(DecorationScene scene, BlockState state, boolean allowFluid) {
+ return scene.isAir(state) || allowFluid && scene.isFluid(state);
}
- private static boolean canPlaceTwoBlockPlant(Hunk data, int x, int z,
+ private static boolean canPlaceTwoBlockPlant(DecorationScene scene, int x, int z,
int lowerY, int upperY, boolean caveSkipFluid) {
+ Hunk data = scene.blocks();
if (lowerY < 0 || upperY >= data.getHeight()) {
return false;
}
- PlatformBlockState lower = data.get(x, lowerY, z);
- PlatformBlockState upper = data.get(x, upperY, z);
- return B.isAir(lower) && B.isAir(upper)
- && (!caveSkipFluid || !B.isFluid(lower) && !B.isFluid(upper));
+ BlockState lower = data.get(x, lowerY, z);
+ BlockState upper = data.get(x, upperY, z);
+ return scene.isAir(lower) && scene.isAir(upper)
+ && (!caveSkipFluid || !scene.isFluid(lower) && !scene.isFluid(upper));
}
private static int computeStack(ResolvedDecorator decorator, double realX, double realZ, int max) {
@@ -451,19 +450,15 @@ final class DecoratorCore {
return stack;
}
- private static volatile PlatformBlockState[] dripstoneUp;
- private static volatile PlatformBlockState[] dripstoneDown;
-
- private static PlatformBlockState[] buildDripstoneArr(String direction) {
- String[] order = {"tip", "frustum", "base"};
- PlatformBlockState[] arr = new PlatformBlockState[3];
- for (int k = 0; k < 3; k++) {
- arr[k] = B.getState("minecraft:pointed_dripstone[thickness=" + order[k] + ",vertical_direction=" + direction + "]");
+ private static BlockState[] dripstones(String direction) {
+ BlockState[] arr = new BlockState[DRIPSTONE_THICKNESS.length];
+ for (int k = 0; k < arr.length; k++) {
+ arr[k] = BlockState.parse("minecraft:pointed_dripstone[thickness=" + DRIPSTONE_THICKNESS[k] + ",vertical_direction=" + direction + "]");
}
return arr;
}
- private static PlatformBlockState dripstoneBlock(int stack, int i, String direction) {
+ private static BlockState dripstoneBlock(int stack, int i, BlockState[] byThickness) {
int thIdx;
if (i == stack - 1) {
thIdx = 0;
@@ -472,39 +467,24 @@ final class DecoratorCore {
} else {
thIdx = 2;
}
- if (direction.equals("up")) {
- if (dripstoneUp == null) {
- dripstoneUp = buildDripstoneArr("up");
- }
- return dripstoneUp[thIdx];
- }
- if (dripstoneDown == null) {
- dripstoneDown = buildDripstoneArr("down");
- }
- return dripstoneDown[thIdx];
+ return byThickness[thIdx];
}
- static String stackedVineKey(PlatformBlockState state, int stack, int index) {
- String material = IrisProceduralBlocks.materialKey(state);
+ /** The key of the vine block that fills a stack of vines at {@code index}: the tip at the end, the plant before it; null for other blocks. */
+ static ResourceId stackedVineMaterial(BlockState state, int stack, int index) {
+ ResourceId material = state.material();
boolean tip = index == stack - 1;
- return switch (material) {
- case WEEPING_VINES, WEEPING_VINES_PLANT -> tip ? WEEPING_VINES : WEEPING_VINES_PLANT;
- case TWISTING_VINES, TWISTING_VINES_PLANT -> tip ? TWISTING_VINES : TWISTING_VINES_PLANT;
- default -> null;
- };
+ if (material.equals(WEEPING_VINES) || material.equals(WEEPING_VINES_PLANT)) {
+ return tip ? WEEPING_VINES : WEEPING_VINES_PLANT;
+ }
+ if (material.equals(TWISTING_VINES) || material.equals(TWISTING_VINES_PLANT)) {
+ return tip ? TWISTING_VINES : TWISTING_VINES_PLANT;
+ }
+ return null;
}
- private static PlatformBlockState stackedVineBlock(PlatformBlockState state, int stack, int index) {
- String key = stackedVineKey(state, stack, index);
- if (key == null) {
- return state;
- }
- return switch (key) {
- case WEEPING_VINES -> weepingVines == null ? weepingVines = B.getState(key) : weepingVines;
- case WEEPING_VINES_PLANT -> weepingVinesPlant == null ? weepingVinesPlant = B.getState(key) : weepingVinesPlant;
- case TWISTING_VINES -> twistingVines == null ? twistingVines = B.getState(key) : twistingVines;
- case TWISTING_VINES_PLANT -> twistingVinesPlant == null ? twistingVinesPlant = B.getState(key) : twistingVinesPlant;
- default -> state;
- };
+ private static BlockState stackedVineBlock(BlockState state, int stack, int index) {
+ ResourceId material = stackedVineMaterial(state, stack, index);
+ return material == null ? state : new BlockState(material.toString());
}
}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/DecoratorPlatformHooks.java b/src/main/java/art/arcane/iris/engine/decorator/DecoratorPlatformHooks.java
deleted file mode 100644
index b14f63ab0..000000000
--- a/src/main/java/art/arcane/iris/engine/decorator/DecoratorPlatformHooks.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2026 Arcane Arts (Volmit Software)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package art.arcane.iris.engine.decorator;
-
-import art.arcane.iris.engine.mantle.EngineMantle;
-import art.arcane.iris.spi.PlatformBlockState;
-import art.arcane.iris.util.project.hunk.Hunk;
-
-public final class DecoratorPlatformHooks {
- private static volatile FaceFixer FACE_FIXER = null;
- private static volatile SurfaceSturdiness SURFACE_STURDINESS = null;
-
- private DecoratorPlatformHooks() {
- }
-
- public interface FaceFixer {
- PlatformBlockState fixFaces(PlatformBlockState state, Hunk hunk, int rX, int rZ, int x, int y, int z, EngineMantle mantle);
- }
-
- public interface SurfaceSturdiness {
- boolean canGoOn(PlatformBlockState surface);
- }
-
- public static synchronized Bindings bind(FaceFixer faceFixer, SurfaceSturdiness surfaceSturdiness) {
- Bindings previous = new Bindings(FACE_FIXER, SURFACE_STURDINESS);
- FACE_FIXER = faceFixer;
- SURFACE_STURDINESS = surfaceSturdiness;
- return previous;
- }
-
- public static synchronized void restore(Bindings bindings) {
- FACE_FIXER = bindings.faceFixer();
- SURFACE_STURDINESS = bindings.surfaceSturdiness();
- }
-
- static FaceFixer faceFixer() {
- return FACE_FIXER;
- }
-
- static SurfaceSturdiness surfaceSturdiness() {
- return SURFACE_STURDINESS;
- }
-
- public record Bindings(FaceFixer faceFixer, SurfaceSturdiness surfaceSturdiness) {
- }
-}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/FloatingDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/FloatingDecorator.java
index dac61cbe9..c5c9ec635 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/FloatingDecorator.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/FloatingDecorator.java
@@ -1,6 +1,6 @@
/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ * 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
@@ -15,28 +15,23 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.decorator;
import art.arcane.iris.builtin.decorant.DecorationPart;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
-import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.math.RNG;
-import art.arcane.iris.spi.PlatformBlockState;
/*
* Floating island decoration path. Bypasses all canGoOn, slope, whitelist, and blacklist
- * gating from IrisSurfaceDecorator — the island top IS the biome's designated surface by
+ * gating from IrisSurfaceDecorator: the island top IS the biome's designated surface by
* construction, so those material-compatibility checks are never meaningful here.
*/
public class FloatingDecorator {
- public static int decorateColumn(Engine engine, IrisBiome target, DecorationPart part,
+ public static int decorateColumn(DecorationScene scene, DecoratedBiome target, DecorationPart part,
int xf, int zf, int realX, int realZ,
- int height, int max, Hunk data, RNG rng,
+ int height, int max, RNG rng,
Runnable candidatesNullCallback) {
- BiomeDecorators decorators = BiomeDecorators.of(engine);
+ BiomeDecorators decorators = scene.decorators();
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(target, part), rng, realX, realZ, decorators.log());
if (decorator == null) {
@@ -45,10 +40,10 @@ public class FloatingDecorator {
}
if (!decorator.isStacking()) {
- DecoratorCore.placeFloatingSimple(decorator, xf, zf, realX, realZ, height, max, data, decorators.log());
+ DecoratorCore.placeFloatingSimple(decorator, scene, xf, zf, realX, realZ, height, max);
return max > 1 ? 1 : 0;
}
- return DecoratorCore.placeFloatingStacked(decorator, xf, zf, realX, realZ, height, max, data);
+ return DecoratorCore.placeFloatingStacked(decorator, scene, xf, zf, realX, realZ, height, max);
}
}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/IrisCeilingDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/IrisCeilingDecorator.java
index ed02dcee9..1883d62e3 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/IrisCeilingDecorator.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/IrisCeilingDecorator.java
@@ -1,6 +1,6 @@
/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ * 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
@@ -15,35 +15,20 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.decorator;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.object.world.biome.InferredType;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.builtin.decorant.DecorationPart;
-import art.arcane.iris.util.common.data.B;
-import art.arcane.iris.util.project.hunk.Hunk;
-import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.volmlib.util.math.RNG;
-import art.arcane.iris.spi.PlatformBlockState;
public class IrisCeilingDecorator extends IrisEngineDecorator {
- public IrisCeilingDecorator(Engine engine) {
- super(engine, "Ceiling", DecorationPart.CEILING);
+ public IrisCeilingDecorator(DecorationScene scene) {
+ super(scene, DecorationPart.CEILING);
}
- @BlockCoordinates
@Override
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
- Hunk data, IrisBiome biome, int height, int max) {
- decorate(x, z, realX, realX1, realX_1, realZ, realZ1, realZ_1, data, biome, biome.getInferredType(), height, max);
- }
-
- @BlockCoordinates
- public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
- Hunk data, IrisBiome biome, InferredType inferredType, int height, int max) {
- boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(inferredType);
+ DecoratedBiome biome, int height, int max) {
+ boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(biome.kind());
RNG rng = getRNG(realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
@@ -52,19 +37,16 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
}
if (!decorator.isStacking()) {
- if (caveSkipFluid) {
- PlatformBlockState state = data.get(x, height, z);
- if (B.isFluid(state)) {
- return;
- }
+ if (caveSkipFluid && scene.isFluid(scene.blocks().get(x, height, z))) {
+ return;
}
- DecoratorCore.placeSingleAt(decorator, x, z, realX, height, realZ, data, true, getEngine().getMantle());
+ DecoratorCore.placeSingleAt(decorator, scene, x, z, realX, height, realZ, true);
return;
}
DecoratorCore.PlaceOpts opts = DecoratorCore.SCRATCH_OPTS.get();
opts.reset();
opts.caveSkipFluid = caveSkipFluid;
- DecoratorCore.placeStackDown(decorator, x, z, realX, realZ, height, 0, data, max, opts, getEngine().getMantle());
+ DecoratorCore.placeStackDown(decorator, scene, x, z, realX, realZ, height, 0, max, opts);
}
}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/IrisEngineDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/IrisEngineDecorator.java
index 5c07087a6..a34881b2e 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/IrisEngineDecorator.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/IrisEngineDecorator.java
@@ -1,6 +1,6 @@
/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ * 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
@@ -15,33 +15,49 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.decorator;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.framework.EngineAssignedComponent;
-import art.arcane.iris.engine.framework.EngineDecorator;
import art.arcane.iris.builtin.decorant.DecorationPart;
-import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.volmlib.util.math.RNG;
-import lombok.Getter;
-public abstract class IrisEngineDecorator extends EngineAssignedComponent implements EngineDecorator {
- @Getter
+/** A decorator of one kind of place, placing into the blocks of a {@link DecorationScene}. */
+public abstract class IrisEngineDecorator {
+ private static final long COLUMN_X_FACTOR = 29356788L;
+ private static final long COLUMN_Z_FACTOR = 10439677L;
+ private static final int X_PART_OFFSET = 6;
+ private static final int Z_PART_OFFSET = 1;
+
private final DecorationPart part;
+ protected final DecorationScene scene;
protected final BiomeDecorators decorators;
- public IrisEngineDecorator(Engine engine, String name, DecorationPart part) {
- super(engine, name + " Decorator");
+ protected IrisEngineDecorator(DecorationScene scene, DecorationPart part) {
+ this.scene = scene;
this.part = part;
- this.decorators = BiomeDecorators.of(engine);
+ this.decorators = scene.decorators();
+ }
+
+ public DecorationPart getPart() {
+ return part;
+ }
+
+ /**
+ * Decorates one column. {@code x} and {@code z} are the column in the chunk, {@code realX} and {@code realZ} in the world,
+ * with the world columns next to it on either side; {@code height} is the Y to decorate from and {@code max} how much room
+ * there is.
+ */
+ public abstract void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
+ DecoratedBiome biome, int height, int max);
+
+ /** {@link #decorate} for a decorator that looks at no neighbouring column. */
+ public void decorate(int x, int z, int realX, int realZ, DecoratedBiome biome, int height, int max) {
+ decorate(x, z, realX, realX, realX, realZ, realZ, realZ, biome, height, max);
}
- @BlockCoordinates
protected RNG getRNG(int x, int z) {
- long seed = DecoratorCore.partSeed(getSeed(), part);
- long modX = 29356788L ^ (part.ordinal() + 6);
- long modZ = 10439677L ^ (part.ordinal() + 1);
+ long seed = DecoratorCore.partSeed(scene.seed(), part);
+ long modX = COLUMN_X_FACTOR ^ (part.ordinal() + X_PART_OFFSET);
+ long modZ = COLUMN_Z_FACTOR ^ (part.ordinal() + Z_PART_OFFSET);
return new RNG(x * modX + z * modZ + seed);
}
}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/IrisSeaFloorDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/IrisSeaFloorDecorator.java
index 5f943c85c..61050f085 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/IrisSeaFloorDecorator.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/IrisSeaFloorDecorator.java
@@ -1,6 +1,6 @@
/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ * 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
@@ -15,26 +15,20 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.decorator;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.builtin.decorant.DecorationPart;
-import art.arcane.iris.util.project.hunk.Hunk;
-import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.volmlib.util.math.RNG;
-import art.arcane.iris.spi.PlatformBlockState;
+import com.volmit.block.BlockState;
public class IrisSeaFloorDecorator extends IrisEngineDecorator {
- public IrisSeaFloorDecorator(Engine engine) {
- super(engine, "Sea Floor", DecorationPart.SEA_FLOOR);
+ public IrisSeaFloorDecorator(DecorationScene scene) {
+ super(scene, DecorationPart.SEA_FLOOR);
}
- @BlockCoordinates
@Override
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
- Hunk data, IrisBiome biome, int height, int max) {
+ DecoratedBiome biome, int height, int max) {
RNG rng = getRNG(realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
@@ -42,12 +36,13 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
return;
}
+ var data = scene.blocks();
if (!decorator.isStacking()) {
- if (decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ))) {
+ if (decorator.slopeBlocks(() -> scene.slopeAt(realX, realZ))) {
return;
}
- if (height >= 0 && height < getEngine().getHeight()) {
- data.set(x, height, z, decorator.blockAt(biome, realX, height, realZ));
+ if (height >= 0 && height < scene.worldHeight()) {
+ place(x, height, z, decorator.blockAt(realX, height, realZ));
}
return;
}
@@ -60,20 +55,27 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
}
if (stack == 1) {
- data.set(x, height, z, decorator.topBlockAt(biome, realX, height, realZ));
+ place(x, height, z, decorator.topBlockAt(realX, height, realZ));
return;
}
- int engineHeight = getEngine().getHeight();
+ int engineHeight = scene.worldHeight();
for (int i = 0; i < stack; i++) {
int h = height + i;
if (h > max || h > engineHeight) {
continue;
}
double threshold = ((double) i) / (stack - 1);
- data.set(x, h, z, threshold >= decorator.topThreshold()
- ? decorator.topBlockAt(biome, realX, h, realZ)
- : decorator.blockAt(biome, realX, h, realZ));
+ place(x, h, z, threshold >= decorator.topThreshold()
+ ? decorator.topBlockAt(realX, h, realZ)
+ : decorator.blockAt(realX, h, realZ));
+ }
+ }
+
+ /** A block the decorator has none of leaves the water as it is. */
+ private void place(int x, int y, int z, BlockState block) {
+ if (block != null && y < scene.worldHeight()) {
+ scene.blocks().set(x, y, z, block);
}
}
}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/IrisSeaSurfaceDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/IrisSeaSurfaceDecorator.java
index 89e2f4459..42f7574a2 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/IrisSeaSurfaceDecorator.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/IrisSeaSurfaceDecorator.java
@@ -1,6 +1,6 @@
/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ * 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
@@ -15,26 +15,20 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.decorator;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.builtin.decorant.DecorationPart;
-import art.arcane.iris.util.project.hunk.Hunk;
-import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.volmlib.util.math.RNG;
-import art.arcane.iris.spi.PlatformBlockState;
+import com.volmit.block.BlockState;
public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
- public IrisSeaSurfaceDecorator(Engine engine) {
- super(engine, "Sea Surface", DecorationPart.SEA_SURFACE);
+ public IrisSeaSurfaceDecorator(DecorationScene scene) {
+ super(scene, DecorationPart.SEA_SURFACE);
}
- @BlockCoordinates
@Override
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
- Hunk data, IrisBiome biome, int height, int max) {
+ DecoratedBiome biome, int height, int max) {
RNG rng = getRNG(realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
@@ -42,11 +36,12 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
return;
}
+ var data = scene.blocks();
if (!decorator.isStacking()) {
int targetY = height + 1;
- if (height >= 0 && targetY < getEngine().getHeight()
- && DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
- PlatformBlockState block = decorator.blockAt(biome, realX, height, realZ);
+ if (height >= 0 && targetY < scene.worldHeight()
+ && DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
+ BlockState block = decorator.blockAt(realX, height, realZ);
if (block != null) {
data.set(x, targetY, z, block);
}
@@ -61,29 +56,29 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
if (stack == 1) {
int targetY = height + 1;
- if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
+ if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
return;
}
- PlatformBlockState block = decorator.topBlockAt(biome, realX, height, realZ);
+ BlockState block = decorator.topBlockAt(realX, height, realZ);
if (block != null) {
data.set(x, targetY, z, block);
}
return;
}
- int engineHeight = getEngine().getHeight();
+ int engineHeight = scene.worldHeight();
for (int i = 0; i < stack; i++) {
int h = height + i;
int targetY = h + 1;
if (h >= max || targetY >= engineHeight
- || !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
+ || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
break;
}
double threshold = ((double) i) / (stack - 1);
- PlatformBlockState block = threshold >= decorator.topThreshold()
- ? decorator.topBlockAt(biome, realX, h, realZ)
- : decorator.blockAt(biome, realX, h, realZ);
+ BlockState block = threshold >= decorator.topThreshold()
+ ? decorator.topBlockAt(realX, h, realZ)
+ : decorator.blockAt(realX, h, realZ);
if (block == null) {
break;
}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/IrisShoreLineDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/IrisShoreLineDecorator.java
index 944cf0213..667807d2e 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/IrisShoreLineDecorator.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/IrisShoreLineDecorator.java
@@ -1,6 +1,6 @@
/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ * 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
@@ -15,37 +15,29 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.decorator;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.builtin.decorant.DecorationPart;
-import art.arcane.iris.util.project.hunk.Hunk;
-import art.arcane.iris.util.project.stream.ProceduralStream;
-import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.volmlib.util.math.RNG;
-import art.arcane.iris.spi.PlatformBlockState;
+import com.volmit.block.BlockState;
public class IrisShoreLineDecorator extends IrisEngineDecorator {
- public IrisShoreLineDecorator(Engine engine) {
- super(engine, "Shore Line", DecorationPart.SHORE_LINE);
+ public IrisShoreLineDecorator(DecorationScene scene) {
+ super(scene, DecorationPart.SHORE_LINE);
}
- @BlockCoordinates
@Override
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
- Hunk data, IrisBiome biome, int height, int max) {
- if (height != getDimension().getFluidHeight()) {
+ DecoratedBiome biome, int height, int max) {
+ if (height != scene.fluidHeight()) {
return;
}
- double complexFluidHeight = getComplex().getFluidHeight();
- ProceduralStream heightStream = getComplex().getHeightStream();
- if (Math.round(heightStream.get(realX1, realZ)) >= complexFluidHeight
- && Math.round(heightStream.get(realX_1, realZ)) >= complexFluidHeight
- && Math.round(heightStream.get(realX, realZ1)) >= complexFluidHeight
- && Math.round(heightStream.get(realX, realZ_1)) >= complexFluidHeight) {
+ double complexFluidHeight = scene.fluidHeight();
+ if (scene.roundedHeightAt(realX1, realZ) >= complexFluidHeight
+ && scene.roundedHeightAt(realX_1, realZ) >= complexFluidHeight
+ && scene.roundedHeightAt(realX, realZ1) >= complexFluidHeight
+ && scene.roundedHeightAt(realX, realZ_1) >= complexFluidHeight) {
return;
}
@@ -56,23 +48,24 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
return;
}
- if (decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ))) {
+ if (decorator.slopeBlocks(() -> scene.slopeAt(realX, realZ))) {
return;
}
- PlatformBlockState support = data.get(x, height, z);
- if (support == null || !support.isSolid()) {
+ var data = scene.blocks();
+ BlockState support = data.get(x, height, z);
+ if (support == null || !scene.isSolid(support)) {
return;
}
if (!decorator.isStacking()) {
int targetY = height + 1;
if (targetY >= data.getHeight()
- || !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
+ || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
return;
}
- PlatformBlockState block = decorator.blockAt(biome, realX, height, realZ);
- if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
+ BlockState block = decorator.blockAt(realX, height, realZ);
+ if (block != null && DecoratorCore.isValidShorelineSupport(scene, decorator, block, support)) {
data.set(x, targetY, z, block);
}
return;
@@ -87,12 +80,12 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
if (stack == 1) {
int targetY = height + 1;
- if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
+ if (targetY >= data.getHeight() || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
return;
}
- PlatformBlockState block = decorator.topBlockAt(biome, realX, height, realZ);
- if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
+ BlockState block = decorator.topBlockAt(realX, height, realZ);
+ if (block != null && DecoratorCore.isValidShorelineSupport(scene, decorator, block, support)) {
data.set(x, targetY, z, block);
}
return;
@@ -102,17 +95,17 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
int h = height + i;
int targetY = h + 1;
if (targetY >= data.getHeight()
- || !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
+ || !DecoratorCore.canReplaceStackTarget(scene, data.get(x, targetY, z), false)) {
break;
}
double threshold = ((double) i) / (stack - 1);
- PlatformBlockState block = threshold >= decorator.topThreshold()
- ? decorator.topBlockAt(biome, realX, h, realZ)
- : decorator.blockAt(biome, realX, h, realZ);
+ BlockState block = threshold >= decorator.topThreshold()
+ ? decorator.topBlockAt(realX, h, realZ)
+ : decorator.blockAt(realX, h, realZ);
if (block == null) {
break;
}
- if (i == 0 && !DecoratorCore.isValidShorelineSupport(decorator, block, support)) {
+ if (i == 0 && !DecoratorCore.isValidShorelineSupport(scene, decorator, block, support)) {
break;
}
data.set(x, targetY, z, block);
diff --git a/src/main/java/art/arcane/iris/engine/decorator/IrisSurfaceDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/IrisSurfaceDecorator.java
index 296d5e533..041a13731 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/IrisSurfaceDecorator.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/IrisSurfaceDecorator.java
@@ -1,6 +1,6 @@
/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ * 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
@@ -15,48 +15,32 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.decorator;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.object.world.biome.InferredType;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.builtin.decorant.DecorationPart;
-import art.arcane.iris.util.project.hunk.Hunk;
-import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.volmlib.util.math.RNG;
-import art.arcane.iris.spi.PlatformBlockState;
+import com.volmit.world.BiomeKind;
public class IrisSurfaceDecorator extends IrisEngineDecorator {
- public IrisSurfaceDecorator(Engine engine) {
- super(engine, "Surface", DecorationPart.NONE);
- }
-
- protected IrisSurfaceDecorator(Engine engine, String name) {
- super(engine, name, DecorationPart.NONE);
+ public IrisSurfaceDecorator(DecorationScene scene) {
+ super(scene, DecorationPart.NONE);
}
protected boolean isSlopeValid(ResolvedDecorator decorator, int realX, int realZ) {
- return !decorator.slopeBlocks(() -> getComplex().getSlopeStream().get(realX, realZ));
+ return !decorator.slopeBlocks(() -> scene.slopeAt(realX, realZ));
}
- @BlockCoordinates
@Override
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
- Hunk data, IrisBiome biome, int height, int max) {
- decorate(x, z, realX, realX1, realX_1, realZ, realZ1, realZ_1, data, biome, biome.getInferredType(), height, max);
- }
-
- @BlockCoordinates
- public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1,
- Hunk data, IrisBiome biome, InferredType inferredType, int height, int max) {
- int fluidHeight = getDimension().getFluidHeight();
- if (inferredType == InferredType.SHORE && height < fluidHeight) {
+ DecoratedBiome biome, int height, int max) {
+ BiomeKind kind = biome.kind();
+ int fluidHeight = scene.fluidHeight();
+ if (kind == BiomeKind.SHORE && height < fluidHeight) {
return;
}
- boolean underwater = isUnderwater(inferredType, height, fluidHeight);
- boolean caveSkipFluid = skipsFluid(inferredType);
+ boolean underwater = isUnderwater(kind, height, fluidHeight);
+ boolean caveSkipFluid = skipsFluid(kind);
RNG rng = getRNG(realX, realZ);
ResolvedDecorator decorator = DecoratorCore.pickDecorator(decorators.decorators(biome, getPart()), rng, realX, realZ, decorators.log());
@@ -70,19 +54,18 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
opts.underwater = underwater;
opts.fluidHeight = fluidHeight;
opts.caveSkipFluid = caveSkipFluid;
- DecoratorCore.placeStackUp(decorator, x, z, realX, realZ, height, max, data, opts);
+ DecoratorCore.placeStackUp(decorator, scene, x, z, realX, realZ, height, max, opts);
return;
}
- DecoratorCore.placeSurfaceSingle(decorator, x, z, realX, height, realZ,
- data, underwater, caveSkipFluid, getEngine().getMantle(), decorators.log());
+ DecoratorCore.placeSurfaceSingle(decorator, scene, x, z, realX, height, realZ, underwater, caveSkipFluid);
}
- static boolean isUnderwater(InferredType inferredType, int height, int fluidHeight) {
- return height < fluidHeight && inferredType != InferredType.CAVE;
+ static boolean isUnderwater(BiomeKind kind, int height, int fluidHeight) {
+ return height < fluidHeight && kind != BiomeKind.CAVE;
}
- static boolean skipsFluid(InferredType inferredType) {
- return inferredType == InferredType.CAVE;
+ static boolean skipsFluid(BiomeKind kind) {
+ return kind == BiomeKind.CAVE;
}
}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/ResolvedDecorator.java b/src/main/java/art/arcane/iris/engine/decorator/ResolvedDecorator.java
index f5166ba37..b9e19e593 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/ResolvedDecorator.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/ResolvedDecorator.java
@@ -21,22 +21,20 @@ package art.arcane.iris.engine.decorator;
import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.builtin.decorant.Decorator;
import art.arcane.volmlib.util.cache.AtomicCache;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
-import art.arcane.iris.spi.PlatformBlockState;
-import art.arcane.iris.util.common.data.B;
import com.volmit.ModuleLog;
import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockSpec;
+import com.volmit.block.BlockState;
import com.volmit.noise.NoiseFactory;
import com.volmit.noise.NoiseSampler;
+import com.volmit.resource.PackResources;
import java.util.ArrayList;
import java.util.List;
import java.util.function.DoubleSupplier;
/**
- * One {@link Decorator} made ready for one world: its palettes resolved to the platform's blocks, and the noise that
+ * One {@link Decorator} made ready for one world: its palettes resolved to blocks, and the noise that
* decides where it places, which block of the palette it picks and how tall it stacks, built when first asked for. What
* the decorator describes stays in the settings; everything that needs the platform, the pack or the world seed is here.
*
@@ -47,17 +45,18 @@ final class ResolvedDecorator {
private final Decorator settings;
private final long seed;
private final NoiseFactory noise;
- private final List blocks;
- private final List topBlocks;
- private final PlatformBlockState[] blockArray;
- private final PlatformBlockState[] topBlockArray;
- private final PlatformBlockState forceBlock;
- private final PlatformBlockState[] whitelist;
- private final PlatformBlockState[] blacklist;
+ private final List blocks;
+ private final List topBlocks;
+ private final BlockState[] blockArray;
+ private final BlockState[] topBlockArray;
+ private final BlockState forceBlock;
+ private final BlockState[] whitelist;
+ private final BlockState[] blacklist;
private final AtomicCache chanceNoise = new AtomicCache<>();
private final AtomicCache varianceNoise = new AtomicCache<>();
private final AtomicCache heightNoise = new AtomicCache<>();
private final ModuleLog log;
+ private final String biomeKey;
/**
* @param blocks the palette as the platform's blocks, each repeated by its weight
@@ -66,43 +65,38 @@ final class ResolvedDecorator {
* @param whitelist the blocks it may only be placed onto; ignored unless the decorator has a whitelist
* @param blacklist the blocks it is never placed onto; ignored unless the decorator has a blacklist
* @param log the log of the module that decorates
+ * @param biomeKey the key of the biome that declares the decorator, which names it in the log
*/
- ResolvedDecorator(Decorator settings, long seed, NoiseFactory noise, List blocks, List topBlocks,
- PlatformBlockState forceBlock, List whitelist, List blacklist,
- ModuleLog log) {
+ ResolvedDecorator(Decorator settings, long seed, NoiseFactory noise, List blocks, List topBlocks,
+ BlockState forceBlock, List whitelist, List blacklist,
+ ModuleLog log, String biomeKey) {
this.settings = settings;
this.seed = seed;
this.noise = noise;
this.blocks = List.copyOf(blocks);
this.topBlocks = List.copyOf(topBlocks);
- this.blockArray = blocks.toArray(new PlatformBlockState[0]);
- this.topBlockArray = topBlocks.toArray(new PlatformBlockState[0]);
+ this.blockArray = blocks.toArray(new BlockState[0]);
+ this.topBlockArray = topBlocks.toArray(new BlockState[0]);
this.forceBlock = forceBlock;
- this.whitelist = whitelist.toArray(new PlatformBlockState[0]);
- this.blacklist = blacklist.toArray(new PlatformBlockState[0]);
+ this.whitelist = whitelist.toArray(new BlockState[0]);
+ this.blacklist = blacklist.toArray(new BlockState[0]);
this.log = log;
+ this.biomeKey = biomeKey;
}
- /** {@code settings} ready for {@code engine}: its blocks resolved through the pack, its noise seeded from {@code seed}. */
- static ResolvedDecorator of(Decorator settings, Engine engine, long seed, ModuleLog log) {
- var resources = engine.getData().getPackResources();
+ /** {@code settings} ready for a world with {@code resources}: its blocks resolved through the pack, its noise seeded from {@code seed}. */
+ static ResolvedDecorator of(Decorator settings, PackResources resources, long seed, ModuleLog log, String biomeKey) {
BlockRegistry registry = resources.blocks();
- PlatformBlockState forced = settings.forceBlock().map(spec -> platformState(registry, spec)).orElse(null);
+ BlockState forced = settings.forceBlock().map(registry::resolve).orElse(null);
return new ResolvedDecorator(settings, seed, resources.noise(), weighted(registry, settings.palette()),
- weighted(registry, settings.topPalette()), forced, each(registry, settings.whitelist()), each(registry, settings.blacklist()), log);
+ weighted(registry, settings.topPalette()), forced, each(registry, settings.whitelist()), each(registry, settings.blacklist()), log,
+ biomeKey);
}
- private static PlatformBlockState platformState(BlockRegistry registry, BlockSpec spec) {
- return B.getState(registry.resolve(spec).key());
- }
-
- private static List weighted(BlockRegistry registry, List palette) {
- List weighted = new ArrayList<>();
+ private static List weighted(BlockRegistry registry, List palette) {
+ List weighted = new ArrayList<>();
for (BlockSpec spec : palette) {
- PlatformBlockState state = platformState(registry, spec);
- if (state == null) {
- continue;
- }
+ BlockState state = registry.resolve(spec);
for (int n = 0; n < spec.weight(); n++) {
weighted.add(state);
}
@@ -110,8 +104,8 @@ final class ResolvedDecorator {
return weighted;
}
- private static List each(BlockRegistry registry, List palette) {
- return palette.stream().map(spec -> platformState(registry, spec)).toList();
+ private static List each(BlockRegistry registry, List palette) {
+ return palette.stream().map(registry::resolve).toList();
}
Decorator settings() {
@@ -148,7 +142,7 @@ final class ResolvedDecorator {
}
/** The block it forces onto the surface instead of the one found there, or null. */
- PlatformBlockState forceBlock() {
+ BlockState forceBlock() {
return forceBlock;
}
@@ -161,15 +155,15 @@ final class ResolvedDecorator {
}
/** Whether the white and black lists keep the decorator off {@code surface}. */
- boolean rejectsSurface(PlatformBlockState surface) {
+ boolean rejectsSurface(BlockState surface) {
if (settings.hasWhitelist() && !matches(whitelist, surface)) {
return true;
}
return settings.hasBlacklist() && matches(blacklist, surface);
}
- private static boolean matches(PlatformBlockState[] palette, PlatformBlockState surface) {
- for (PlatformBlockState state : palette) {
+ private static boolean matches(BlockState[] palette, BlockState surface) {
+ for (BlockState state : palette) {
if (state.equals(surface)) {
return true;
}
@@ -197,9 +191,9 @@ final class ResolvedDecorator {
}
/** The block of the palette at the position, for decorations that fill a column block by block; null when the palette has no block. */
- PlatformBlockState blockAt(IrisBiome biome, double x, double y, double z) {
+ BlockState blockAt(double x, double y, double z) {
if (blocks.isEmpty()) {
- log.warnOnce("decorator-empty:" + biome.getName(), "Empty Block Data for " + biome.getName());
+ log.warnOnce("decorator-empty:" + biomeKey, "Empty Block Data for " + biomeKey);
return null;
}
@@ -211,9 +205,9 @@ final class ResolvedDecorator {
}
/** The top palette's block at the position, or the palette's when there is no top palette; null where the chance noise declines. */
- PlatformBlockState topBlockAt(IrisBiome biome, double x, double y, double z) {
+ BlockState topBlockAt(double x, double y, double z) {
if (topBlocks.isEmpty()) {
- return blockAt(biome, x, y, z);
+ return blockAt(x, y, z);
}
double zoom = settings.style().zoom();
@@ -229,19 +223,19 @@ final class ResolvedDecorator {
}
/** The palette's block for the column, or null when the palette has no block. */
- PlatformBlockState pickBlock(double x, double z) {
+ BlockState pickBlock(double x, double z) {
return pick(blockArray, x, z);
}
/** The top palette's block for the column; the palette's when there is no top palette. */
- PlatformBlockState pickTopBlock(double x, double z) {
+ BlockState pickTopBlock(double x, double z) {
if (topBlockArray.length == 0) {
return pickBlock(x, z);
}
return pick(topBlockArray, x, z);
}
- private PlatformBlockState pick(PlatformBlockState[] palette, double x, double z) {
+ private BlockState pick(BlockState[] palette, double x, double z) {
if (palette.length == 0) {
return null;
}
diff --git a/src/main/java/art/arcane/iris/engine/modifier/DepositClump.java b/src/main/java/art/arcane/iris/engine/modifier/DepositClump.java
new file mode 100644
index 000000000..4f72c2a5a
--- /dev/null
+++ b/src/main/java/art/arcane/iris/engine/modifier/DepositClump.java
@@ -0,0 +1,70 @@
+/*
+ * Iris is a World Generator for Minecraft Servers
+ * Copyright (c) 2026 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package art.arcane.iris.engine.modifier;
+
+import art.arcane.volmlib.util.data.VectorMap;
+import art.arcane.volmlib.util.math.IrisBlockVector;
+import art.arcane.volmlib.util.math.Vector3i;
+import com.volmit.block.BlockState;
+
+/**
+ * The blocks of one deposit clump, around its centre. Blocks are kept in a {@link VectorMap} of positions relative to the centre,
+ * which is how Iris always held a clump, so a clump's blocks come in the same order and a chunk's deposits draw the same random
+ * numbers.
+ */
+final class DepositClump {
+ private final int width;
+ private final int height;
+ private final int depth;
+ private final Vector3i center;
+ private final VectorMap blocks = new VectorMap<>();
+
+ DepositClump(int width, int height, int depth) {
+ this.width = width;
+ this.height = height;
+ this.depth = depth;
+ this.center = new Vector3i(width / 2, height / 2, depth / 2);
+ }
+
+ /** How many blocks wide the clump's box is, along X. */
+ int width() {
+ return width;
+ }
+
+ Vector3i center() {
+ return center;
+ }
+
+ /** The clump's blocks by their position relative to its centre. */
+ VectorMap blocks() {
+ return blocks;
+ }
+
+ /** Puts {@code block} at {@code x}, {@code y}, {@code z} counted from the corner of the clump's box. */
+ void setFromCorner(int x, int y, int z, BlockState block) {
+ if (x >= width || y >= height || z >= depth) {
+ throw new IllegalArgumentException(x + " " + y + " " + z + " exceeds limit of " + width + " " + height + " " + depth);
+ }
+ blocks.put(new IrisBlockVector(x - center.getX(), y - center.getY(), z - center.getZ()), block);
+ }
+
+ /** Puts {@code block} on the centre, which is where a one block clump has its block. */
+ void setCentre(BlockState block) {
+ blocks.put(new IrisBlockVector(center.getX(), center.getY(), center.getZ()), block);
+ }
+}
diff --git a/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java b/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java
index 668755e37..64b521cf8 100644
--- a/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java
+++ b/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java
@@ -24,7 +24,6 @@ import art.arcane.iris.builtin.deposit.DepositSettings;
import art.arcane.iris.builtin.deposit.DepositVariantSettings;
import art.arcane.iris.builtin.deposit.OreFrequencySettings;
import art.arcane.iris.builtin.deposit.OreSizeSettings;
-import art.arcane.iris.core.modules.IrisChunk;
import com.volmit.FeatureRegistry;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
@@ -45,7 +44,6 @@ import java.util.List;
public final class DepositModule implements IrisModule {
private static final String VERSION = "built-in";
private static final int CHUNK_CENTRE = 7;
- private static final int CHUNK_SHIFT = 4;
@Override
public ModuleInfo info() {
@@ -69,13 +67,11 @@ public final class DepositModule implements IrisModule {
}
private static void place(ChunkStageContext context, List> inChunk) {
- IrisChunk chunk = IrisChunk.current();
List generators = generatorsAtCentre(context.settings(), context.originX(), context.originZ());
- if (generators.isEmpty() || chunk.bypassesMantleStages()) {
+ if (generators.isEmpty()) {
return;
}
- chunk.state(DepositPlacer.class, DepositPlacer::new).generate(generators, chunk.blocks(),
- chunk.originX() >> CHUNK_SHIFT, chunk.originZ() >> CHUNK_SHIFT, chunk.multicore(), chunk.context());
+ DepositPlacer.of(context.world()).generate(context, generators);
}
/** Every level's generators at the centre column of the chunk whose first block is {@code originX}, {@code originZ}, in level order. */
diff --git a/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java b/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java
index b5f38119f..f611b34f8 100644
--- a/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java
+++ b/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java
@@ -1,6 +1,6 @@
/*
- * Iris is a World Generator for Minecraft Bukkit Servers
- * Copyright (c) 2022 Arcane Arts (Volmit Software)
+ * 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
@@ -15,9 +15,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
package art.arcane.iris.engine.modifier;
+import art.arcane.iris.builtin.IrisSeed;
import art.arcane.iris.builtin.deposit.DepositGenerator;
import art.arcane.iris.builtin.deposit.DepositHeightDistribution;
import art.arcane.iris.builtin.deposit.DepositPlacementScope;
@@ -25,213 +25,341 @@ import art.arcane.iris.builtin.deposit.DepositVariant;
import art.arcane.iris.builtin.deposit.DepositVariantSettings;
import art.arcane.iris.builtin.deposit.OreFrequencySettings;
import art.arcane.iris.builtin.deposit.OreSizeSettings;
-import art.arcane.iris.core.loader.IrisRegistrant;
-import art.arcane.iris.engine.framework.Engine;
-import art.arcane.iris.engine.framework.EngineAssignedComponent;
-import art.arcane.iris.engine.object.world.biome.IrisBiome;
-import art.arcane.iris.engine.object.world.dimension.IrisDimension;
-import art.arcane.iris.engine.object.prefab.IrisObject;
-import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
-import art.arcane.iris.engine.object.world.region.IrisRegion;
-import art.arcane.iris.util.project.context.ChunkContext;
-import art.arcane.volmlib.util.data.HeightMap;
-import art.arcane.iris.util.project.hunk.Hunk;
-import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
+import art.arcane.iris.engine.modifier.ResolvedDeposit.BiomeIdentity;
+import art.arcane.volmlib.util.math.IrisBlockVector;
import art.arcane.volmlib.util.math.RNG;
-import art.arcane.volmlib.util.matter.MatterCavern;
-import art.arcane.iris.util.common.parallel.BurstExecutor;
-import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
-import art.arcane.iris.spi.PlatformBlockState;
-import art.arcane.iris.util.common.data.B;
+import com.volmit.FeatureAttachment.Target;
+import com.volmit.ModuleLog;
+import com.volmit.block.BlockRegistry;
+import com.volmit.block.BlockState;
+import com.volmit.block.BlockTrait;
+import com.volmit.config.FeatureSettings;
+import com.volmit.config.FeatureSettings.Entry;
+import com.volmit.hunk.Hunk;
+import com.volmit.mantle.MantleLayer;
+import com.volmit.resource.PackResources;
+import com.volmit.resource.ResourceId;
+import com.volmit.resource.ResourceKey;
+import com.volmit.stage.ChunkStageContext;
+import com.volmit.world.BiomeSample;
+import com.volmit.world.PackBiome;
+import com.volmit.world.PackWorld;
+import com.volmit.world.TerrainSampler;
+import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
/**
- * Places deposit clumps into one chunk for {@link DepositModule}: one per engine runtime, holding the deposit
- * stream's random and each generator made ready for this engine ({@link ResolvedDeposit}: resolved blocks and clump
- * shapes). Each generator gets its own random, derived from the chunk and its position in the list.
+ * Places deposit clumps into one chunk for {@link DepositModule}: one per world, holding the deposit stream's random and each
+ * generator made ready for this world ({@link ResolvedDeposit}: resolved blocks and clump shapes). Each generator gets its own
+ * random, derived from the chunk and its position in the list, and the generators of a chunk run one after the other.
*/
-public class DepositPlacer extends EngineAssignedComponent {
- private final RNG rng;
+final class DepositPlacer {
private static final double UNCHANGED_ORE_MULTIPLIER = 1D;
+ private static final int CHUNK_SHIFT = 4;
+ private static final int CHUNK_WIDTH = 16;
+ private static final long CHUNK_X_SEED_FACTOR = 341873128712L;
+ private static final long CHUNK_Z_SEED_FACTOR = 132897987541L;
+ private static final int DEFAULT_SURFACE_CLEARANCE = 7;
+ private static final BlockState BEDROCK = new BlockState("minecraft:bedrock");
+ private final RNG rng;
+ private final BlockRegistry registry;
+ private final PackResources resources;
+ private final ModuleLog log;
+ private final boolean tunesOres;
+ private final boolean remapsOres;
private final Map resolved = new ConcurrentHashMap<>();
private final Map variants = new ConcurrentHashMap<>();
+ private final Map> biomeIdentities = new ConcurrentHashMap<>();
- public DepositPlacer(Engine engine) {
- super(engine, "Deposit");
- rng = new RNG(getEngine().getSeedManager().getDeposit());
+ DepositPlacer(PackWorld world) {
+ this.rng = new RNG(IrisSeed.DEPOSIT.of(world));
+ this.resources = world.resources();
+ this.registry = resources.blocks();
+ this.log = world.log();
+ this.tunesOres = declares(world, OreFrequencySettings.class) || declares(world, OreSizeSettings.class);
+ this.remapsOres = declares(world, DepositVariantSettings.class);
}
- /** Runs {@code generators}, in order, on the chunk at chunk coordinates {@code x}, {@code z}. */
- public void generate(List generators, Hunk terrain, int x, int z, boolean multicore,
- ChunkContext context) {
- PrecisionStopwatch p = PrecisionStopwatch.start();
- generateDeposits(generators, terrain, x, z, multicore, context);
- getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
+ /** The world's deposit placer, kept in its state store. */
+ static DepositPlacer of(PackWorld world) {
+ return world.state(DepositPlacer.class, DepositPlacer::new);
}
- private void generateDeposits(List generators, Hunk terrain, int x, int z,
- boolean multicore, ChunkContext context) {
- BurstExecutor burst = burst().burst(multicore);
+ /** Whether any level of the pack declares {@code settings}; a world that declares none never asks a biome for them. */
+ private static boolean declares(PackWorld world, Class extends com.volmit.IrisFeature> settings) {
+ return !world.settings().declared(settings).isEmpty();
+ }
- long seed = x * 341873128712L + z * 132897987541L;
+ /** Runs {@code generators}, in order, on the chunk of {@code context}. */
+ void generate(ChunkStageContext context, List generators) {
+ Placing placing = new Placing(context);
+ int chunkX = context.originX() >> CHUNK_SHIFT;
+ int chunkZ = context.originZ() >> CHUNK_SHIFT;
+ long seed = chunkX * CHUNK_X_SEED_FACTOR + chunkZ * CHUNK_Z_SEED_FACTOR;
long mask = 0;
- MantleChunk chunk = getEngine().getMantle().getMantle().getChunk(x, z).use();
- try {
- for (DepositGenerator k : generators) {
- long finalSeed = seed * ++mask;
- burst.queue(() -> generate(k, chunk, terrain, rng.nextParallelRNG(finalSeed), x, z, false, context));
- }
- } finally {
- // complete() must run before release() even when queueing throws — already
- // submitted burst tasks must never write into a released chunk.
- try {
- burst.complete();
- } finally {
- chunk.release();
- }
+ for (DepositGenerator generator : generators) {
+ long finalSeed = seed * ++mask;
+ placing.generate(generator, rng.nextParallelRNG(finalSeed));
}
}
- public void generate(DepositGenerator k, MantleChunk chunk, Hunk data, RNG rng, int cx, int cz, boolean safe, ChunkContext context) {
- generate(k, chunk, data, rng, cx, cz, safe, null, context);
+ private ResolvedDeposit resolved(DepositGenerator generator) {
+ return resolved.computeIfAbsent(generator, ignored -> new ResolvedDeposit(generator, rng.getSeed(), registry));
}
- public void generate(DepositGenerator k, MantleChunk chunk, Hunk data, RNG rng, int cx, int cz, boolean safe, HeightMap he, ChunkContext context) {
- ResolvedDeposit deposit = resolved(k);
- if (k.spawnChance() < rng.d())
- return;
+ private Optional identityOf(ResourceId biome) {
+ return biomeIdentities.computeIfAbsent(biome, id -> resources.find(new ResourceKey<>(id, PackBiome.class))
+ .map(found -> new BiomeIdentity(id.path(), found.platformBiome().toString(), found.vanillaBiome().toString())));
+ }
- for (int l = 0; l < rng.i(k.minPerChunk(), k.maxPerChunk() + 1); l++) {
- if (k.perClumpSpawnChance() < rng.d())
- continue;
+ /** Places deposits into one chunk, with the views of its invocation. */
+ private final class Placing {
+ private final Hunk blocks;
+ private final TerrainSampler terrain;
+ private final FeatureSettings settings;
+ private final MantleLayer caverns;
+ private final int originX;
+ private final int originZ;
+ private final int worldHeight;
+ private final int minWorldY;
+ private final int[] surfaceHeights = new int[CHUNK_WIDTH * CHUNK_WIDTH];
+ private boolean surfaceKnown;
+ private final Map airStates = new IdentityHashMap<>();
+ private final Map replaceableStates = new IdentityHashMap<>();
+ private final Map> suitedOres = new IdentityHashMap<>();
- IrisObject clump = deposit.clump(rng);
+ Placing(ChunkStageContext context) {
+ this.blocks = context.hunk(BlockState.class);
+ this.terrain = context.terrain();
+ this.settings = context.settings();
+ this.caverns = context.mantle().caverns();
+ this.originX = context.originX();
+ this.originZ = context.originZ();
+ this.worldHeight = blocks.getHeight();
+ this.minWorldY = terrain.minWorldY();
+ }
- int dim = clump.getW();
- int min = dim / 2;
- int max = (int) (16D - dim / 2D);
+ void generate(DepositGenerator k, RNG rng) {
+ ResolvedDeposit deposit = resolved(k);
+ if (k.spawnChance() < rng.d())
+ return;
- if (min > max || min < 0 || max > 15) {
- min = 6;
- max = 9;
- }
+ for (int l = 0; l < rng.i(k.minPerChunk(), k.maxPerChunk() + 1); l++) {
+ if (k.perClumpSpawnChance() < rng.d())
+ continue;
- int x = rng.i(min, max + 1);
- int z = rng.i(min, max + 1);
- int terrainSurface = getDepositTerrainSurface(cx, cz, x, z, he, context);
- int height = k.placementScope() == DepositPlacementScope.TERRAIN
- ? depositSurfaceLimit(terrainSurface, k.surfaceClearance())
- : getEngine().getHeight() - 1;
+ DepositClump clump = deposit.clump(rng);
- if (height < 0) {
- continue;
- }
+ int dim = clump.width();
+ int min = dim / 2;
+ int max = (int) (16D - dim / 2D);
- int y = sampleHeight(
- k.heightDistribution(), rng, k.minHeight(), k.maxHeight(),
- Math.min(height, getEngine().getHeight() - 1));
- if (y == Integer.MIN_VALUE) {
- continue;
- }
+ if (min > max || min < 0 || max > 15) {
+ min = 6;
+ max = 9;
+ }
- boolean clippedHeight = k.heightDistribution() == DepositHeightDistribution.CLIPPED_UNIFORM;
- if (clippedHeight && y > height - 2)
- continue;
+ int x = rng.i(min, max + 1);
+ int z = rng.i(min, max + 1);
+ int terrainSurface = terrainSurface(x, z);
+ int height = k.placementScope() == DepositPlacementScope.TERRAIN
+ ? depositSurfaceLimit(terrainSurface, k.surfaceClearance())
+ : worldHeight - 1;
- int biomeY = Math.max(0, Math.min(getEngine().getHeight() - 1, y));
- boolean oreDeposit = deposit.isOre();
- IrisBiome surfaceBiome = context.getBiome().get(x, z);
- IrisBiome depositBiome = oreDeposit || k.usesCaveBiomeFilter()
- ? getEngine().getCaveBiome((cx << 4) + x, biomeY, (cz << 4) + z)
- : null;
- if (!deposit.matchesBiome(surfaceBiome, depositBiome)) {
- continue;
- }
+ if (height < 0) {
+ continue;
+ }
- if (oreDeposit) {
- if (depositBiome != null) {
- double frequencyMultiplier = oreFrequencyMultiplier(depositBiome);
- if (frequencyMultiplier < 1D
- && !passesOreFrequency(frequencyMultiplier, rng.d())) {
- continue;
- }
+ int y = sampleHeight(
+ k.heightDistribution(), rng, k.minHeight(), k.maxHeight(),
+ Math.min(height, worldHeight - 1));
+ if (y == Integer.MIN_VALUE) {
+ continue;
+ }
- double sizeMultiplier = oreSizeMultiplier(depositBiome);
- if (sizeMultiplier != 1D) {
- IrisObject scaledClump = deposit.clump(rng, sizeMultiplier);
- int scaledDimension = scaledClump.getW();
- x = clampDepositCenter(x, scaledDimension, 16);
- if (clippedHeight) {
- y = clampDepositCenter(y, scaledDimension, getEngine().getHeight());
+ boolean clippedHeight = k.heightDistribution() == DepositHeightDistribution.CLIPPED_UNIFORM;
+ if (clippedHeight && y > height - 2)
+ continue;
+
+ int biomeY = Math.max(0, Math.min(worldHeight - 1, y));
+ boolean oreDeposit = deposit.isOre();
+ Supplier biomes = biomesAt(x, biomeY, z);
+ if (!deposit.matchesBiome(() -> identityOf(biomes.get().surfaceBiome()).orElse(null),
+ () -> biomes.get().caveBiome().flatMap(id -> identityOf(id)).orElse(null))) {
+ continue;
+ }
+
+ if (oreDeposit && tunesOres) {
+ Optional caveBiome = biomes.get().caveBiome();
+ if (caveBiome.isPresent()) {
+ double frequencyMultiplier = oreFrequencyMultiplier(caveBiome.get());
+ if (frequencyMultiplier < 1D
+ && !passesOreFrequency(frequencyMultiplier, rng.d())) {
+ continue;
+ }
+
+ double sizeMultiplier = oreSizeMultiplier(caveBiome.get());
+ if (sizeMultiplier != 1D) {
+ DepositClump scaledClump = deposit.clump(rng, sizeMultiplier);
+ int scaledDimension = scaledClump.width();
+ x = clampDepositCenter(x, scaledDimension, 16);
+ if (clippedHeight) {
+ y = clampDepositCenter(y, scaledDimension, worldHeight);
+ }
+ z = clampDepositCenter(z, scaledDimension, 16);
+ clump = scaledClump;
}
- z = clampDepositCenter(z, scaledDimension, 16);
- clump = scaledClump;
}
}
+
+ placeClump(k, deposit, clump, rng, x, y, z);
}
+ }
- IrisDimension dimension = getDimension();
-
- for (art.arcane.volmlib.util.math.IrisBlockVector j : clump.getBlocks().keys()) {
+ private void placeClump(DepositGenerator k, ResolvedDeposit deposit, DepositClump clump, RNG rng, int x, int y, int z) {
+ for (IrisBlockVector j : clump.blocks().keys()) {
int nx = j.getBlockX() + x;
int ny = j.getBlockY() + y;
int nz = j.getBlockZ() + z;
- if (nx > 15 || nx < 0 || ny >= getEngine().getHeight() || ny < 0 || nz < 0 || nz > 15) {
+ if (nx > 15 || nx < 0 || ny >= worldHeight || ny < 0 || nz < 0 || nz > 15) {
continue;
}
- int columnSurface = getDepositTerrainSurface(cx, cz, nx, nz, he, context);
+ int columnSurface = terrainSurface(nx, nz);
if (!placementSurfaceAllows(
k.placementScope(), ny, columnSurface, k.surfaceClearance())) {
continue;
}
- PlatformBlockState current = data.get(nx, ny, nz);
- if (!canReplaceDepositTarget(current)) {
+ BlockState current = blocks.get(nx, ny, nz);
+ if (!canReplaceTarget(current)) {
continue;
}
if (!deposit.canReplace(current)) {
continue;
}
- if (!k.replaceBedrock() && IrisProceduralBlocks.materialKey(current).equals("minecraft:bedrock")) {
+ if (!k.replaceBedrock() && current.material().equals(BEDROCK.material())) {
continue;
}
if (shouldDiscardExposed(
- k.discardChanceOnAirExposure(), rng.d(), isAdjacentToAir(data, nx, ny, nz))) {
+ k.discardChanceOnAirExposure(), rng.d(), isAdjacentToAir(blocks, nx, ny, nz, this::isAir))) {
continue;
}
- if (chunk.get(nx, ny, nz, MatterCavern.class) == null) {
- PlatformBlockState ore = clump.getBlocks().get(j);
- PlatformBlockState remapped = resolveDepositVariant(
- cx, cz, nx, ny, nz, ore, dimension, context);
- PlatformBlockState finalBlock = remapped != null
+ if (caverns.get(originX + nx, ny, originZ + nz) == null) {
+ BlockState ore = clump.blocks().get(j);
+ BlockState remapped = remapped(nx, ny, nz, ore);
+ BlockState finalBlock = remapped != null
? remapped
- : B.toDeepSlateOre(current, ore);
- data.set(nx, ny, nz, finalBlock);
+ : oreSuiting(current, ore);
+ blocks.set(nx, ny, nz, finalBlock);
}
}
}
- }
- private ResolvedDeposit resolved(DepositGenerator generator) {
- return resolved.computeIfAbsent(generator, ignored -> ResolvedDeposit.of(generator, getEngine()));
- }
+ /** Asks the host for the biomes of the column only if a filter or an ore tuning reads them, and only once. */
+ private Supplier biomesAt(int localX, int y, int localZ) {
+ BiomeSample[] sample = new BiomeSample[1];
+ return () -> {
+ if (sample[0] == null) {
+ sample[0] = terrain.biome(originX + localX, y, originZ + localZ);
+ }
+ return sample[0];
+ };
+ }
- private int getDepositTerrainSurface(
- int cx, int cz, int localX, int localZ, HeightMap heightMap,
- ChunkContext context) {
- return heightMap != null
- ? heightMap.getHeight((cx << 4) + localX, (cz << 4) + localZ)
- : context.getRoundedHeight(localX, localZ);
+ /** {@code ore}, or the variant of it that suits the rock it replaces; the platform knows the variants, so each pair is asked once. */
+ private BlockState oreSuiting(BlockState rock, BlockState ore) {
+ return suitedOres.computeIfAbsent(rock, known -> new IdentityHashMap<>())
+ .computeIfAbsent(ore, known -> registry.oreFor(rock, known));
+ }
+
+ private boolean isAir(BlockState state) {
+ return airStates.computeIfAbsent(state, known -> registry.hasTrait(known, BlockTrait.AIR));
+ }
+
+ private boolean canReplaceTarget(BlockState state) {
+ return replaceableStates.computeIfAbsent(state, known -> canReplaceDepositTarget(registry, known));
+ }
+
+ /** The height of the terrain at a column of the chunk, as the stages before the deposits see it. */
+ private int terrainSurface(int localX, int localZ) {
+ if (!surfaceKnown) {
+ for (int x = 0; x < CHUNK_WIDTH; x++) {
+ for (int z = 0; z < CHUNK_WIDTH; z++) {
+ surfaceHeights[x * CHUNK_WIDTH + z] = (int) Math.round(terrain.surfaceY(originX + x, originZ + z));
+ }
+ }
+ surfaceKnown = true;
+ }
+ return surfaceHeights[localX * CHUNK_WIDTH + localZ];
+ }
+
+ private BlockState remapped(int localX, int localY, int localZ, BlockState ore) {
+ if (!remapsOres) {
+ return null;
+ }
+ int worldX = originX + localX;
+ int worldZ = originZ + localZ;
+ int worldY = absoluteWorldY(minWorldY, localY);
+
+ Optional caveBiome = terrain.biome(worldX, localY, worldZ).caveBiome();
+ if (caveBiome.isPresent()) {
+ BlockState match = matchDepositVariant(settings.declaredBy(caveBiome.get(), DepositVariantSettings.class), ore, worldY);
+ if (match != null) {
+ return match;
+ }
+ }
+
+ BlockState match = matchDepositVariant(levelSettings(Target.REGION, worldX, worldZ), ore, worldY);
+ if (match != null) {
+ return match;
+ }
+
+ return matchDepositVariant(levelSettings(Target.DIMENSION, worldX, worldZ), ore, worldY);
+ }
+
+ private Optional levelSettings(Target level, int worldX, int worldZ) {
+ return settings.at(DepositVariantSettings.class, worldX, worldZ).stream()
+ .filter(entry -> entry.level() == level)
+ .map(Entry::value)
+ .findFirst();
+ }
+
+ private BlockState matchDepositVariant(Optional owner, BlockState ore, int y) {
+ for (DepositVariant declared : owner.map(DepositVariantSettings::variants).orElse(List.of())) {
+ ResolvedDepositVariant variant = variants.computeIfAbsent(declared, rule -> new ResolvedDepositVariant(rule, registry, log));
+ if (!variant.appliesAt(y)) {
+ continue;
+ }
+
+ BlockState swapped = variant.remapOrNull(ore);
+ if (swapped != null) {
+ return swapped;
+ }
+ }
+
+ return null;
+ }
+
+ private double oreFrequencyMultiplier(ResourceId caveBiome) {
+ return settings.declaredBy(caveBiome, OreFrequencySettings.class).map(OreFrequencySettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER);
+ }
+
+ private double oreSizeMultiplier(ResourceId caveBiome) {
+ return settings.declaredBy(caveBiome, OreSizeSettings.class).map(OreSizeSettings::multiplier).orElse(UNCHANGED_ORE_MULTIPLIER);
+ }
}
static int depositSurfaceLimit(int surfaceY) {
- return depositSurfaceLimit(surfaceY, 7);
+ return depositSurfaceLimit(surfaceY, DEFAULT_SURFACE_CLEARANCE);
}
static int depositSurfaceLimit(int surfaceY, int surfaceClearance) {
@@ -252,8 +380,8 @@ public class DepositPlacer extends EngineAssignedComponent {
return minHeight + localY;
}
- static boolean canReplaceDepositTarget(PlatformBlockState state) {
- return state != null && !state.isAir() && !state.isFluid();
+ static boolean canReplaceDepositTarget(BlockRegistry registry, BlockState state) {
+ return state != null && !registry.hasTrait(state, BlockTrait.AIR) && !registry.hasTrait(state, BlockTrait.FLUID);
}
static int sampleHeight(
@@ -285,23 +413,22 @@ public class DepositPlacer extends EngineAssignedComponent {
return adjacentToAir && chance > 0D && sample < Math.min(1D, chance);
}
- static boolean isAdjacentToAir(Hunk data, int x, int y, int z) {
- return isAirAt(data, x - 1, y, z)
- || isAirAt(data, x + 1, y, z)
- || isAirAt(data, x, y - 1, z)
- || isAirAt(data, x, y + 1, z)
- || isAirAt(data, x, y, z - 1)
- || isAirAt(data, x, y, z + 1);
+ static boolean isAdjacentToAir(Hunk data, int x, int y, int z, Predicate