diff --git a/README.md b/README.md index bd0790394..f1ba758e0 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,18 @@ direct dependencies on Iris internals. Ported features are IrisApi modules that every pack loads before its own: object placement (`iris:prepare`, `iris:anchor`, `iris:validate`, `iris:bore`, `iris:blocks`, `iris:stilt`, -`iris:vacuum`, `iris:snow`) and `iris:perfection`. Their stage constants and the output types packs -may read live in `src/main/java/art/arcane/iris/builtin`, the package Iris exposes to pack modules; -their stage bodies live beside the features they replace. +`iris:vacuum`, `iris:snow`) and chunk generation, which every world runs in this order: `iris:biome`, +`iris:terrain`, `iris:carve` (a mantle stage planning caves, and a chunk stage cutting them), +`iris:post`, `iris:floating` (solids), `iris:deposit`, `iris:matter`, `iris:decorant`, `iris:floating` +(decoration), `iris:perfection` and `iris:custom`. There are no world modes any more. Their stage +constants, and the settings and output types packs may read, live in +`src/main/java/art/arcane/iris/builtin`, the package Iris exposes to pack modules; their stage bodies live +beside the features they replace. + +`iris:biome` and `iris:deposit` (chunk stages) and the cave planning of `iris:carve` (a mantle stage) are +full ports: the module owns its logic and per-engine state. The other generation stages are thin wrappers +that run the existing actuator or modifier unchanged. Iris's object, floating object and structure mantle +components are still Iris mantle components. Iris core and these sources still depend on each other. The Iris host build therefore compiles them together as one source set. This keeps the existing class names and platform artifacts while the diff --git a/source-patterns.txt b/source-patterns.txt index 6e0d633f7..b09f3c28b 100644 --- a/source-patterns.txt +++ b/source-patterns.txt @@ -1,7 +1,6 @@ art/arcane/iris/engine/actuator/** art/arcane/iris/engine/decorator/** art/arcane/iris/engine/modifier/** -art/arcane/iris/engine/mode/** art/arcane/iris/engine/mantle/components/** art/arcane/iris/engine/object/** art/arcane/iris/engine/image/** diff --git a/src/main/java/art/arcane/iris/builtin/biome/BiomeStages.java b/src/main/java/art/arcane/iris/builtin/biome/BiomeStages.java new file mode 100644 index 000000000..c83b8efc0 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/biome/BiomeStages.java @@ -0,0 +1,31 @@ +/* + * 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.biome; + +import com.volmit.stage.ChunkStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:biome}: the biomes a chunk reports to the server. */ +public final class BiomeStages { + /** Writes every column's biome, sky biome or custom biome, into the chunk. */ + public static final ChunkStage WRITE = Stage.chunk("iris:biome/write"); + + private BiomeStages() { + } +} diff --git a/src/main/java/art/arcane/iris/builtin/carve/CarveStages.java b/src/main/java/art/arcane/iris/builtin/carve/CarveStages.java new file mode 100644 index 000000000..d63809438 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/carve/CarveStages.java @@ -0,0 +1,34 @@ +/* + * 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.carve; + +import com.volmit.stage.ChunkStage; +import com.volmit.stage.MantleStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:carve}: caves, planned in the mantle and cut into each chunk's terrain. */ +public final class CarveStages { + /** Plans the caves of the dimension's cave profiles into the mantle, one block into each neighbor. */ + public static final MantleStage CAVES = Stage.mantle("iris:carve/caves"); + /** Cuts the planned caves out of the chunk's terrain and decorates their floors and ceilings. */ + public static final ChunkStage APPLY = Stage.chunk("iris:carve/apply"); + + private CarveStages() { + } +} diff --git a/src/main/java/art/arcane/iris/builtin/custom/CustomStages.java b/src/main/java/art/arcane/iris/builtin/custom/CustomStages.java new file mode 100644 index 000000000..c7ca96c7b --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/custom/CustomStages.java @@ -0,0 +1,31 @@ +/* + * 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.custom; + +import com.volmit.stage.ChunkStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:custom}: blocks of content plugins, which the server places after generation. */ +public final class CustomStages { + /** Records the chunk's custom blocks so the server can place them once the chunk exists. */ + public static final ChunkStage BLOCKS = Stage.chunk("iris:custom/blocks"); + + private CustomStages() { + } +} diff --git a/src/main/java/art/arcane/iris/builtin/decorant/DecorantStages.java b/src/main/java/art/arcane/iris/builtin/decorant/DecorantStages.java new file mode 100644 index 000000000..1158ada20 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/decorant/DecorantStages.java @@ -0,0 +1,31 @@ +/* + * 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.stage.ChunkStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:decorant}: the decorators of biomes, such as grass, flowers and cave ceilings. */ +public final class DecorantStages { + /** Places every column's surface, sea, shore and cave decorators. */ + public static final ChunkStage DECORATE = Stage.chunk("iris:decorant/decorate"); + + private DecorantStages() { + } +} diff --git a/src/main/java/art/arcane/iris/builtin/deposit/DepositSettings.java b/src/main/java/art/arcane/iris/builtin/deposit/DepositSettings.java new file mode 100644 index 000000000..c9901093e --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/deposit/DepositSettings.java @@ -0,0 +1,49 @@ +/* + * 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.deposit; + +import art.arcane.iris.engine.object.terrain.deposit.IrisDepositGenerator; +import com.volmit.FeatureAttachment.Target; +import com.volmit.IrisFeature; +import com.volmit.config.Desc; +import com.volmit.config.Feature; + +import java.util.List; + +/** + * The deposits one dimension, region or biome declares, written as {@code "deposits": [...]}. Levels stack: + * a chunk gets the deposits of its dimension, its centre column's region and that column's biome. + */ +@Desc("Ores and other deposits generated in every chunk where this applies") +@Feature(id = "iris:deposit", name = "Deposits", alias = "deposits", targets = {Target.DIMENSION, Target.REGION, Target.BIOME}) +public final class DepositSettings implements IrisFeature { + @Desc("Define deposit generators that this applies to chunks") + private List generators = List.of(); + + public DepositSettings() { + } + + public DepositSettings(List generators) { + this.generators = List.copyOf(generators); + } + + public List generators() { + return generators; + } +} diff --git a/src/main/java/art/arcane/iris/builtin/deposit/DepositStages.java b/src/main/java/art/arcane/iris/builtin/deposit/DepositStages.java new file mode 100644 index 000000000..e61abc3ca --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/deposit/DepositStages.java @@ -0,0 +1,34 @@ +/* + * 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.deposit; + +import com.volmit.stage.ChunkStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:deposit}: ores and other deposits. */ +public final class DepositStages { + /** + * Places the deposits every level declares at the chunk's centre column, the dimension's, the region's and + * the biome's, each with its own clumps. Active where any column of the chunk has deposits. + */ + public static final ChunkStage ORES = Stage.chunk("iris:deposit/ores"); + + private DepositStages() { + } +} diff --git a/src/main/java/art/arcane/iris/builtin/floating/FloatingStages.java b/src/main/java/art/arcane/iris/builtin/floating/FloatingStages.java new file mode 100644 index 000000000..d3deb4680 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/floating/FloatingStages.java @@ -0,0 +1,33 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.builtin.floating; + +import com.volmit.stage.ChunkStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:floating}: the floating islands of floating child biomes. */ +public final class FloatingStages { + /** Writes the islands' solid blocks. */ + public static final ChunkStage SOLIDS = Stage.chunk("iris:floating/solids"); + /** Decorates the islands' tops and bottoms once the chunk's own decoration is done. */ + public static final ChunkStage DECORATE = Stage.chunk("iris:floating/decorate"); + + private FloatingStages() { + } +} diff --git a/src/main/java/art/arcane/iris/builtin/matter/MatterStages.java b/src/main/java/art/arcane/iris/builtin/matter/MatterStages.java new file mode 100644 index 000000000..8becc062b --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/matter/MatterStages.java @@ -0,0 +1,31 @@ +/* + * 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.matter; + +import com.volmit.stage.ChunkStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:matter}: the blocks the mantle planned for a chunk, such as objects and structures. */ +public final class MatterStages { + /** Copies the chunk's planned mantle blocks into it. */ + public static final ChunkStage INSERT = Stage.chunk("iris:matter/insert"); + + private MatterStages() { + } +} diff --git a/src/main/java/art/arcane/iris/builtin/post/PostStages.java b/src/main/java/art/arcane/iris/builtin/post/PostStages.java new file mode 100644 index 000000000..8c45102c1 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/post/PostStages.java @@ -0,0 +1,31 @@ +/* + * 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.post; + +import com.volmit.stage.ChunkStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:post}: smoothing a chunk's surface after carving. */ +public final class PostStages { + /** Fills single-block holes, places slabs and walls on steps and settles snow. */ + public static final ChunkStage SMOOTH = Stage.chunk("iris:post/smooth"); + + private PostStages() { + } +} diff --git a/src/main/java/art/arcane/iris/builtin/terrain/TerrainStages.java b/src/main/java/art/arcane/iris/builtin/terrain/TerrainStages.java new file mode 100644 index 000000000..da7131982 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/terrain/TerrainStages.java @@ -0,0 +1,31 @@ +/* + * 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.stage.ChunkStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:terrain}: the solid ground, fluids and biome layers of a chunk. */ +public final class TerrainStages { + /** Fills each column from bedrock up to its height and the fluid height, with its biome's layers. */ + public static final ChunkStage SHAPE = Stage.chunk("iris:terrain/shape"); + + private TerrainStages() { + } +} diff --git a/src/main/java/art/arcane/iris/engine/actuator/BiomeModule.java b/src/main/java/art/arcane/iris/engine/actuator/BiomeModule.java new file mode 100644 index 000000000..1ef7c0591 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/actuator/BiomeModule.java @@ -0,0 +1,126 @@ +/* + * 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.biome.BiomeStages; +import art.arcane.iris.core.modules.IrisChunk; +import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.engine.object.world.biome.IrisBiome; +import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom; +import art.arcane.iris.spi.IrisPlatform; +import art.arcane.iris.spi.IrisPlatforms; +import art.arcane.iris.spi.PlatformBiome; +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.KMap; +import art.arcane.volmlib.util.mantle.runtime.Mantle; +import art.arcane.volmlib.util.math.RNG; +import art.arcane.volmlib.util.matter.Matter; +import art.arcane.volmlib.util.matter.MatterBiomeInject; +import art.arcane.volmlib.util.matter.slices.BiomeInjectMatter; +import art.arcane.volmlib.util.scheduling.PrecisionStopwatch; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:biome}: writes each column's biome into the chunk's biome hunk, a custom biome under the + * dimension's namespace, and records the biome id in the mantle for platforms that inject biomes later. + */ +public final class BiomeModule implements IrisModule { + private static final String VERSION = "built-in"; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:biome", "Biomes", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(BiomeStages.WRITE).run(BiomeModule::write); + } + + private static void write(ChunkStageContext context) { + IrisChunk chunk = IrisChunk.current(); + chunk.state(BiomeWriter.class, BiomeWriter::new).write(chunk.originX(), chunk.originZ(), chunk.biomes(), chunk.context()); + } + + /** What writing biomes keeps for one engine runtime: the biome stream's random and the platform biomes resolved so far. */ + static final class BiomeWriter { + private final Engine engine; + private final RNG rng; + private final KMap resolvedBiomes = new KMap<>(); + + BiomeWriter(Engine engine) { + this.engine = engine; + this.rng = new RNG(engine.getSeedManager().getBiome()); + } + + /** A partial biome write fails the chunk: a chunk flagged done with default biomes would keep them forever. */ + void write(int originX, int originZ, Hunk biomes, ChunkContext context) { + PrecisionStopwatch stopwatch = PrecisionStopwatch.start(); + Mantle mantle = engine.getMantle().getMantle(); + ChunkedDataCache biomeCache = context.getBiome(); + for (int localX = 0; localX < biomes.getWidth(); localX++) { + for (int localZ = 0; localZ < biomes.getDepth(); localZ++) { + int worldX = originX + localX; + int worldZ = originZ + localZ; + ResolvedBiome resolved = resolve(keyOf(biomeCache.get(localX, localZ), worldX, worldZ)); + if (resolved.biome() != null) { + biomes.set(localX, 0, localZ, localX, biomes.getHeight() - 1, localZ, resolved.biome()); + } + mantle.set(worldX, 0, worldZ, resolved.matter()); + } + } + engine.getMetrics().getBiome().put(stopwatch.getMilliseconds()); + } + + private String keyOf(IrisBiome biome, int worldX, int worldZ) { + if (!biome.isCustom()) { + return biome.getSkyBiomeKey(rng, engine, worldX, 0, worldZ); + } + IrisBiomeCustom custom = biome.getCustomBiome(rng, engine, worldX, 0, worldZ); + return engine.getDimension().getLoadKey() + ":" + custom.getId(); + } + + /** + * The registry lookup and the biome id depend only on the key, so the pair is cached instead of paying two + * string-keyed lookups per column. Unresolved biomes are never cached, so a biome registered later still + * resolves. + */ + private ResolvedBiome resolve(String key) { + ResolvedBiome cached = key == null ? null : resolvedBiomes.get(key); + if (cached != null) { + return cached; + } + IrisPlatform platform = IrisPlatforms.get(); + PlatformBiome biome = platform.registries().biome(key); + ResolvedBiome resolved = new ResolvedBiome(biome, BiomeInjectMatter.get(platform.biomeWriter().biomeIdFor(key))); + if (key != null && biome != null) { + resolvedBiomes.put(key, resolved); + } + return resolved; + } + } + + private record ResolvedBiome(PlatformBiome biome, MatterBiomeInject matter) { + } +} diff --git a/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java b/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java new file mode 100644 index 000000000..d1a8b1b2a --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/actuator/DecorantModule.java @@ -0,0 +1,51 @@ +/* + * 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.decorant.DecorantStages; +import art.arcane.iris.builtin.matter.MatterStages; +import art.arcane.iris.core.modules.IrisChunk; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:decorant}: the biomes' decorators, placed on the surface the mantle's blocks left. A thin + * wrapper: the stage runs {@link IrisDecorantActuator} unchanged, one per engine runtime. + */ +public final class DecorantModule implements IrisModule { + private static final String VERSION = "built-in"; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:decorant", "Decorators", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(DecorantStages.DECORATE).requires(MatterStages.INSERT).run(DecorantModule::decorate); + } + + private static void decorate(ChunkStageContext context) { + IrisChunk chunk = IrisChunk.current(); + chunk.state(IrisDecorantActuator.class, IrisDecorantActuator::new) + .actuate(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); + } +} diff --git a/src/main/java/art/arcane/iris/engine/actuator/IrisBiomeActuator.java b/src/main/java/art/arcane/iris/engine/actuator/IrisBiomeActuator.java deleted file mode 100644 index d420dfc73..000000000 --- a/src/main/java/art/arcane/iris/engine/actuator/IrisBiomeActuator.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.actuator; - -import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom; -import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.framework.EngineAssignedActuator; -import art.arcane.iris.engine.object.world.biome.IrisBiome; -import art.arcane.iris.util.project.context.ChunkContext; -import art.arcane.iris.util.project.context.ChunkedDataCache; -import art.arcane.volmlib.util.collection.KMap; -import art.arcane.volmlib.util.documentation.BlockCoordinates; -import art.arcane.iris.util.project.hunk.Hunk; -import art.arcane.volmlib.util.mantle.runtime.Mantle; -import art.arcane.volmlib.util.math.RNG; -import art.arcane.volmlib.util.matter.Matter; -import art.arcane.volmlib.util.matter.MatterBiomeInject; -import art.arcane.volmlib.util.matter.slices.BiomeInjectMatter; -import art.arcane.volmlib.util.scheduling.ChronoLatch; -import art.arcane.volmlib.util.scheduling.PrecisionStopwatch; -import art.arcane.iris.spi.IrisPlatform; -import art.arcane.iris.spi.IrisPlatforms; -import art.arcane.iris.spi.PlatformBiome; - -public class IrisBiomeActuator extends EngineAssignedActuator { - private final RNG rng; - private final ChronoLatch cl = new ChronoLatch(5000); - private final KMap resolvedBiomes = new KMap<>(); - - public IrisBiomeActuator(Engine engine) { - super(engine, "Biome"); - rng = new RNG(engine.getSeedManager().getBiome()); - } - - @BlockCoordinates - @Override - public void onActuate(int x, int z, Hunk h, boolean multicore, ChunkContext context) { - // No catch here: a partial biome write must fail the chunk (EngineAssignedActuator - // rethrows), or the chunk is flagged REAL with default plains columns forever. - PrecisionStopwatch p = PrecisionStopwatch.start(); - int width = h.getWidth(); - int depth = h.getDepth(); - int height = h.getHeight(); - Engine engine = getEngine(); - Mantle mantle = engine.getMantle().getMantle(); - ChunkedDataCache biomeCache = context.getBiome(); - - for (int xf = 0; xf < width; xf++) { - IrisBiome ib; - for (int zf = 0; zf < depth; zf++) { - ib = biomeCache.get(xf, zf); - String key; - - if (ib.isCustom()) { - IrisBiomeCustom custom = ib.getCustomBiome(rng, engine, x + xf, 0, z + zf); - key = getDimension().getLoadKey() + ":" + custom.getId(); - } else { - key = ib.getSkyBiomeKey(rng, engine, x + xf, 0, z + zf); - } - - ResolvedBiome resolved = resolve(key); - PlatformBiome biome = resolved.biome(); - - if (biome != null) { - h.set(xf, 0, zf, xf, height - 1, zf, biome); - } - - mantle.set(x + xf, 0, z + zf, resolved.matter()); - } - } - engine.getMetrics().getBiome().put(p.getMilliseconds()); - } - - /** - * The registry lookup and the biome id only depend on the scatter resolved key, so cache the pair - * instead of paying two string keyed lookups per column. Unresolved biomes are never cached, so a - * biome registered later still resolves. - */ - private ResolvedBiome resolve(String key) { - ResolvedBiome cached = key == null ? null : resolvedBiomes.get(key); - - if (cached != null) { - return cached; - } - - IrisPlatform platform = IrisPlatforms.get(); - PlatformBiome biome = platform.registries().biome(key); - ResolvedBiome resolved = new ResolvedBiome(biome, BiomeInjectMatter.get(platform.biomeWriter().biomeIdFor(key))); - - if (key != null && biome != null) { - resolvedBiomes.put(key, resolved); - } - - return resolved; - } - - private record ResolvedBiome(PlatformBiome biome, MatterBiomeInject matter) { - } -} diff --git a/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java b/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java new file mode 100644 index 000000000..9bc017a6b --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainModule.java @@ -0,0 +1,50 @@ +/* + * 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.terrain.TerrainStages; +import art.arcane.iris.core.modules.IrisChunk; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:terrain}: the chunk's ground, fluids and biome layers. A thin wrapper: the stage runs + * {@link IrisTerrainNormalActuator} unchanged, one per engine runtime. + */ +public final class TerrainModule implements IrisModule { + private static final String VERSION = "built-in"; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:terrain", "Terrain", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(TerrainStages.SHAPE).run(TerrainModule::shape); + } + + private static void shape(ChunkStageContext context) { + IrisChunk chunk = IrisChunk.current(); + chunk.state(IrisTerrainNormalActuator.class, IrisTerrainNormalActuator::new) + .actuate(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); + } +} diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/MantleCarvingComponent.java b/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java similarity index 91% rename from src/main/java/art/arcane/iris/engine/mantle/components/MantleCarvingComponent.java rename to src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java index fa61ed86f..c67e63461 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/MantleCarvingComponent.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/CaveCarving.java @@ -20,9 +20,7 @@ package art.arcane.iris.engine.mantle.components; import art.arcane.iris.engine.IrisComplex; import art.arcane.iris.engine.UpperDimensionContext; -import art.arcane.iris.engine.mantle.ComponentFlag; -import art.arcane.iris.engine.mantle.EngineMantle; -import art.arcane.iris.engine.mantle.IrisMantleComponent; +import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.mantle.MantleWriter; import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile; @@ -38,7 +36,6 @@ import art.arcane.iris.util.project.stream.utility.ChunkFillableDoubleStream2D; import art.arcane.iris.util.simd.SimdKernels; import art.arcane.iris.util.simd.SimdSupport; import art.arcane.volmlib.util.documentation.ChunkCoordinates; -import art.arcane.volmlib.util.mantle.flag.ReservedFlag; import art.arcane.volmlib.util.math.PowerOfTwoCoordinates; import art.arcane.volmlib.util.scheduling.PrecisionStopwatch; @@ -48,8 +45,12 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -@ComponentFlag(ReservedFlag.CARVED) -public class MantleCarvingComponent extends IrisMantleComponent { +/** + * Plans one chunk's caves into the mantle for {@link art.arcane.iris.engine.modifier.CarveModule}: the cave + * profiles of the dimension's carving entries and of the regions and biomes around the chunk, blended over + * their borders. One per engine runtime, keeping a carver per cave profile. + */ +public class CaveCarving { private static final int CHUNK_SIZE = 16; private static final int CHUNK_AREA = CHUNK_SIZE * CHUNK_SIZE; private static final int BLEND_RADIUS = 3; @@ -64,6 +65,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { private static final double[] KERNEL_WEIGHT = new double[KERNEL_SIZE]; private static final ThreadLocal BLEND_SCRATCH = ThreadLocal.withInitial(BlendScratch::new); + private final Engine engine; private final Object profileCarverLock = new Object(); private volatile Map profileCarvers = new IdentityHashMap<>(); @@ -80,31 +82,20 @@ public class MantleCarvingComponent extends IrisMantleComponent { } } - public MantleCarvingComponent(EngineMantle engineMantle) { - super(engineMantle, ReservedFlag.CARVED, 0); + public CaveCarving(Engine engine) { + this.engine = engine; } - @Override - public void hotload() { - super.hotload(); - // Hotload swaps in fresh IrisCaveProfile instances (identity keys), so retained - // entries would strand a full carver set pinning the closed IrisData per reload. - // Carvers rebuild deterministically from the carve seed, so output is unchanged. - synchronized (profileCarverLock) { - profileCarvers = new IdentityHashMap<>(); - } - } - - @Override - public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) { + /** Carves the caves of the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */ + public void carve(MantleWriter writer, int x, int z, ChunkContext context) { IrisComplex complex = context.getComplex(); IrisDimensionCarvingResolver.State resolverState = new IrisDimensionCarvingResolver.State(); BlendScratch blendScratch = BLEND_SCRATCH.get(); int[] chunkSurfaceHeights = prepareChunkSurfaceHeights(x, z, context, blendScratch.chunkSurfaceHeights); PrecisionStopwatch resolveStopwatch = PrecisionStopwatch.start(); List weightedProfiles = resolveWeightedProfiles(x, z, complex, resolverState); - getEngineMantle().getEngine().getMetrics().getCarveResolve().put(resolveStopwatch.getMilliseconds()); - int fluidHeight = getDimension().getFluidHeight(); + engine.getMetrics().getCarveResolve().put(resolveStopwatch.getMilliseconds()); + int fluidHeight = engine.getDimension().getFluidHeight(); int[] surfaceFluidBoundaryStartY = blendScratch.surfaceFluidBoundaryStartY; SurfaceFluidBoundaryPlan.fill( chunkSurfaceHeights, @@ -120,8 +111,8 @@ public class MantleCarvingComponent extends IrisMantleComponent { carveProfile(weightedProfile, writer, x, z, chunkSurfaceHeights, surfaceFluidBoundaryStartY, fluidSupportPlan); } - UpperDimensionContext upperCtx = getEngineMantle().getEngine().getUpperContext(); - if (upperCtx != null && getDimension().isUpperDimensionCarving()) { + UpperDimensionContext upperCtx = engine.getUpperContext(); + if (upperCtx != null && engine.getDimension().isUpperDimensionCarving()) { carveUpperTerrain(upperCtx, weightedProfiles, writer, x, z, chunkSurfaceHeights, fluidSupportPlan); } fluidSupportPlan.resolve(writer.acquireChunk(x, z)); @@ -158,9 +149,9 @@ public class MantleCarvingComponent extends IrisMantleComponent { private void carveUpperTerrain(UpperDimensionContext upperCtx, List normalProfiles, MantleWriter writer, int cx, int cz, int[] lowerSurfaceHeights, CaveFluidSupportPlan fluidSupportPlan) { - int chunkHeight = getEngineMantle().getEngine().getHeight(); - int worldMinHeight = getEngineMantle().getEngine().getWorld().minHeight(); - int gap = getDimension().getUpperDimensionGap(); + int chunkHeight = engine.getHeight(); + int worldMinHeight = engine.getWorld().minHeight(); + int gap = engine.getDimension().getUpperDimensionGap(); int baseX = PowerOfTwoCoordinates.chunkToBlock(cx); int baseZ = PowerOfTwoCoordinates.chunkToBlock(cz); @@ -307,7 +298,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { private List resolveDimensionCarvingProfiles(int chunkX, int chunkZ, IrisDimensionCarvingResolver.State resolverState, BlendScratch blendScratch) { List weightedProfiles = new ArrayList<>(); - List entries = getDimension().getCarving(); + List entries = engine.getDimension().getCarving(); if (entries == null || entries.isEmpty()) { return weightedProfiles; } @@ -320,7 +311,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { continue; } - IrisBiome rootBiome = IrisDimensionCarvingResolver.resolveEntryBiome(getEngineMantle().getEngine(), entry, resolverState); + IrisBiome rootBiome = IrisDimensionCarvingResolver.resolveEntryBiome(engine, entry, resolverState); if (rootBiome == null) { continue; } @@ -333,7 +324,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { IrisRange worldYRange = entry.getWorldYRange(); for (int columnIndex = 0; columnIndex < CHUNK_AREA; columnIndex++) { IrisDimensionCarvingEntry resolvedEntry = columnPlan[columnIndex]; - IrisBiome resolvedBiome = IrisDimensionCarvingResolver.resolveEntryBiome(getEngineMantle().getEngine(), resolvedEntry, resolverState); + IrisBiome resolvedBiome = IrisDimensionCarvingResolver.resolveEntryBiome(engine, resolvedEntry, resolverState); if (resolvedBiome == null) { continue; } @@ -368,7 +359,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { for (int localZ = 0; localZ < CHUNK_SIZE; localZ++) { int worldZ = baseZ + localZ; int columnIndex = PowerOfTwoCoordinates.packLocal16(localX, localZ); - columnPlan[columnIndex] = IrisDimensionCarvingResolver.resolveFromRoot(getEngineMantle().getEngine(), entry, worldX, worldZ, resolverState); + columnPlan[columnIndex] = IrisDimensionCarvingResolver.resolveFromRoot(engine, entry, worldX, worldZ, resolverState); } } } @@ -416,7 +407,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { IrisDimensionCarvingResolver.State resolverState ) { IrisCaveProfile resolved = null; - IrisCaveProfile dimensionProfile = getDimension().getCaveProfile(); + IrisCaveProfile dimensionProfile = engine.getDimension().getCaveProfile(); if (isProfileEnabled(dimensionProfile)) { resolved = dimensionProfile; } @@ -437,12 +428,12 @@ public class MantleCarvingComponent extends IrisMantleComponent { int roundedSurfaceY = (int) Math.round(surfaceHeight); int sampleY = Math.max(1, roundedSurfaceY - 56); - int worldY = sampleY + getEngineMantle().getEngine().getWorld().minHeight(); - IrisDimensionCarvingEntry rootCarvingEntry = IrisDimensionCarvingResolver.resolveRootEntry(getEngineMantle().getEngine(), worldY, resolverState); + int worldY = sampleY + engine.getWorld().minHeight(); + IrisDimensionCarvingEntry rootCarvingEntry = IrisDimensionCarvingResolver.resolveRootEntry(engine, worldY, resolverState); IrisBiome resolvedCarvingBiome = null; if (rootCarvingEntry != null) { - IrisDimensionCarvingEntry resolvedCarvingEntry = IrisDimensionCarvingResolver.resolveFromRoot(getEngineMantle().getEngine(), rootCarvingEntry, worldX, worldZ, resolverState); - resolvedCarvingBiome = IrisDimensionCarvingResolver.resolveEntryBiome(getEngineMantle().getEngine(), resolvedCarvingEntry, resolverState); + IrisDimensionCarvingEntry resolvedCarvingEntry = IrisDimensionCarvingResolver.resolveFromRoot(engine, rootCarvingEntry, worldX, worldZ, resolverState); + resolvedCarvingBiome = IrisDimensionCarvingResolver.resolveEntryBiome(engine, resolvedCarvingEntry, resolverState); if (resolvedCarvingBiome != null) { caveBiome = resolvedCarvingBiome; } @@ -514,7 +505,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { return carver; } - IrisCaveCarver3D createdCarver = new IrisCaveCarver3D(getEngineMantle().getEngine(), profile); + IrisCaveCarver3D createdCarver = new IrisCaveCarver3D(engine, profile); synchronized (profileCarverLock) { IrisCaveCarver3D published = profileCarvers.get(profile); if (published != null) { @@ -532,10 +523,6 @@ public class MantleCarvingComponent extends IrisMantleComponent { return profile != null && profile.isEnabled(); } - protected int computeRadius() { - return 1; - } - private int[] prepareChunkSurfaceHeights(int chunkX, int chunkZ, ChunkContext context, int[] scratch) { int[] surfaceHeights = scratch; int baseX = PowerOfTwoCoordinates.chunkToBlock(chunkX); @@ -565,7 +552,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { surfaceHeights[columnIndex] = (int) Math.round(cachedChunkHeights[(localZ << 4) + localX]); continue; } - surfaceHeights[columnIndex] = getEngineMantle().getEngine().getHeight(worldX, worldZ); + surfaceHeights[columnIndex] = engine.getHeight(worldX, worldZ); } } return surfaceHeights; @@ -582,7 +569,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { int clampedLimit = Math.max(1, maxProfiles); List rankedProfiles = new ArrayList<>(blendedProfiles); - rankedProfiles.sort(MantleCarvingComponent::compareBySelectionRank); + rankedProfiles.sort(CaveCarving::compareBySelectionRank); List keptProfiles = new ArrayList<>(); int keptCount = Math.min(clampedLimit, rankedProfiles.size()); for (int index = 0; index < keptCount; index++) { @@ -620,7 +607,7 @@ public class MantleCarvingComponent extends IrisMantleComponent { double averageWeight = computeAverageWeight(keptProfile.columnWeights, areaSize); mergedProfiles.add(new WeightedProfile(keptProfile.profile, keptProfile.columnWeights, averageWeight, keptProfile.worldYRange, keptProfile.sequence)); } - mergedProfiles.sort(MantleCarvingComponent::compareByCarveOrder); + mergedProfiles.sort(CaveCarving::compareByCarveOrder); return mergedProfiles; } diff --git a/src/main/java/art/arcane/iris/engine/mode/ModeEnclosure.java b/src/main/java/art/arcane/iris/engine/mode/ModeEnclosure.java deleted file mode 100644 index 09d2f9f15..000000000 --- a/src/main/java/art/arcane/iris/engine/mode/ModeEnclosure.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.mode; - -import art.arcane.iris.engine.actuator.IrisBiomeActuator; -import art.arcane.iris.engine.actuator.IrisTerrainNormalActuator; -import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.framework.EngineMode; -import art.arcane.iris.engine.framework.IrisEngineMode; - -public class ModeEnclosure extends IrisEngineMode implements EngineMode { - public ModeEnclosure(Engine engine) { - super(engine); - var terrain = new IrisTerrainNormalActuator(getEngine()); - var biome = new IrisBiomeActuator(getEngine()); - - registerStage(burst( - (x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c), - (x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c) - )); - } -} diff --git a/src/main/java/art/arcane/iris/engine/mode/ModeIslands.java b/src/main/java/art/arcane/iris/engine/mode/ModeIslands.java deleted file mode 100644 index 494b46bc8..000000000 --- a/src/main/java/art/arcane/iris/engine/mode/ModeIslands.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.mode; - -import art.arcane.iris.engine.actuator.IrisBiomeActuator; -import art.arcane.iris.engine.actuator.IrisTerrainNormalActuator; -import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.framework.EngineMode; -import art.arcane.iris.engine.framework.IrisEngineMode; - -public class ModeIslands extends IrisEngineMode implements EngineMode { - public ModeIslands(Engine engine) { - super(engine); - var terrain = new IrisTerrainNormalActuator(getEngine()); - var biome = new IrisBiomeActuator(getEngine()); - - registerStage(burst( - (x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c), - (x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c) - )); - } -} diff --git a/src/main/java/art/arcane/iris/engine/mode/ModeOverworld.java b/src/main/java/art/arcane/iris/engine/mode/ModeOverworld.java deleted file mode 100644 index 3534e2f78..000000000 --- a/src/main/java/art/arcane/iris/engine/mode/ModeOverworld.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.mode; - -import art.arcane.iris.engine.actuator.IrisBiomeActuator; -import art.arcane.iris.engine.actuator.IrisDecorantActuator; -import art.arcane.iris.engine.actuator.IrisTerrainNormalActuator; -import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.framework.EngineMode; -import art.arcane.iris.engine.framework.EnginePlatformHooks; -import art.arcane.iris.engine.framework.EngineStage; -import art.arcane.iris.engine.framework.IrisEngineMode; -import art.arcane.iris.engine.modifier.IrisCarveModifier; -import art.arcane.iris.engine.modifier.IrisCustomModifier; -import art.arcane.iris.engine.modifier.IrisDepositModifier; -import art.arcane.iris.engine.modifier.IrisFloatingChildBiomeModifier; -import art.arcane.iris.engine.modifier.IrisPostModifier; -import art.arcane.iris.spi.IrisLogging; - -import java.util.concurrent.atomic.AtomicLong; - -public class ModeOverworld extends IrisEngineMode implements EngineMode { - private static final AtomicLong lastMaintenanceBypassLog = new AtomicLong(0L); - private final EnginePlatformHooks platformHooks; - - public ModeOverworld(Engine engine) { - super(engine); - platformHooks = engine.getPlatformHooks(); - IrisTerrainNormalActuator terrain = new IrisTerrainNormalActuator(getEngine()); - IrisBiomeActuator biome = new IrisBiomeActuator(getEngine()); - IrisDecorantActuator decorant = new IrisDecorantActuator(getEngine()); - IrisCarveModifier cave = new IrisCarveModifier(getEngine()); - IrisPostModifier post = new IrisPostModifier(getEngine()); - IrisDepositModifier deposit = new IrisDepositModifier(getEngine()); - IrisCustomModifier custom = new IrisCustomModifier(getEngine()); - IrisFloatingChildBiomeModifier floatingChildBiomes = new IrisFloatingChildBiomeModifier(getEngine()); - EngineStage sBiome = (x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c); - EngineStage sGenMatter = (x, z, k, p, m, c) -> { - if (shouldBypassMantleStages()) { - return; - } - generateMatter( - x >> 4, - z >> 4, - m || getEngine().isStudio(), - c); - }; - EngineStage sTerrain = (x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c); - EngineStage sDecorant = (x, z, k, p, m, c) -> decorant.actuate(x, z, k, m, c); - EngineStage sCave = (x, z, k, p, m, c) -> { - if (shouldBypassMantleStages()) { - return; - } - cave.modify(x >> 4, z >> 4, k, m, c); - }; - EngineStage sDeposit = (x, z, k, p, m, c) -> { - if (shouldBypassMantleStages()) { - return; - } - deposit.modify(x, z, k, m, c); - }; - EngineStage sPost = (x, z, k, p, m, c) -> { - if (shouldBypassMantleStages()) { - return; - } - post.modify(x, z, k, m, c); - }; - EngineStage sInsertMatter = (x, z, K, p, m, c) -> { - if (shouldBypassMantleStages()) { - return; - } - getMantle().insertMatter(x >> 4, z >> 4, K, m); - }; - EngineStage sFloatingTerrainSolid = (x, z, k, p, m, c) -> floatingChildBiomes.modify(x, z, k, m, c); - EngineStage sFloatingDecorate = (x, z, k, p, m, c) -> floatingChildBiomes.decorateColumns(x, z, k, m, c); - EngineStage sCustom = (x, z, k, p, m, c) -> { - if (shouldBypassMantleStages()) { - return; - } - custom.modify(x, z, k, m, c); - }; - - registerStage(burst( - sBiome, - sGenMatter, - sTerrain - )); - registerStage(sCave); - registerStage(sPost); - registerStage(sFloatingTerrainSolid); - // Never burst these three: all of them write the same block hunk (and sDecorant reads - // the surface sInsertMatter writes), so parallel order is scheduler-dependent. The - // production path already runs them inline in this order; sequential registration - // makes studio (the only multicore path) match production and the goldenhash baseline. - registerStage(sDeposit); - registerStage(sInsertMatter); - registerStage(sDecorant); - registerStage(sFloatingDecorate); - registerStage(sCustom); - } - - private boolean shouldBypassMantleStages() { - boolean active = platformHooks.shouldBypassMantleStages(getEngine()); - if (active) { - long now = System.currentTimeMillis(); - long last = lastMaintenanceBypassLog.get(); - if (now - last >= 5000L && lastMaintenanceBypassLog.compareAndSet(last, now)) { - IrisLogging.info("Maintenance regen bypass: skipping mantle-backed overworld stages for Folia safety."); - } - } - return active; - } -} diff --git a/src/main/java/art/arcane/iris/engine/mode/ModeSuperFlat.java b/src/main/java/art/arcane/iris/engine/mode/ModeSuperFlat.java deleted file mode 100644 index 6cc04308b..000000000 --- a/src/main/java/art/arcane/iris/engine/mode/ModeSuperFlat.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.mode; - -import art.arcane.iris.engine.actuator.IrisBiomeActuator; -import art.arcane.iris.engine.actuator.IrisTerrainNormalActuator; -import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.framework.EngineMode; -import art.arcane.iris.engine.framework.IrisEngineMode; - -public class ModeSuperFlat extends IrisEngineMode implements EngineMode { - public ModeSuperFlat(Engine engine) { - super(engine); - var terrain = new IrisTerrainNormalActuator(getEngine()); - var biome = new IrisBiomeActuator(getEngine()); - - registerStage(burst( - (x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c), - (x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c) - )); - } -} diff --git a/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java b/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java new file mode 100644 index 000000000..476645917 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java @@ -0,0 +1,78 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.carve.CarveStages; +import art.arcane.iris.builtin.terrain.TerrainStages; +import art.arcane.iris.core.modules.IrisChunk; +import art.arcane.iris.core.modules.IrisMantleChunk; +import art.arcane.iris.engine.mantle.components.CaveCarving; +import art.arcane.iris.engine.object.world.dimension.IrisDimension; +import art.arcane.volmlib.util.mantle.flag.ReservedFlag; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.MantleStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:carve}: caves. A mantle stage plans them into the mantle, reaching one block into each + * neighboring chunk where blended cave walls cross the border; a chunk stage later cuts them out of the chunk's + * terrain. The mantle stage is a port of what was Iris's carving mantle component, its work done by + * {@link CaveCarving}, one per engine runtime. The chunk stage is a thin wrapper around {@link IrisCarveModifier}. + */ +public final class CarveModule implements IrisModule { + private static final String VERSION = "built-in"; + /** Blended cave walls reach one block past the chunk. */ + private static final int CAVE_REACH_BLOCKS = 1; + private static final int CHUNK_SHIFT = 4; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:carve", "Caves", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(CarveStages.CAVES).reach(CAVE_REACH_BLOCKS).run(CarveModule::planCaves); + graph.define(CarveStages.APPLY).requires(TerrainStages.SHAPE).run(CarveModule::applyCaves); + } + + private static void planCaves(MantleStageContext context) { + IrisMantleChunk chunk = IrisMantleChunk.current(); + if (!carves(chunk.engine().getDimension())) { + return; + } + chunk.state(CaveCarving.class, CaveCarving::new).carve(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context()); + } + + private static void applyCaves(ChunkStageContext context) { + IrisChunk chunk = IrisChunk.current(); + if (chunk.bypassesMantleStages()) { + return; + } + chunk.state(IrisCarveModifier.class, IrisCarveModifier::new).modify(chunk.originX() >> CHUNK_SHIFT, chunk.originZ() >> CHUNK_SHIFT, + chunk.blocks(), chunk.multicore(), chunk.context()); + } + + /** A dimension turns carving off with {@code carvingEnabled}, or by listing {@code CARVED} in {@code disabledComponents}. */ + private static boolean carves(IrisDimension dimension) { + return dimension.isCarvingEnabled() && !dimension.getDisabledComponents().contains(ReservedFlag.CARVED); + } +} diff --git a/src/main/java/art/arcane/iris/engine/modifier/CustomModule.java b/src/main/java/art/arcane/iris/engine/modifier/CustomModule.java new file mode 100644 index 000000000..1be418b26 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/CustomModule.java @@ -0,0 +1,55 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.custom.CustomStages; +import art.arcane.iris.builtin.perfection.PerfectionStages; +import art.arcane.iris.core.modules.IrisChunk; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:custom}: records the chunk's content-plugin blocks for the server to place later. A thin + * wrapper: the stage runs {@link IrisCustomModifier} unchanged, one per engine runtime, except while + * maintenance regeneration bypasses the mantle. + */ +public final class CustomModule implements IrisModule { + private static final String VERSION = "built-in"; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:custom", "Custom blocks", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(CustomStages.BLOCKS).requires(PerfectionStages.SURFACE).run(CustomModule::record); + } + + private static void record(ChunkStageContext context) { + IrisChunk chunk = IrisChunk.current(); + if (chunk.bypassesMantleStages()) { + return; + } + chunk.state(IrisCustomModifier.class, IrisCustomModifier::new) + .modify(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); + } +} diff --git a/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java b/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java new file mode 100644 index 000000000..cdbc14311 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/DepositModule.java @@ -0,0 +1,78 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.deposit.DepositSettings; +import art.arcane.iris.builtin.deposit.DepositStages; +import art.arcane.iris.builtin.floating.FloatingStages; +import art.arcane.iris.builtin.terrain.TerrainStages; +import art.arcane.iris.core.modules.IrisChunk; +import art.arcane.iris.engine.object.terrain.deposit.IrisDepositGenerator; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.config.FeatureSettings; +import com.volmit.config.FeatureSettings.Entry; +import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.StageGraph; + +import java.util.List; + +/** + * Module {@code iris:deposit}: ores and other deposits. The dimension, a region and a biome each declare their + * own {@link DepositSettings}, and they stack: a chunk gets every level's deposits at its centre column, the + * dimension's first, then the region's, then the biome's. The stage runs where any column of the chunk has + * deposits, but places only what the centre column declares, so a chunk's deposits do not depend on which + * of its columns a biome border crosses. + */ +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() { + return ModuleInfo.of("iris:deposit", "Deposits", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(DepositStages.ORES) + .when(DepositSettings.class) + .requires(TerrainStages.SHAPE) + .softAfter(FloatingStages.SOLIDS.ref()) + .run(DepositModule::place); + } + + 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()) { + return; + } + chunk.state(DepositPlacer.class, DepositPlacer::new).generate(generators, chunk.blocks(), + chunk.originX() >> CHUNK_SHIFT, chunk.originZ() >> CHUNK_SHIFT, chunk.multicore(), chunk.context()); + } + + /** Every level's generators at the centre column of the chunk whose first block is {@code originX}, {@code originZ}, in level order. */ + static List generatorsAtCentre(FeatureSettings settings, int originX, int originZ) { + return settings.at(DepositSettings.class, originX + CHUNK_CENTRE, originZ + CHUNK_CENTRE).stream() + .flatMap(entry -> entry.value().generators().stream()) + .toList(); + } +} diff --git a/src/main/java/art/arcane/iris/engine/modifier/IrisDepositModifier.java b/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java similarity index 91% rename from src/main/java/art/arcane/iris/engine/modifier/IrisDepositModifier.java rename to src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java index 796c5d103..21e944c01 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/IrisDepositModifier.java +++ b/src/main/java/art/arcane/iris/engine/modifier/DepositPlacer.java @@ -19,7 +19,7 @@ package art.arcane.iris.engine.modifier; import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.framework.EngineAssignedModifier; +import art.arcane.iris.engine.framework.EngineAssignedComponent; import art.arcane.iris.engine.object.world.biome.IrisBiome; import art.arcane.iris.engine.object.terrain.deposit.IrisDepositGenerator; import art.arcane.iris.engine.object.terrain.deposit.IrisDepositHeightDistribution; @@ -41,41 +41,37 @@ import art.arcane.volmlib.util.scheduling.PrecisionStopwatch; import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.util.common.data.B; -public class IrisDepositModifier extends EngineAssignedModifier { +import java.util.List; + +/** + * Places deposit clumps into one chunk for {@link DepositModule}: one per engine runtime, holding the deposit + * stream's random. Each generator gets its own random, derived from the chunk and its position in the list. + */ +public class DepositPlacer extends EngineAssignedComponent { private final RNG rng; - public IrisDepositModifier(Engine engine) { + public DepositPlacer(Engine engine) { super(engine, "Deposit"); rng = new RNG(getEngine().getSeedManager().getDeposit()); } - @Override - public void onModify(int x, int z, Hunk output, boolean multicore, ChunkContext context) { + /** 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(output, Math.floorDiv(x, 16), Math.floorDiv(z, 16), multicore, context); + generateDeposits(generators, terrain, x, z, multicore, context); getEngine().getMetrics().getDeposit().put(p.getMilliseconds()); } - public void generateDeposits(Hunk terrain, int x, int z, boolean multicore, ChunkContext context) { - IrisRegion region = context.getRegion().get(7, 7); - IrisBiome biome = context.getBiome().get(7, 7); + private void generateDeposits(List generators, Hunk terrain, int x, int z, + boolean multicore, ChunkContext context) { BurstExecutor burst = burst().burst(multicore); long seed = x * 341873128712L + z * 132897987541L; long mask = 0; MantleChunk chunk = getEngine().getMantle().getMantle().getChunk(x, z).use(); try { - for (IrisDepositGenerator k : getDimension().getDeposits()) { - long finalSeed = seed * ++mask; - burst.queue(() -> generate(k, chunk, terrain, rng.nextParallelRNG(finalSeed), x, z, false, context)); - } - - for (IrisDepositGenerator k : region.getDeposits()) { - long finalSeed = seed * ++mask; - burst.queue(() -> generate(k, chunk, terrain, rng.nextParallelRNG(finalSeed), x, z, false, context)); - } - - for (IrisDepositGenerator k : biome.getDeposits()) { + for (IrisDepositGenerator k : generators) { long finalSeed = seed * ++mask; burst.queue(() -> generate(k, chunk, terrain, rng.nextParallelRNG(finalSeed), x, z, false, context)); } diff --git a/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java b/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java new file mode 100644 index 000000000..dc260c18d --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java @@ -0,0 +1,62 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.decorant.DecorantStages; +import art.arcane.iris.builtin.floating.FloatingStages; +import art.arcane.iris.builtin.post.PostStages; +import art.arcane.iris.core.modules.IrisChunk; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:floating}: the islands of floating child biomes, their solids after smoothing and their + * decoration after the chunk's own. A thin wrapper: both stages run {@link IrisFloatingChildBiomeModifier} + * unchanged, one per engine runtime. + */ +public final class FloatingModule implements IrisModule { + private static final String VERSION = "built-in"; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:floating", "Floating islands", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(FloatingStages.SOLIDS).requires(PostStages.SMOOTH).run(FloatingModule::solids); + graph.define(FloatingStages.DECORATE).requires(DecorantStages.DECORATE).run(FloatingModule::decorate); + } + + private static void solids(ChunkStageContext context) { + IrisChunk chunk = IrisChunk.current(); + islands(chunk).modify(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); + } + + private static void decorate(ChunkStageContext context) { + IrisChunk chunk = IrisChunk.current(); + islands(chunk).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); + } + + private static IrisFloatingChildBiomeModifier islands(IrisChunk chunk) { + return chunk.state(IrisFloatingChildBiomeModifier.class, IrisFloatingChildBiomeModifier::new); + } +} diff --git a/src/main/java/art/arcane/iris/engine/modifier/MatterModule.java b/src/main/java/art/arcane/iris/engine/modifier/MatterModule.java new file mode 100644 index 000000000..b36865087 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/MatterModule.java @@ -0,0 +1,59 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.deposit.DepositStages; +import art.arcane.iris.builtin.floating.FloatingStages; +import art.arcane.iris.builtin.matter.MatterStages; +import art.arcane.iris.core.modules.IrisChunk; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:matter}: copies the blocks the mantle planned for the chunk, its objects and structures, + * into it. A thin wrapper around the engine mantle's own insertion. It orders itself after deposits without + * requiring them, since deposits run only where a level declares some. + */ +public final class MatterModule implements IrisModule { + private static final String VERSION = "built-in"; + private static final int CHUNK_SHIFT = 4; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:matter", "Mantle blocks", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(MatterStages.INSERT) + .requires(FloatingStages.SOLIDS) + .softAfter(DepositStages.ORES.ref()) + .run(MatterModule::insert); + } + + private static void insert(ChunkStageContext context) { + IrisChunk chunk = IrisChunk.current(); + if (chunk.bypassesMantleStages()) { + return; + } + chunk.engine().getMantle().insertMatter(chunk.originX() >> CHUNK_SHIFT, chunk.originZ() >> CHUNK_SHIFT, chunk.blocks(), chunk.multicore()); + } +} diff --git a/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java b/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java index 4a2f8b5e8..2019f94f0 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/PerfectionModule.java @@ -18,12 +18,12 @@ package art.arcane.iris.engine.modifier; +import art.arcane.iris.builtin.floating.FloatingStages; import art.arcane.iris.builtin.perfection.PerfectionStages; import art.arcane.iris.core.modules.IrisChunk; import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks; import art.arcane.iris.engine.object.world.dimension.IrisDimension; -import art.arcane.iris.engine.object.world.dimension.IrisDimensionModeType; import art.arcane.iris.spi.PlatformBlockState; import art.arcane.iris.util.common.data.B; import art.arcane.iris.util.project.hunk.Hunk; @@ -39,7 +39,7 @@ import java.util.List; import java.util.Map; /** - * Module {@code iris:perfection}: on overworld chunks, turns ores back into the stone around them when the + * Module {@code iris:perfection}: turns ores back into the stone around them when the * dimension hides its ores, then removes decorations whose block below cannot hold them, again until none * is left, since removing one can strand the one above. */ @@ -60,16 +60,13 @@ public final class PerfectionModule implements IrisModule { @Override public void install(StageGraph graph) { - graph.define(PerfectionStages.SURFACE).run(PerfectionModule::perfect); + graph.define(PerfectionStages.SURFACE).requires(FloatingStages.DECORATE).run(PerfectionModule::perfect); } private static void perfect(ChunkStageContext context) { IrisChunk chunk = IrisChunk.current(); Engine engine = chunk.engine(); IrisDimension dimension = engine.getDimension(); - if (dimension.getMode().getType() != IrisDimensionModeType.OVERWORLD) { - return; - } PrecisionStopwatch stopwatch = PrecisionStopwatch.start(); Hunk blocks = chunk.blocks(); if (dimension.isHideOresForHiddenOre()) { diff --git a/src/main/java/art/arcane/iris/engine/modifier/PostModule.java b/src/main/java/art/arcane/iris/engine/modifier/PostModule.java new file mode 100644 index 000000000..f34ef829c --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/modifier/PostModule.java @@ -0,0 +1,54 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package art.arcane.iris.engine.modifier; + +import art.arcane.iris.builtin.carve.CarveStages; +import art.arcane.iris.builtin.post.PostStages; +import art.arcane.iris.core.modules.IrisChunk; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:post}: smooths the carved surface. A thin wrapper: the stage runs {@link IrisPostModifier} + * unchanged, one per engine runtime, except while maintenance regeneration bypasses the mantle. + */ +public final class PostModule implements IrisModule { + private static final String VERSION = "built-in"; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:post", "Post-processing", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(PostStages.SMOOTH).requires(CarveStages.APPLY).run(PostModule::smooth); + } + + private static void smooth(ChunkStageContext context) { + IrisChunk chunk = IrisChunk.current(); + if (chunk.bypassesMantleStages()) { + return; + } + chunk.state(IrisPostModifier.class, IrisPostModifier::new) + .modify(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); + } +} diff --git a/src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java b/src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java index f2bab53ca..10f40aafc 100644 --- a/src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java +++ b/src/main/java/art/arcane/iris/engine/object/world/biome/IrisBiome.java @@ -33,7 +33,6 @@ import art.arcane.iris.engine.object.terrain.IrisBiomeLayerGenerator; import art.arcane.iris.engine.object.terrain.IrisBiomePaletteLayer; import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile; import art.arcane.iris.engine.object.terrain.deposit.IrisBiomeOres; -import art.arcane.iris.engine.object.terrain.deposit.IrisDepositGenerator; import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant; import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator; import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds; @@ -225,9 +224,6 @@ public class IrisBiome extends IrisRegistrant implements IRare { @ArrayType(min = 1, type = IrisBiomeGeneratorLink.class) @Desc("Generators for this biome. Multiple generators with different interpolation sizes will mix with other biomes how you would expect. This defines your biome height relative to the fluid height. Use negative for oceans.") private KList generators = new KList().qadd(new IrisBiomeGeneratorLink()); - @ArrayType(min = 1, type = IrisDepositGenerator.class) - @Desc("Define biome deposit generators that add onto the existing regional and global deposit generators") - private KList deposits = new KList<>(); @MinNumber(0) @MaxNumber(1) @Desc("Multiplier applied to the frequency of every ore deposit whose center is inside this biome. A value of 0.4 keeps 40% of ore veins while leaving non-ore deposits unchanged.") diff --git a/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimension.java b/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimension.java index 899ccc241..aad10040f 100644 --- a/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimension.java +++ b/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimension.java @@ -35,7 +35,6 @@ import art.arcane.iris.engine.object.structure.IrisStructurePlacement; import art.arcane.iris.engine.object.structure.vanilla.IrisImportedStructureControl; import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile; import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry; -import art.arcane.iris.engine.object.terrain.deposit.IrisDepositGenerator; import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant; import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator; import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds; @@ -250,9 +249,6 @@ public class IrisDimension extends IrisRegistrant { @MaxNumber(360) @Desc("You can rotate the input coordinates by an angle. This can make terrain appear more natural (less sharp corners and lines). This literally rotates the entire dimension by an angle. Hint: Try 12 degrees or something not on a 90 or 45 degree angle.") private double dimensionAngleDeg = 0; - @Required - @Desc("Define the mode of this dimension (required!)") - private IrisDimensionMode mode = new IrisDimensionMode(); @MinNumber(0) @MaxNumber(8192) @Desc("Coordinate fracturing applies noise to the input coordinates. This creates the 'iris swirls' and wavy features. The distance pushes these waves further into places they shouldnt be. This is a block value multiplier.") @@ -281,9 +277,6 @@ public class IrisDimension extends IrisRegistrant { private boolean useMantle = true; @Desc("Prevent Leaf decay as if placed in creative mode") private boolean preventLeafDecay = false; - @ArrayType(min = 1, type = IrisDepositGenerator.class) - @Desc("Define global deposit generators") - private KList deposits = new KList<>(); @ArrayType(min = 1, type = IrisDepositVariant.class) @Desc("Dimension-wide deposit ore remap rules. Each entry declares a vertical band and a source->replacement block id map. Applied after biome and region rules; first matching dimension rule wins.") private KList depositVariants = new KList<>(); diff --git a/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionMode.java b/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionMode.java deleted file mode 100644 index fc2f39358..000000000 --- a/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionMode.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.object.world.dimension; - -import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.framework.EngineMode; -import art.arcane.iris.engine.object.annotations.Desc; -import art.arcane.iris.engine.object.annotations.Snippet; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; - -@Snippet("dimension-mode") -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor -@Desc("Represents a dimensional mode") -@Data -public class IrisDimensionMode { - @Desc("The dimension type") - private IrisDimensionModeType type = IrisDimensionModeType.OVERWORLD; - - public EngineMode create(Engine engine) { - return type.create(engine); - } -} diff --git a/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionModeType.java b/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionModeType.java deleted file mode 100644 index c2a248b3c..000000000 --- a/src/main/java/art/arcane/iris/engine/object/world/dimension/IrisDimensionModeType.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2022 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.object.world.dimension; - -import art.arcane.iris.engine.framework.Engine; -import art.arcane.iris.engine.framework.EngineMode; -import art.arcane.iris.engine.mode.ModeEnclosure; -import art.arcane.iris.engine.mode.ModeIslands; -import art.arcane.iris.engine.mode.ModeOverworld; -import art.arcane.iris.engine.mode.ModeSuperFlat; -import art.arcane.iris.engine.object.annotations.Desc; - -import java.util.function.Function; - -@Desc("The type of dimension this is") -public enum IrisDimensionModeType { - @Desc("Typical dimensions. Has a fluid height, and all features of a biome based world") - OVERWORLD(ModeOverworld::new), - - @Desc("Ultra fast, but very limited in features. Only supports terrain & biomes. No decorations, mobs, objects, or anything of the sort!") - SUPERFLAT(ModeSuperFlat::new), - - @Desc("Like the nether, a ceiling & floor carved out") - ENCLOSURE(ModeEnclosure::new), - - @Desc("Floating islands of terrain") - ISLANDS(ModeIslands::new), - ; - private final Function factory; - - IrisDimensionModeType(Function factory) { - this.factory = factory; - } - - public EngineMode create(Engine e) { - return factory.apply(e); - } -} diff --git a/src/main/java/art/arcane/iris/engine/object/world/region/IrisRegion.java b/src/main/java/art/arcane/iris/engine/object/world/region/IrisRegion.java index 59a08e80c..b128642a1 100644 --- a/src/main/java/art/arcane/iris/engine/object/world/region/IrisRegion.java +++ b/src/main/java/art/arcane/iris/engine/object/world/region/IrisRegion.java @@ -26,7 +26,6 @@ import art.arcane.iris.engine.object.placement.IrisObjectPlacement; import art.arcane.iris.engine.object.procedural.IrisProceduralObjects; import art.arcane.iris.engine.object.structure.IrisStructurePlacement; import art.arcane.iris.engine.object.terrain.carving.IrisCaveProfile; -import art.arcane.iris.engine.object.terrain.deposit.IrisDepositGenerator; import art.arcane.iris.engine.object.terrain.deposit.IrisDepositVariant; import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator; import art.arcane.iris.engine.object.terrain.deposit.IrisOreGeneratorBounds; @@ -150,9 +149,6 @@ public class IrisRegion extends IrisRegistrant implements IRare { @ArrayType(min = 1, type = String.class) @Desc("A list of root-level cave biomes in this region, used for carved cave interiors. Don't specify child biomes of other biomes here. Just the root parents.") private KList caveBiomes = new KList<>(); - @ArrayType(min = 1, type = IrisDepositGenerator.class) - @Desc("Define regional deposit generators that add onto the global deposit generators") - private KList deposits = new KList<>(); @ArrayType(min = 1, type = IrisDepositVariant.class) @Desc("Deposit ore remap rules scoped to this region. Each entry declares a vertical band and a source->replacement block id map. Applied after biome rules but before dimension rules; first matching region rule wins.") private KList depositVariants = new KList<>();