diff --git a/README.md b/README.md index f1ba758e0..daefa6d7c 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,20 @@ 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 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:vacuum`, `iris:snow`), the mantle, and chunk generation. Every mantle stage is a pass of Iris's +mantle of its own, in the stage graph's order: `iris:carve/caves`, `iris:objects/place`, +`iris:floating/objects`, `iris:structure/place`, so a pack's mantle stage can order itself after any of +them. Chunk generation then runs, in this order: `iris:biome`, `iris:terrain`, `iris:carve` (cutting the +planned caves), `iris:post`, `iris:floating` (solids), `iris:deposit`, `iris:matter`, `iris:decorant`, +`iris:floating` (decoration), `iris:perfection` and `iris:custom`. There are no world modes and no Iris +mantle components outside the stage graph 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:biome` and `iris:deposit` (chunk stages) and every mantle stage (caves, objects, floating objects, +structures) are full ports: the module owns its logic and per-engine state, and the mantle stages work out +their reach from the pack when it loads. The other chunk stages are thin wrappers that run the existing +actuator or modifier unchanged. 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/src/main/java/art/arcane/iris/builtin/floating/FloatingStages.java b/src/main/java/art/arcane/iris/builtin/floating/FloatingStages.java index d3deb4680..19f1282e9 100644 --- a/src/main/java/art/arcane/iris/builtin/floating/FloatingStages.java +++ b/src/main/java/art/arcane/iris/builtin/floating/FloatingStages.java @@ -19,10 +19,13 @@ package art.arcane.iris.builtin.floating; import com.volmit.stage.ChunkStage; +import com.volmit.stage.MantleStage; import com.volmit.stage.Stage; /** Module {@code iris:floating}: the floating islands of floating child biomes. */ public final class FloatingStages { + /** Places the objects on and under the islands into the mantle, after the dimension's other objects. */ + public static final MantleStage OBJECTS = Stage.mantle("iris:floating/objects"); /** 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. */ diff --git a/src/main/java/art/arcane/iris/builtin/objects/ObjectStages.java b/src/main/java/art/arcane/iris/builtin/objects/ObjectStages.java new file mode 100644 index 000000000..9917dd1ab --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/objects/ObjectStages.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.objects; + +import com.volmit.stage.MantleStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:objects}: the objects the dimension's regions and biomes place. */ +public final class ObjectStages { + /** Places surface, cave and upper-dimension objects into the mantle, after the caves they anchor in. */ + public static final MantleStage PLACE = Stage.mantle("iris:objects/place"); + + private ObjectStages() { + } +} diff --git a/src/main/java/art/arcane/iris/builtin/structure/StructureStages.java b/src/main/java/art/arcane/iris/builtin/structure/StructureStages.java new file mode 100644 index 000000000..5ea26c630 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/structure/StructureStages.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.structure; + +import com.volmit.stage.MantleStage; +import com.volmit.stage.Stage; + +/** Module {@code iris:structure}: Iris structures, assembled from pieces. */ +public final class StructureStages { + /** Places the structures of the dimension, its regions and biomes into the mantle, after objects and floating objects. */ + public static final MantleStage PLACE = Stage.mantle("iris:structure/place"); + + private StructureStages() { + } +} diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/MantleFloatingObjectComponent.java b/src/main/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacing.java similarity index 95% rename from src/main/java/art/arcane/iris/engine/mantle/components/MantleFloatingObjectComponent.java rename to src/main/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacing.java index 8a1bfc446..249c80a13 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/MantleFloatingObjectComponent.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/FloatingObjectPlacing.java @@ -22,9 +22,7 @@ import art.arcane.iris.engine.object.placement.IrisObjectPlacement; import art.arcane.iris.core.loader.IrisData; import art.arcane.iris.engine.IrisComplex; import art.arcane.iris.engine.data.cache.Cache; -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.terrain.floating.FloatingIslandSample; import art.arcane.iris.engine.object.placement.FloatingObjectFootprint; @@ -43,7 +41,6 @@ import art.arcane.iris.util.common.math.IrisBlockVector; import art.arcane.iris.util.project.context.ChunkContext; import art.arcane.volmlib.util.collection.KList; import art.arcane.volmlib.util.documentation.ChunkCoordinates; -import art.arcane.volmlib.util.mantle.flag.ReservedFlag; import art.arcane.volmlib.util.math.RNG; import java.io.File; @@ -53,23 +50,29 @@ import java.util.IdentityHashMap; import java.util.Map; import java.util.Set; -@ComponentFlag(ReservedFlag.FLOATING_OBJECT) -public class MantleFloatingObjectComponent extends IrisMantleComponent { +/** + * Places the objects of floating child biomes on and under their islands into the mantle for + * {@link art.arcane.iris.engine.modifier.FloatingModule}. One per engine runtime. Its reach is the + * largest placement reach of any floating object the dimension's biomes can place, at least 16 blocks. + */ +public class FloatingObjectPlacing { private static final int INVERTED_PICK_ATTEMPTS = 8; private static final IrisObjectRotation ROTATION_NONE = IrisObjectRotation.of(0, 0, 0); - public MantleFloatingObjectComponent(EngineMantle engineMantle) { - super(engineMantle, ReservedFlag.FLOATING_OBJECT, 2); + private final Engine engine; + + public FloatingObjectPlacing(Engine engine) { + this.engine = engine; } - @Override - public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) { + /** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */ + public void place(MantleWriter writer, int x, int z, ChunkContext context) { IrisComplex complex = context.getComplex(); - IrisData data = getData(); + IrisData data = engine.getData(); int minX = x << 4; int minZ = z << 4; - RNG chunkRng = new RNG(Cache.key(x, z) + seed() + 0x0FA710BEL); - FloatingIslandSampleResolver sampleResolver = new FloatingIslandSampleResolver(getEngineMantle(), context.getFloatingIslandBoundarySampler()); + RNG chunkRng = new RNG(Cache.key(x, z) + engine.getSeedManager().getMantle() + 0x0FA710BEL); + FloatingIslandSampleResolver sampleResolver = new FloatingIslandSampleResolver(engine.getMantle(), context.getFloatingIslandBoundarySampler()); FloatingIslandSample.clearChunkMemo(); @@ -543,14 +546,14 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent { }; } - @Override - protected int computeRadius() { + /** How far, in blocks along X and Z, placements may write beyond their chunk. */ + public int reach() { int maxObjectExtent = 16; Map sizeCache = new HashMap<>(); Set warnedLargeObjects = new HashSet<>(); try { - IrisData data = getData(); - for (IrisBiome biome : getDimension().getReachableBiomes(this::getData)) { + IrisData data = engine.getData(); + for (IrisBiome biome : engine.getDimension().getReachableBiomes(engine)) { KList entries = biome.getFloatingChildBiomes(); if (entries == null || entries.isEmpty()) { continue; @@ -599,7 +602,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent { size = IrisObject.sampleSize(file); sizeCache.put(objectKey, size); } - int reach = MantleObjectComponent.calculatePlacementReach(size, placement); + int reach = ObjectPlacing.calculatePlacementReach(size, placement); if (reach > 128 && warnedLargeObjects.add(objectKey)) { IrisLogging.warn("Floating object " + objectKey + " has a large placement reach (" + reach + " blocks) and may increase memory usage!"); } diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/ObjectModule.java b/src/main/java/art/arcane/iris/engine/mantle/components/ObjectModule.java new file mode 100644 index 000000000..b1b1734fc --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/mantle/components/ObjectModule.java @@ -0,0 +1,63 @@ +/* + * 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.mantle.components; + +import art.arcane.iris.builtin.carve.CarveStages; +import art.arcane.iris.builtin.objects.ObjectStages; +import art.arcane.iris.core.modules.IrisMantleChunk; +import art.arcane.iris.core.modules.IrisPackSettings; +import art.arcane.iris.engine.framework.Engine; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.config.PackSettings; +import com.volmit.stage.MantleStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:objects}: the objects the dimension's regions and biomes place, written into the mantle + * once the caves they may anchor in are planned. A port of what was Iris's object mantle component, its work + * done by {@link ObjectPlacing}, one per engine runtime. Its reach is the pack's largest object placement. + */ +public final class ObjectModule implements IrisModule { + private static final String VERSION = "built-in"; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:objects", "Objects", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(ObjectStages.PLACE).requires(CarveStages.CAVES).reach(ObjectModule::reach).run(ObjectModule::place); + } + + private static void place(MantleStageContext context) { + IrisMantleChunk chunk = IrisMantleChunk.current(); + placing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context()); + } + + private static int reach(PackSettings settings) { + return placing(IrisPackSettings.of(settings).engine()).reach(); + } + + /** The engine runtime's object placing, which {@link Engine#getObjectsAt} also asks. */ + public static ObjectPlacing placing(Engine engine) { + return engine.getGeneration().state(ObjectPlacing.class, ObjectPlacing::new); + } +} diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/MantleObjectComponent.java b/src/main/java/art/arcane/iris/engine/mantle/components/ObjectPlacing.java similarity index 96% rename from src/main/java/art/arcane/iris/engine/mantle/components/MantleObjectComponent.java rename to src/main/java/art/arcane/iris/engine/mantle/components/ObjectPlacing.java index 94ccb244e..8702ababf 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/MantleObjectComponent.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/ObjectPlacing.java @@ -26,9 +26,6 @@ import art.arcane.iris.util.common.data.B; import art.arcane.iris.engine.data.cache.Cache; 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.mantle.MantleWriter; import art.arcane.iris.engine.framework.Engine; import art.arcane.iris.engine.framework.TreeBlockMaterial; @@ -55,7 +52,6 @@ import art.arcane.volmlib.util.collection.KSet; import art.arcane.iris.util.project.context.ChunkContext; import art.arcane.volmlib.util.documentation.BlockCoordinates; import art.arcane.volmlib.util.documentation.ChunkCoordinates; -import art.arcane.volmlib.util.mantle.flag.ReservedFlag; import art.arcane.volmlib.util.math.RNG; import art.arcane.volmlib.util.matter.MatterCavern; import art.arcane.volmlib.util.matter.MatterStructurePOI; @@ -74,16 +70,23 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -@ComponentFlag(ReservedFlag.OBJECT) -public class MantleObjectComponent extends IrisMantleComponent { +/** + * Places the objects of the dimension's regions and biomes into the mantle for + * {@link ObjectModule}: surface, cave and upper-dimension objects, and procedural objects, one chunk at a + * time after the caves they anchor in are planned. One per engine runtime. Its reach is the largest + * placement reach of any object the dimension can place. + */ +public class ObjectPlacing { private static final long CAVE_REJECT_LOG_THROTTLE_MS = 5000L; private static final int BEDROCK_CLEARANCE = 6; private static final byte LIQUID_FORCED_AIR = 3; private static final Map CAVE_REJECT_LOG_STATE = new ConcurrentHashMap<>(); private static final Set MISSING_LOAD_KEY_WARNED = ConcurrentHashMap.newKeySet(); - public MantleObjectComponent(EngineMantle engineMantle) { - super(engineMantle, ReservedFlag.OBJECT, 1); + private final Engine engine; + + public ObjectPlacing(Engine engine) { + this.engine = engine; } private static String placementMarker(IrisObject object, int id, String context) { @@ -111,21 +114,21 @@ public class MantleObjectComponent extends IrisMantleComponent { placer.setData(x, y, z, TreeBlockMaterial.of(data)); } - @Override - public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) { + /** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */ + public void place(MantleWriter writer, int x, int z, ChunkContext context) { IrisComplex complex = context.getComplex(); boolean traceRegen = isRegenTraceThread(); - RNG rng = applyNoise(x, z, Cache.key(x, z) + seed()); + RNG rng = applyNoise(x, z, Cache.key(x, z) + engine.getSeedManager().getMantle()); int xxx = 8 + (x << 4); int zzz = 8 + (z << 4); IrisRegion region = complex.getRegionStream().get(xxx, zzz); IrisBiome surfaceBiome = complex.getTrueBiomeStream().get(xxx, zzz); - int surfaceY = getEngineMantle().getEngine().getHeight(xxx, zzz, true); + int surfaceY = engine.getHeight(xxx, zzz, true); IrisBiome caveBiome = resolveCaveObjectBiome(xxx, zzz, surfaceY, surfaceBiome); if (IrisSettings.get().getGeneral().isDebug() && (x & 31) == 0 && (z & 31) == 0) { int carvedBlocks = 0; int minY = 1; - int maxY = Math.min(getEngineMantle().getEngine().getHeight() - 1, surfaceY - 14); + int maxY = Math.min(engine.getHeight() - 1, surfaceY - 14); for (int sy = minY; sy < maxY; sy++) { if (writer.isCarved(8 + (x << 4), sy, 8 + (z << 4))) { carvedBlocks++; @@ -153,8 +156,8 @@ public class MantleObjectComponent extends IrisMantleComponent { } ObjectPlacementSummary summary = placeObjects(writer, rng, x, z, surfaceBiome, caveBiome, region, complex, traceRegen); placeProceduralObjects(writer, rng, x, z, surfaceBiome, caveBiome, region); - UpperDimensionContext upperCtx = getEngineMantle().getEngine().getUpperContext(); - IrisDimension dimension = getDimension(); + UpperDimensionContext upperCtx = engine.getUpperContext(); + IrisDimension dimension = engine.getDimension(); if (upperCtx != null && dimension.isUpperDimensionObjects()) { placeUpperObjects(writer, rng, x, z, xxx, zzz, surfaceY, upperCtx, dimension, complex, traceRegen); } @@ -183,7 +186,7 @@ public class MantleObjectComponent extends IrisMantleComponent { private IrisBiome resolveCaveObjectBiome(int x, int z, int surfaceY, IrisBiome surfaceBiome) { int legacySampleY = Math.max(1, surfaceY - 48); - IrisBiome legacyCaveBiome = getEngineMantle().getEngine().getCaveBiome(x, legacySampleY, z); + IrisBiome legacyCaveBiome = engine.getCaveBiome(x, legacySampleY, z); if (legacyCaveBiome == null) { legacyCaveBiome = surfaceBiome; } @@ -192,7 +195,7 @@ public class MantleObjectComponent extends IrisMantleComponent { IrisBiome ladderChoice = null; for (int sampleDepth : sampleDepths) { int sampleY = Math.max(1, surfaceY - sampleDepth); - IrisBiome sampled = getEngineMantle().getEngine().getCaveBiome(x, sampleY, z); + IrisBiome sampled = engine.getCaveBiome(x, sampleY, z); boolean sameSurface = sampled == surfaceBiome; if (!sameSurface && sampled != null && surfaceBiome != null) { String sampledKey = sampled.getLoadKey(); @@ -435,7 +438,7 @@ public class MantleObjectComponent extends IrisMantleComponent { IObjectPlacer placer = golden ? new GoldenDebugObjectPlacer(basePlacer, scope + "/" + p.getName()) : basePlacer; int density = Math.max(1, p.getDensity()); for (int i = 0; i < density; i++) { - IrisObject variant = p.getVariantObject(getData(), rng); + IrisObject variant = p.getVariantObject(engine.getData(), rng); if (variant == null) { if (golden) { IrisLogging.debug("Goldendebug procedural pick: chunk=" + x + "," + z @@ -473,7 +476,7 @@ public class MantleObjectComponent extends IrisMantleComponent { int zz = caveAnchor == null ? rng.i(blockZ, blockZ + 16) : caveAnchor.z(); int id = rng.i(0, Integer.MAX_VALUE); if (golden) { - KList pool = p.getVariantObjects(getData()); + KList pool = p.getVariantObjects(engine.getData()); IrisLogging.debug("Goldendebug procedural pick: chunk=" + x + "," + z + " placement=" + p.getName() + " densityIndex=" + i @@ -521,7 +524,7 @@ public class MantleObjectComponent extends IrisMantleComponent { if (treePlacement && marker != null) { writeTreeMaterial(placer, b.getX(), b.getY(), b.getZ(), data); } - }, null, getData()); + }, null, engine.getData()); } if (golden) { IrisLogging.debug("Goldendebug procedural result: chunk=" + x + "," + z @@ -582,7 +585,7 @@ public class MantleObjectComponent extends IrisMantleComponent { underwater, writer.getDataIfPresent(candidateX, candidateY, candidateZ, MatterCavern.class), candidateY, - getDimension().getCaveLavaHeight())) { + engine.getDimension().getCaveLavaHeight())) { continue; } return new CavePlacementAnchor(candidateX, candidateY, candidateZ); @@ -629,7 +632,7 @@ public class MantleObjectComponent extends IrisMantleComponent { if (placement.isDolphinTarget() && placement.isUnderwater() && B.isStorageChest(data)) { transaction.setData(block.getX(), block.getY(), block.getZ(), MatterStructurePOI.BURIED_TREASURE); } - }, null, getData()); + }, null, engine.getData()); if (result < 0) { transaction.discard(); return new ContainedPlacementResult(result, CaveObjectPlacementTransaction.CommitResult.EMPTY); @@ -655,7 +658,7 @@ public class MantleObjectComponent extends IrisMantleComponent { int rejected = 0; int nullObjects = 0; int errors = 0; - int density = objectPlacement.getDensity(rng, x, z, getData()); + int density = objectPlacement.getDensity(rng, x, z, engine.getData()); boolean golden = GoldenDebugObjectPlacer.isGoldenDebugChunk(chunkX, chunkZ); for (int i = 0; i < density; i++) { @@ -699,7 +702,7 @@ public class MantleObjectComponent extends IrisMantleComponent { if (effectivePlacement.isDolphinTarget() && effectivePlacement.isUnderwater() && B.isStorageChest(data)) { writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE); } - }, null, getData()); + }, null, engine.getData()); if (result >= 0) { placed++; @@ -746,7 +749,6 @@ public class MantleObjectComponent extends IrisMantleComponent { if (expectedCaveBiomeKey == null) { return false; } - Engine engine = getEngineMantle().getEngine(); IrisBiome at = engine.getCaveBiome(x, y, z); IrisBiome surface = engine.getSurfaceBiome(x, z); return caveAnchorBiomeConflicts(at, surface, expectedCaveBiomeKey); @@ -788,7 +790,7 @@ public class MantleObjectComponent extends IrisMantleComponent { int errors = 0; int minX = chunkX << 4; int minZ = chunkZ << 4; - int density = objectPlacement.getDensity(rng, minX, minZ, getData()); + int density = objectPlacement.getDensity(rng, minX, minZ, engine.getData()); IrisCaveAnchorMode anchorMode = resolveAnchorMode(objectPlacement, caveProfile); if (objectPlacement.getMode() == ObjectPlaceMode.CEILING_HANG) { anchorMode = IrisCaveAnchorMode.CEILING; @@ -1025,11 +1027,11 @@ public class MantleObjectComponent extends IrisMantleComponent { boolean traceRegen, String scope ) { - int chunkHeight = getEngineMantle().getEngine().getHeight(); + int chunkHeight = engine.getHeight(); int upperGap = dimension.getUpperDimensionGap(); int minX = chunkX << 4; int minZ = chunkZ << 4; - int density = objectPlacement.getDensity(rng, minX, minZ, getData()); + int density = objectPlacement.getDensity(rng, minX, minZ, engine.getData()); for (int i = 0; i < density; i++) { IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(complex, rng)); @@ -1039,7 +1041,7 @@ public class MantleObjectComponent extends IrisMantleComponent { int xx = rng.i(minX, minX + 16); int zz = rng.i(minZ, minZ + 16); - int columnLowerSurfaceY = getEngineMantle().getEngine().getHeight(xx, zz, true); + int columnLowerSurfaceY = engine.getHeight(xx, zz, true); int rawUpperSurface = upperCtx.getUpperSurfaceY(xx, zz); int upperSurfaceY = Math.max(rawUpperSurface, columnLowerSurfaceY + upperGap); if (upperSurfaceY >= chunkHeight - 2) { @@ -1073,7 +1075,7 @@ public class MantleObjectComponent extends IrisMantleComponent { if (placement.isDolphinTarget() && placement.isUnderwater() && B.isStorageChest(data)) { writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE); } - }, null, getData()); + }, null, engine.getData()); if (traceRegen) { IrisLogging.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ @@ -1164,7 +1166,7 @@ public class MantleObjectComponent extends IrisMantleComponent { /** Dimension acts as the floor: it can force support on and widen the buffer, never weaken either. */ private IrisObjectPlacement applyDimensionSurfaceSupport(IrisObjectPlacement placement) { - IrisDimension dimension = getDimension(); + IrisDimension dimension = engine.getDimension(); boolean require = placement.isRequireSurfaceSupport() && dimension.isRequireObjectSurfaceSupport(); int buffer = Math.max(placement.getSurfaceSupportBuffer(), dimension.getObjectSurfaceSupportBuffer()); if (require == placement.isRequireSurfaceSupport() && buffer == placement.getSurfaceSupportBuffer()) { @@ -1249,7 +1251,7 @@ public class MantleObjectComponent extends IrisMantleComponent { } private KList scanCaveAnchorColumn(MantleWriter writer, IrisCaveAnchorMode anchorMode, int anchorScanStep, int objectMinDepthBelowSurface, int x, int z, CaveAnchorCache anchorCache) { - int height = getEngineMantle().getEngine().getHeight(); + int height = engine.getHeight(); int step = Math.max(1, anchorScanStep); int surfaceY = anchorCache.getSurfaceHeight(x, z); int maxAnchorExclusive = caveAnchorScanUpperBound(height, surfaceY, objectMinDepthBelowSurface); @@ -1316,7 +1318,7 @@ public class MantleObjectComponent extends IrisMantleComponent { } private IrisCaveProfile resolveCaveProfile(IrisCaveProfile preferred, IrisCaveProfile secondary) { - IrisCaveProfile dimensionProfile = getDimension().getCaveProfile(); + IrisCaveProfile dimensionProfile = engine.getDimension().getCaveProfile(); if (preferred != null && preferred.isEnabled()) { return preferred; } @@ -1416,8 +1418,8 @@ public class MantleObjectComponent extends IrisMantleComponent { @BlockCoordinates private Set guessPlacedKeys(RNG rng, int x, int z, IrisObjectPlacement objectPlacement) { Set f = new KSet<>(); - for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) { - IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng)); + for (int i = 0; i < objectPlacement.getDensity(rng, x, z, engine.getData()); i++) { + IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(engine.getComplex(), rng)); if (v == null) { continue; } @@ -1430,9 +1432,9 @@ public class MantleObjectComponent extends IrisMantleComponent { public Set guess(int x, int z) { // todo The guess doesnt bring into account that the placer may return -1 - RNG rng = applyNoise(x, z, Cache.key(x, z) + seed()); - IrisBiome biome = getEngineMantle().getEngine().getSurfaceBiome((x << 4) + 8, (z << 4) + 8); - IrisRegion region = getEngineMantle().getEngine().getRegion((x << 4) + 8, (z << 4) + 8); + RNG rng = applyNoise(x, z, Cache.key(x, z) + engine.getSeedManager().getMantle()); + IrisBiome biome = engine.getSurfaceBiome((x << 4) + 8, (z << 4) + 8); + IrisRegion region = engine.getRegion((x << 4) + 8, (z << 4) + 8); Set v = new KSet<>(); for (IrisObjectPlacement i : biome.getSurfaceObjects()) { if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) { @@ -1449,19 +1451,20 @@ public class MantleObjectComponent extends IrisMantleComponent { return v; } - protected int computeRadius() { - IrisDimension dimension = getDimension(); + /** How far, in blocks along X and Z, placements may write beyond their chunk. */ + public int reach() { + IrisDimension dimension = engine.getDimension(); KMap sizeCache = new KMap<>(); KSet warnedLargeObjects = new KSet<>(); int radius = 0; - for (IrisRegion region : dimension.getAllRegions(this::getData)) { + for (IrisRegion region : dimension.getAllRegions(engine)) { if (region == null) { continue; } radius = Math.max(radius, computePlacementRadius(region.getObjects(), sizeCache, warnedLargeObjects)); radius = Math.max(radius, computeProceduralRadius(region.getProceduralObjects())); } - for (IrisBiome biome : dimension.getReachableBiomes(this::getData)) { + for (IrisBiome biome : dimension.getReachableBiomes(engine)) { if (biome == null) { continue; } @@ -1510,7 +1513,7 @@ public class MantleObjectComponent extends IrisMantleComponent { if (placement == null) { continue; } - KList variants = placement.getVariantObjects(getData()); + KList variants = placement.getVariantObjects(engine.getData()); if (variants == null) { continue; } @@ -1578,7 +1581,7 @@ public class MantleObjectComponent extends IrisMantleComponent { private IrisBlockVector loadObjectSize(KMap sizeCache, String objectKey) { return sizeCache.computeIfAbsent(objectKey, k -> { try { - return IrisObject.sampleSize(getData().getObjectLoader().findFile(objectKey)); + return IrisObject.sampleSize(engine.getData().getObjectLoader().findFile(objectKey)); } catch (IOException e) { IrisLogging.reportError(e); } @@ -1641,7 +1644,7 @@ public class MantleObjectComponent extends IrisMantleComponent { return surfaceY; } - surfaceY = getEngineMantle().getEngine().getHeight(x, z); + surfaceY = engine.getHeight(x, z); surfaceHeights.put(columnKey, surfaceY); return surfaceY; } diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/StructureModule.java b/src/main/java/art/arcane/iris/engine/mantle/components/StructureModule.java new file mode 100644 index 000000000..5915045a2 --- /dev/null +++ b/src/main/java/art/arcane/iris/engine/mantle/components/StructureModule.java @@ -0,0 +1,64 @@ +/* + * 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.mantle.components; + +import art.arcane.iris.builtin.floating.FloatingStages; +import art.arcane.iris.builtin.objects.ObjectStages; +import art.arcane.iris.builtin.structure.StructureStages; +import art.arcane.iris.core.modules.IrisMantleChunk; +import art.arcane.iris.core.modules.IrisPackSettings; +import art.arcane.iris.engine.framework.Engine; +import com.volmit.IrisModule; +import com.volmit.ModuleInfo; +import com.volmit.config.PackSettings; +import com.volmit.stage.MantleStageContext; +import com.volmit.stage.StageGraph; + +/** + * Module {@code iris:structure}: Iris structures, written into the mantle after objects, whose trees they clear + * where they intersect, and after floating objects. A port of what was Iris's structure mantle component, its + * work done by {@link StructurePlacing}, one per engine runtime. Its reach is the pack's largest structure. + */ +public final class StructureModule implements IrisModule { + private static final String VERSION = "built-in"; + + @Override + public ModuleInfo info() { + return ModuleInfo.of("iris:structure", "Structures", VERSION); + } + + @Override + public void install(StageGraph graph) { + graph.define(StructureStages.PLACE).requires(ObjectStages.PLACE).softAfter(FloatingStages.OBJECTS.ref()) + .reach(StructureModule::reach).run(StructureModule::place); + } + + private static void place(MantleStageContext context) { + IrisMantleChunk chunk = IrisMantleChunk.current(); + placing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context()); + } + + private static int reach(PackSettings settings) { + return placing(IrisPackSettings.of(settings).engine()).reach(); + } + + private static StructurePlacing placing(Engine engine) { + return engine.getGeneration().state(StructurePlacing.class, StructurePlacing::new); + } +} diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/IrisStructureComponent.java b/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java similarity index 93% rename from src/main/java/art/arcane/iris/engine/mantle/components/IrisStructureComponent.java rename to src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java index 40edd8af8..fede31277 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/IrisStructureComponent.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/StructurePlacing.java @@ -27,9 +27,7 @@ import art.arcane.iris.engine.framework.PlacedStructurePiece; import art.arcane.iris.engine.framework.StructurePlacementScope; import art.arcane.iris.engine.framework.StructurePlacementMarker; import art.arcane.iris.engine.framework.TreeBlockMaterial; -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.world.dimension.IrisDimension; @@ -56,7 +54,6 @@ import art.arcane.volmlib.util.mantle.runtime.MantleChunk; import art.arcane.volmlib.util.matter.Matter; import art.arcane.volmlib.util.matter.MatterCavern; import art.arcane.volmlib.util.matter.MatterStructurePOI; -import art.arcane.volmlib.util.mantle.flag.ReservedFlag; import art.arcane.volmlib.util.math.RNG; import it.unimi.dsi.fastutil.longs.Long2IntMap; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; @@ -65,19 +62,25 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -@ComponentFlag(ReservedFlag.JIGSAW) -public class IrisStructureComponent extends IrisMantleComponent { +/** + * Places the Iris structures of the dimension, its regions and biomes into the mantle for + * {@link StructureModule}: their pieces, foundations, bores and carves, clearing object trees they + * intersect. One per engine runtime. Its reach is the largest structure any placement can produce. + */ +public class StructurePlacing { private static final MatterCavern CARVE_CAVERN = new MatterCavern(true, "", (byte) 3); - public IrisStructureComponent(EngineMantle engineMantle) { - super(engineMantle, ReservedFlag.JIGSAW, 3); + private final Engine engine; + + public StructurePlacing(Engine engine) { + this.engine = engine; } - @Override + /** Places what originates in the chunk at chunk coordinates {@code x}, {@code z} into {@code writer}. */ @ChunkCoordinates - public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) { + public void place(MantleWriter writer, int x, int z, ChunkContext context) { for (IrisStructurePlacement placement : StructurePlacementScope.placementsAt( - getEngineMantle().getEngine(), x, z)) { + engine, x, z)) { if (!placement.hasIrisStructures()) { continue; } @@ -88,7 +91,7 @@ public class IrisStructureComponent extends IrisMantleComponent { @ChunkCoordinates private void placeFromPlacement(MantleWriter writer, IrisStructurePlacement placement, int cx, int cz) { IrisStructureLocator.ResolvedPlacement resolved = IrisStructureLocator.resolvePlacement( - getEngineMantle().getEngine(), placement, cx, cz); + engine, placement, cx, cz); if (resolved == null) { return; } @@ -173,7 +176,7 @@ public class IrisStructureComponent extends IrisMantleComponent { boolean surfaceStructure) { IrisMaterialPalette palette = Objects.requireNonNull( settings.getPalette(), "Structure stilt palette must not be null"); - int mantleOffset = getEngineMantle().getEngine().getMinHeight(); + int mantleOffset = engine.getMinHeight(); int maxDepth = Math.max(1, settings.getMaxDepth()); for (Long2IntMap.Entry column : columns.long2IntEntrySet()) { int worldX = StructureFoundationPlanner.unpackX(column.getLongKey()); @@ -184,7 +187,7 @@ public class IrisStructureComponent extends IrisMantleComponent { if (foundationState == null || !foundationState.isSolid()) { continue; } - int terrainHeight = getEngineMantle().trueHeight(worldX, worldZ); + int terrainHeight = engine.getMantle().trueHeight(worldX, worldZ); int groundY = StructureFoundationPlanner.findGroundY( foundationY, maxDepth, 0, y -> { @@ -203,7 +206,7 @@ public class IrisStructureComponent extends IrisMantleComponent { } StructureFoundationPlanner.fillSupportColumn(foundationY, groundY, y -> { writeFoundationSupport( - writer, palette, rng, getData(), worldX, y, worldZ, mantleOffset); + writer, palette, rng, engine.getData(), worldX, y, worldZ, mantleOffset); }); } } @@ -259,14 +262,14 @@ public class IrisStructureComponent extends IrisMantleComponent { int maxX = bounds[3] + pad; int maxY = bounds[4] + Math.max(0, terrain.getCeilingPadding()); int maxZ = bounds[5] + pad; - int worldMin = getEngineMantle().getEngine().getMinHeight() + 1; - int worldMax = getEngineMantle().getEngine().getMinHeight() + getEngineMantle().getEngine().getHeight() - 1; + int worldMin = engine.getMinHeight() + 1; + int worldMax = engine.getMinHeight() + engine.getHeight() - 1; minY = Math.max(minY, worldMin); maxY = Math.min(maxY, worldMax); if (maxX < minX || maxY < minY || maxZ < minZ) { return; } - int mantleOffset = getEngineMantle().getEngine().getMinHeight(); + int mantleOffset = engine.getMinHeight(); for (int bx = minX; bx <= maxX; bx++) { for (int by = minY; by <= maxY; by++) { for (int bz = minZ; bz <= maxZ; bz++) { @@ -287,9 +290,9 @@ public class IrisStructureComponent extends IrisMantleComponent { int head = Math.max(0, terrain.getCeilingPadding()); int floorCut = Math.max(0, terrain.getFloorPadding()); double strength = terrain.resolvedErosionStrength(); - int mantleOffset = getEngineMantle().getEngine().getMinHeight(); - int worldMin = getEngineMantle().getEngine().getMinHeight() + 1; - int worldMax = getEngineMantle().getEngine().getMinHeight() + getEngineMantle().getEngine().getHeight() - 1; + int mantleOffset = engine.getMinHeight(); + int worldMin = engine.getMinHeight() + 1; + int worldMax = engine.getMinHeight() + engine.getHeight() - 1; int upExtension = shape.maximumCeilingExtension(head, strength); if (shape == IrisStructureCarveShape.BOX) { @@ -309,7 +312,7 @@ public class IrisStructureComponent extends IrisMantleComponent { CNG blob = null; CNG roll = null; if (eroded) { - RNG noiseRng = new RNG(seed() + Cache.key(bounds[0], bounds[2])); + RNG noiseRng = new RNG(engine.getSeedManager().getMantle() + Cache.key(bounds[0], bounds[2])); blob = CNG.signature(noiseRng); roll = CNG.signature(noiseRng.nextParallelRNG(0x2A17)); } @@ -404,8 +407,8 @@ public class IrisStructureComponent extends IrisMantleComponent { } private void clearIntersectingObjectTrees(MantleWriter writer, IrisStructureLocator.ResolvedPlacement resolved) { - int mantleOffset = getEngineMantle().getEngine().getMinHeight(); - int worldHeight = getEngineMantle().getEngine().getHeight(); + int mantleOffset = engine.getMinHeight(); + int worldHeight = engine.getHeight(); Map intersectingObjects = new HashMap<>(); for (PlacedStructurePiece piece : resolved.pieces()) { for (IrisBlockVector local : piece.getObject().getBlocks().keys()) { @@ -450,7 +453,7 @@ public class IrisStructureComponent extends IrisMantleComponent { if (decoded == null) { return; } - IrisObject object = getData().load(IrisObject.class, decoded.objectKey(), false); + IrisObject object = engine.getData().load(IrisObject.class, decoded.objectKey(), false); if (object == null) { return; } @@ -543,7 +546,7 @@ public class IrisStructureComponent extends IrisMantleComponent { if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) { config.setForcePlace(true); } - int placeY = (y == -1) ? -1 : y - getEngineMantle().getEngine().getMinHeight(); + int placeY = (y == -1) ? -1 : y - engine.getMinHeight(); String marker = structurePlacementMarker(structure, p, objectKey); return object.place(p.getX(), placeY, p.getZ(), writer, config, rng, (position, state) -> { StructureFoundationPlanner.recordBaseCell( @@ -552,7 +555,7 @@ public class IrisStructureComponent extends IrisMantleComponent { if (marker != null && shouldWriteStructureMarker(state)) { writer.setData(position.getX(), position.getY(), position.getZ(), marker); } - }, null, getData()); + }, null, engine.getData()); } static boolean shouldWriteStructureMarker(PlatformBlockState state) { @@ -578,15 +581,15 @@ public class IrisStructureComponent extends IrisMantleComponent { return StructurePlacementMarker.encodeStructure(objectKey, placementId, structureKey); } - @Override - protected int computeRadius() { - IrisDimension dimension = getDimension(); + /** How far, in blocks along X and Z, placements may write beyond their chunk. */ + public int reach() { + IrisDimension dimension = engine.getDimension(); int maxBlocks = 0; - for (IrisRegion region : dimension.getAllRegions(this::getData)) { + for (IrisRegion region : dimension.getAllRegions(engine)) { maxBlocks = Math.max(maxBlocks, maxBlocksFrom(region.getStructures())); } - for (IrisBiome biome : dimension.getReachableBiomes(this::getData)) { + for (IrisBiome biome : dimension.getReachableBiomes(engine)) { maxBlocks = Math.max(maxBlocks, maxBlocksFrom(biome.getStructures())); } maxBlocks = Math.max(maxBlocks, maxBlocksFrom(dimension.getStructures())); @@ -605,7 +608,7 @@ public class IrisStructureComponent extends IrisMantleComponent { || terrain.resolvedMode() == IrisStructureTerrainMode.BORE ? Math.max(0, terrain.getHorizontalPadding()) : 0; for (String key : placement.getStructures()) { - IrisStructure structure = getData().load(IrisStructure.class, key, false); + IrisStructure structure = engine.getData().load(IrisStructure.class, key, false); if (structure != null) { max = Math.max(max, Math.max(1, structure.getMaxSizeChunks()) * 16 + carvePadding); } diff --git a/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java b/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java index 476645917..0e6ce0642 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/CarveModule.java @@ -24,7 +24,6 @@ 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; @@ -71,8 +70,11 @@ public final class CarveModule implements IrisModule { chunk.blocks(), chunk.multicore(), chunk.context()); } - /** A dimension turns carving off with {@code carvingEnabled}, or by listing {@code CARVED} in {@code disabledComponents}. */ + /** + * A dimension turns carving off with {@code carvingEnabled}. Listing {@code CARVED} in {@code disabledComponents} + * also does: Iris then skips this stage's mantle pass like any disabled component. + */ private static boolean carves(IrisDimension dimension) { - return dimension.isCarvingEnabled() && !dimension.getDisabledComponents().contains(ReservedFlag.CARVED); + return dimension.isCarvingEnabled(); } } diff --git a/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java b/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java index dc260c18d..f63346186 100644 --- a/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java +++ b/src/main/java/art/arcane/iris/engine/modifier/FloatingModule.java @@ -20,17 +20,26 @@ 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.objects.ObjectStages; import art.arcane.iris.builtin.post.PostStages; import art.arcane.iris.core.modules.IrisChunk; +import art.arcane.iris.core.modules.IrisMantleChunk; +import art.arcane.iris.core.modules.IrisPackSettings; +import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.engine.mantle.components.FloatingObjectPlacing; import com.volmit.IrisModule; import com.volmit.ModuleInfo; +import com.volmit.config.PackSettings; import com.volmit.stage.ChunkStageContext; +import com.volmit.stage.MantleStageContext; 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. + * Module {@code iris:floating}: the islands of floating child biomes, their objects in the mantle after the + * dimension's other objects, their solids after smoothing and their decoration after the chunk's own. The + * mantle stage is a port of what was Iris's floating object mantle component, its work done by + * {@link FloatingObjectPlacing}, whose reach is the pack's largest floating object placement. The chunk + * stages are a thin wrapper: both run {@link IrisFloatingChildBiomeModifier} unchanged, one per engine runtime. */ public final class FloatingModule implements IrisModule { private static final String VERSION = "built-in"; @@ -42,10 +51,21 @@ public final class FloatingModule implements IrisModule { @Override public void install(StageGraph graph) { + graph.define(FloatingStages.OBJECTS).softAfter(ObjectStages.PLACE.ref()).reach(FloatingModule::objectReach) + .run(FloatingModule::objects); graph.define(FloatingStages.SOLIDS).requires(PostStages.SMOOTH).run(FloatingModule::solids); graph.define(FloatingStages.DECORATE).requires(DecorantStages.DECORATE).run(FloatingModule::decorate); } + private static void objects(MantleStageContext context) { + IrisMantleChunk chunk = IrisMantleChunk.current(); + objectPlacing(chunk.engine()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context()); + } + + private static int objectReach(PackSettings settings) { + return objectPlacing(IrisPackSettings.of(settings).engine()).reach(); + } + private static void solids(ChunkStageContext context) { IrisChunk chunk = IrisChunk.current(); islands(chunk).modify(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); @@ -56,6 +76,10 @@ public final class FloatingModule implements IrisModule { islands(chunk).decorateColumns(chunk.originX(), chunk.originZ(), chunk.blocks(), chunk.multicore(), chunk.context()); } + private static FloatingObjectPlacing objectPlacing(Engine engine) { + return engine.getGeneration().state(FloatingObjectPlacing.class, FloatingObjectPlacing::new); + } + private static IrisFloatingChildBiomeModifier islands(IrisChunk chunk) { return chunk.state(IrisFloatingChildBiomeModifier.class, IrisFloatingChildBiomeModifier::new); } diff --git a/src/main/java/art/arcane/iris/engine/object/annotations/functions/ComponentFlagFunction.java b/src/main/java/art/arcane/iris/engine/object/annotations/functions/ComponentFlagFunction.java index eabc3086e..981ccd8e3 100644 --- a/src/main/java/art/arcane/iris/engine/object/annotations/functions/ComponentFlagFunction.java +++ b/src/main/java/art/arcane/iris/engine/object/annotations/functions/ComponentFlagFunction.java @@ -1,17 +1,16 @@ package art.arcane.iris.engine.object.annotations.functions; import art.arcane.iris.core.loader.IrisData; +import art.arcane.iris.core.modules.MantleStageFlags; import art.arcane.iris.engine.framework.ListFunction; -import art.arcane.iris.engine.mantle.ComponentFlag; -import art.arcane.iris.engine.mantle.MantleComponent; -import art.arcane.iris.spi.IrisPlatforms; -import art.arcane.iris.util.common.scheduling.J; import art.arcane.volmlib.util.collection.KList; -import art.arcane.volmlib.util.io.JarScanner; import art.arcane.volmlib.util.mantle.flag.MantleFlag; -import java.util.Objects; - +/** + * What studio offers for a dimension's {@code disabledComponents}: the flags of Iris's own mantle stages, such as + * {@code CARVED} for caves. Pack mantle stages are left out: their flags follow their position in the pack's + * stage order, so a name written today could disable another stage once the pack changes. + */ public class ComponentFlagFunction implements ListFunction> { @Override public String key() { @@ -25,18 +24,6 @@ public class ComponentFlagFunction implements ListFunction> { @Override public KList apply(IrisData data) { - var engine = data.getEngine(); - if (engine != null) return engine.getMantle().getComponentFlags().toStringList(); - JarScanner scanner = new JarScanner(IrisPlatforms.get().pluginJar(), "art.arcane.iris.engine.mantle.components"); - J.attempt(scanner::scan); - return scanner.getClasses() - .stream() - .filter(c -> c.isAnnotationPresent(ComponentFlag.class)) - .filter(MantleComponent.class::isAssignableFrom) - .map(c -> c.getDeclaredAnnotation(ComponentFlag.class)) - .filter(Objects::nonNull) - .map(ComponentFlag::value) - .map(MantleFlag::toString) - .collect(KList.collector()); + return MantleStageFlags.builtIn().stream().map(MantleFlag::toString).collect(KList.collector()); } }