From c9058e0892a237842b4536e12528847349f0ecbc Mon Sep 17 00:00:00 2001 From: piexel Date: Thu, 15 Oct 2026 13:03:42 +0200 Subject: [PATCH] Structures generate from the built-ins jar iris:structure moves into the jar as a thin module: it declares the structure placement settings and the mantle stage, and Iris places the structures through a StructureHost facade. The structure model, assembler, locator, fitting and placing stay host. The resource kinds become iris:structure-model/*, owned by Iris's own module. StructurePlacement names its structures with @Ref(Reference.PACK_STRUCTURE), so the exposed package names no host class. CaveProfiles had no users and is removed. --- builtin-modules.txt | 1 + .../iris/builtin/structure/StructureHost.java | 56 +++++++++++++++++++ .../builtin/structure/StructurePlacement.java | 7 +-- .../structure/StructureResources.java | 10 ++-- .../mantle/components/StructureModule.java | 50 +++-------------- .../object/terrain/carving/CaveProfiles.java | 33 ----------- 6 files changed, 73 insertions(+), 84 deletions(-) create mode 100644 src/main/java/art/arcane/iris/builtin/structure/StructureHost.java delete mode 100644 src/main/java/art/arcane/iris/engine/object/terrain/carving/CaveProfiles.java diff --git a/builtin-modules.txt b/builtin-modules.txt index 83c2e59b2..344628e87 100644 --- a/builtin-modules.txt +++ b/builtin-modules.txt @@ -91,3 +91,4 @@ include art/arcane/iris/engine/mantle/components/FloatingObjectPlacing*.class include art/arcane/iris/engine/mantle/components/FloatingIslandSampleResolver*.class include art/arcane/iris/engine/mantle/components/IslandFace*.class include art/arcane/iris/engine/mantle/components/UndersideTurn*.class +module art.arcane.iris.engine.mantle.components.StructureModule diff --git a/src/main/java/art/arcane/iris/builtin/structure/StructureHost.java b/src/main/java/art/arcane/iris/builtin/structure/StructureHost.java new file mode 100644 index 000000000..3455b23f6 --- /dev/null +++ b/src/main/java/art/arcane/iris/builtin/structure/StructureHost.java @@ -0,0 +1,56 @@ +/* + * 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.config.PackSettings; +import com.volmit.world.PackWorld; + +/** + * What {@code iris:structure} asks of Iris: Iris places its jigsaw structures itself. The structure model (structures, + * pools, pieces), the assembler that builds a structure from them and the locator that spreads them over the world are + * Iris's, shared with the jigsaw studio and the structure importers and exporters. Iris's worlds implement it; a module + * reaches it with {@link #of}. + */ +public interface StructureHost { + /** The host of the world {@code settings} are the pack's of, which must be a world Iris generates. */ + static StructureHost of(PackSettings settings) { + if (settings instanceof Source source) { + return source.structures(); + } + throw new IllegalArgumentException("Built-in modules generate Iris's own worlds, not " + settings); + } + + /** The host of {@code world}, which must be a world Iris generates. */ + static StructureHost of(PackWorld world) { + if (world instanceof Source source) { + return source.structures(); + } + throw new IllegalArgumentException("Built-in modules generate Iris's own worlds, not " + world); + } + + /** Places the structures that start in the chunk whose mantle this thread is generating. */ + void placeChunk(); + + /** How far, in blocks along X and Z, a structure may write beyond the chunk it starts in. */ + int reach(); + + /** Iris's worlds answer for their structures. */ + interface Source { + StructureHost structures(); + } +} diff --git a/src/main/java/art/arcane/iris/builtin/structure/StructurePlacement.java b/src/main/java/art/arcane/iris/builtin/structure/StructurePlacement.java index 465b30ceb..1f8f7f5a4 100644 --- a/src/main/java/art/arcane/iris/builtin/structure/StructurePlacement.java +++ b/src/main/java/art/arcane/iris/builtin/structure/StructurePlacement.java @@ -18,14 +18,12 @@ package art.arcane.iris.builtin.structure; -import art.arcane.iris.engine.object.structure.IrisStructure; import com.volmit.config.Desc; import com.volmit.config.MaxNumber; import com.volmit.config.MinItems; import com.volmit.config.MinNumber; import com.volmit.config.Ref; import com.volmit.config.Reference; -import com.volmit.config.ResourceRef; import java.util.Collections; import java.util.List; @@ -34,13 +32,12 @@ import java.util.Optional; /** * Where and how often the structures of a dimension, region or biome start, written as one entry of its * {@code "structures": [...]}: the pack's own structures to assemble or the platform's to start natively, the - * distribution of the starts, the height they anchor at, and how they meet the terrain. IrisApi types only, besides - * the structure resource kind the {@code structures} keys name. + * distribution of the starts, the height they anchor at, and how they meet the terrain. IrisApi types only. */ @Desc("Attaches structures to a biome, region or dimension and controls where and how often they generate. This is independent of a structure's own native generation, so you can add custom placements in tandem with native generation or instead of it.") public final class StructurePlacement { @MinItems(1) - @ResourceRef(IrisStructure.class) + @Ref(Reference.PACK_STRUCTURE) @Desc("Editable Iris assembly resources offered by this placement. Leave empty when nativeStructures supplies the source.") private List structures = List.of(); diff --git a/src/main/java/art/arcane/iris/engine/framework/structure/StructureResources.java b/src/main/java/art/arcane/iris/engine/framework/structure/StructureResources.java index 1ed3beebf..bb302a93a 100644 --- a/src/main/java/art/arcane/iris/engine/framework/structure/StructureResources.java +++ b/src/main/java/art/arcane/iris/engine/framework/structure/StructureResources.java @@ -30,7 +30,7 @@ import com.volmit.resource.ResourceKind; import java.util.List; /** - * The resource kinds of module {@code iris:structure}, which keep the folders and files Iris packs have always used, + * The resource kinds of Iris's module {@code iris:structure-model}, which keep the folders and files Iris packs have always used, * and lookups by pack key for code that still names structures, pools and pieces by key. Every lookup goes through * the pack's {@link com.volmit.resource.PackResources}, so it sees the pack's current snapshot: a hotload, or * {@link IrisData#invalidateStructureResources()} after a tool rewrote the files, reads them again. @@ -40,16 +40,16 @@ import java.util.List; */ public final class StructureResources { /** Jigsaw structures, in {@code structures/}. */ - public static final ResourceKind STRUCTURES = ResourceKind.of("iris:structure/structure", "structures", IrisStructure.class); + public static final ResourceKind STRUCTURES = ResourceKind.of("iris:structure-model/structure", "structures", IrisStructure.class); /** Jigsaw pools a structure starts from and connectors lead to, in {@code jigsaw-pools/}. */ - public static final ResourceKind POOLS = ResourceKind.of("iris:structure/pool", "jigsaw-pools", IrisJigsawPool.class); + public static final ResourceKind POOLS = ResourceKind.of("iris:structure-model/pool", "jigsaw-pools", IrisJigsawPool.class); /** Jigsaw pieces pools hold, each an object with connectors, in {@code jigsaw-pieces/}. */ - public static final ResourceKind PIECES = ResourceKind.of("iris:structure/piece", "jigsaw-pieces", IrisJigsawPiece.class); + public static final ResourceKind PIECES = ResourceKind.of("iris:structure-model/piece", "jigsaw-pieces", IrisJigsawPiece.class); private StructureResources() { } - /** Every resource kind of the structure module. */ + /** Every resource kind of the structure model. */ public static List> kinds() { return List.of(STRUCTURES, POOLS, PIECES); } 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 index 674340ffa..68eb8d1d5 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/StructureModule.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/StructureModule.java @@ -19,47 +19,25 @@ package art.arcane.iris.engine.mantle.components; import art.arcane.iris.builtin.IrisStages; +import art.arcane.iris.builtin.structure.StructureHost; import art.arcane.iris.builtin.structure.StructurePlacementSettings; import art.arcane.iris.builtin.structure.StructureSettings; -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.framework.structure.StructureLocating; -import art.arcane.iris.engine.framework.structure.StructureResources; -import art.arcane.iris.engine.framework.structure.StructureValidator; -import art.arcane.iris.engine.framework.structure.StructureVanillaStructures; import com.volmit.FeatureRegistry; import com.volmit.IrisModule; import com.volmit.ModuleInfo; -import com.volmit.ModuleLog; import com.volmit.config.PackSettings; -import com.volmit.service.StructureLocator; -import com.volmit.service.VanillaStructures; 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. - *

- * The module owns the pack's structures, jigsaw pools and jigsaw pieces as resource kinds - * ({@link StructureResources}), read from the folders packs have always used, and checks them with - * {@link StructureValidator} wherever Iris validates a pack. It lets Iris find its structures through - * {@link StructureLocating}; a world's structure index lives in the world's state, so a reload of the pack's structure - * files, which starts a new world, builds it again. - *

- * It decides over the platform's own structures through its {@link VanillaStructures} provider - * ({@link StructureVanillaStructures}): the dimension's {@code importedStructures} settings disable, move, fit and set - * them up, and the pack's structure placements replace them, place them alongside, start them where their - * {@code nativeStructures} grids say and fit them into the terrain. The pack's structure placements are its - * {@code "structures"} settings ({@link StructurePlacementSettings}) of the dimension, its regions and biomes. + * Module {@code iris:structure}: the structure placements a pack declares, and the mantle stage that places the jigsaw + * structures starting in each chunk. Iris builds and places the structures ({@link StructureHost}); the structure + * resources, their validation, the locator and the platform structure answers are Iris's own module + * {@code iris:structure-model}. */ public final class StructureModule implements IrisModule { private static final String VERSION = "built-in"; - private ModuleLog log; - @Override public ModuleInfo info() { return ModuleInfo.of("iris:structure", "Structures", VERSION); @@ -68,30 +46,20 @@ public final class StructureModule implements IrisModule { @Override public void install(StageGraph graph) { graph.define(IrisStages.Structure.PLACE).softAfter(IrisStages.Objects.PLACE.ref(), IrisStages.Floating.OBJECTS.ref()) - .reach(this::reach).run(StructureModule::place); + .reach(StructureModule::reach).run(StructureModule::place); } @Override public void register(FeatureRegistry registry) { - log = registry.log(); registry.registerSettings(StructureSettings.class); registry.registerSettings(StructurePlacementSettings.class); - StructureResources.kinds().forEach(registry::registerResourceKind); - registry.registerValidator(new StructureValidator()); - registry.registerService(StructureLocator.class, new StructureLocating()); - registry.registerService(VanillaStructures.class, new StructureVanillaStructures()); } private static void place(MantleStageContext context) { - IrisMantleChunk chunk = IrisMantleChunk.current(); - placing(chunk.engine(), context.log()).place(chunk.writer(), chunk.chunkX(), chunk.chunkZ(), chunk.context()); + StructureHost.of(context.world()).placeChunk(); } - private int reach(PackSettings settings) { - return placing(IrisPackSettings.of(settings).engine(), log).reach(); - } - - private static StructurePlacing placing(Engine engine, ModuleLog log) { - return engine.getGeneration().state(StructurePlacing.class, generating -> new StructurePlacing(generating, log)); + private static int reach(PackSettings settings) { + return StructureHost.of(settings).reach(); } } diff --git a/src/main/java/art/arcane/iris/engine/object/terrain/carving/CaveProfiles.java b/src/main/java/art/arcane/iris/engine/object/terrain/carving/CaveProfiles.java deleted file mode 100644 index 55628bb16..000000000 --- a/src/main/java/art/arcane/iris/engine/object/terrain/carving/CaveProfiles.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Servers - * Copyright (c) 2026 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package art.arcane.iris.engine.object.terrain.carving; - -import art.arcane.iris.builtin.carve.CaveProfile; -import art.arcane.iris.core.loader.IrisRegistrant; - -/** The cave profiles dimensions, regions and biomes declare ({@code caveProfile}). */ -public final class CaveProfiles { - private CaveProfiles() { - } - - /** The profile {@code owner}, a dimension, region or biome, declares; null when it declares none, which is as good as one that is not enabled. */ - public static CaveProfile declaredBy(IrisRegistrant owner) { - return owner.getModuleSettings().find(CaveProfile.class).orElse(null); - } -}