diff --git a/README.md b/README.md
index 23208e07f..35322cf98 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,7 @@ regions and biomes. The loot tables, spawners, entities and markers are plain mo
`EntityDefinition`, `SpawnMarker`). `PlacementLoot` picks the table an object placement gives one of its chests.
`iris:decorant`, `iris:terrain` and `iris:deposit` ship in the built-ins jar and keep their per-world workers (`BiomeDecorators`, `TerrainShaper`,
`DepositPlacer`) in the world's state store (`context.world().state(...)`); the modules still compiled into Iris reach the same store through
-`IrisChunk.state(...)` / `engine.getGeneration().state(...)`.
+the `IrisChunk` their invocation offers (`context.extension(IrisChunk.class)`, then `state(...)`) or `engine.getGeneration().state(...)`.
Settings move off Iris's classes one feature at a time. `iris:deposit` is the first whose settings are IrisApi types
only: `DepositSettings` holds `DepositGenerator`s (blocks as `BlockSpec`, its enums beside it in
@@ -188,24 +188,30 @@ none of the jar's modules (`IrisModuleHost.JAR_MODULE_IDS`, which a test keeps e
`builtin-modules.txt`): add a module to the jar and to that list together.
`art.arcane.iris.builtin` also holds what the compiled-in built-ins and the jar must share, because each sees its own copy of
-every other class: `IrisSeed` (Iris's per-feature world seeds, a facade Iris's worlds implement, so existing worlds generate the
-same) and `terrain.LayerBlocks` (the world's picks from the biomes' palette layers: terrain, caves and post pick from the same
+every other class. The facades among them are interfaces Iris implements and offers through IrisApi's extension point, never
+through the thread or a cast: a module asks `world.extension(X.class)` for what belongs to a world (`IrisSeeds`, `LiveWorld`,
+`ObjectHost`, `FloatingHost`, `StructureHost`), `context.extension(X.class)` for what belongs to one invocation (`ObjectPlacement`
+in a placement stage, `MatterMantle` in a chunk or mantle stage) and `settings.extension(X.class)` for a reach worked out
+before any world exists, each with `.orElseThrow()`, since a built-in runs only where Iris offers them. `IrisSeeds` gives
+Iris's per-feature world seeds (`seeds.seed(IrisSeed.CARVE)`), so existing worlds generate the same; `terrain.LayerBlocks` (the world's picks from the biomes' palette layers: terrain, caves and post pick from the same
layers, and a layer's noise is built once per world by whichever asks first), `LiveWorld` (what the loot and spawn services ask a
running world, outside any chunk stage: the layout and settings at a block, the platform's weather and loot tables, the
-objects' loot and the spawner cooldowns Iris saves with the world; values only, implemented by Iris's worlds like `IrisSeed`),
+objects' loot and the spawner cooldowns Iris saves with the world; values only),
`loot.LootResolver` (the random streams loot is drawn from, shared with the hosts that fill containers) and the loot and
marker lists of an object placement (`loot.ObjectLoot`, `loot.ObjectVanillaLoot`, `spawn.PlacementMarker`, which the modules
register as held types, because Iris's `IrisObjectPlacement` holds them). The placement stages need more of the object being
-placed than IrisApi describes, so `placement.ObjectPlacement` is the facade Iris implements for each placement and binds to the placing
-thread (`ObjectPlacement.current()`): the object's size (`ObjectShape`), the placement's settings (`PlacementSettings`, read from
+placed than IrisApi describes, so `placement.ObjectPlacement` is the facade Iris implements for each placement and offers with
+its invocation (`context.extension(ObjectPlacement.class)`): the object's size (`ObjectShape`), the placement's settings (`PlacementSettings`, read from
Iris's `IrisObjectPlacement`), the terrain questions of its placer and the world around it (`PlacementTerrain`), the surface warp,
and the block operations only the platform can do (turning a state with the object, merging two states, matching, traits of the
placement's own states). Its types answer with IrisApi, VolmLib and built-in values only. `prepare.PreparedPlacement`, the output of
`iris:prepare/transforms`, lives in the exposed package too, because `IrisStages` names it. `iris:post` reads its switches
(`postProcessingWalls`, `postProcessingSlabs`) and the biome's `wall` and `slab` as module settings through its context.
-`iris:carve` also reads the mantle's matter slices through `MatterMantle` (a facade Iris's mantle implements: the chunk of
-`MatterCavern`s and markers it plans and applies, which the platform and the rest of Iris read as slices, not as module layers). What a
+`iris:carve` also reads the mantle's matter slices through `MatterMantle` (the chunk of `MatterCavern`s and markers it plans and
+applies, which the platform and the rest of Iris read as slices, not as module layers). A mantle stage gets the whole mantle; a
+chunk stage gets its own chunk and the neighbors the world already holds in memory, which is all the cave apply stage ever read,
+so it writes nothing outside its chunk. What a
cave's walls, floor and ceiling get comes from the terrain and decorant built-ins of the same jar (`terrain.BiomeLayers`,
`terrain.TerrainPalettes`, the biome decorators), through carve's own `CaveDressing`, which tests replace with fixed blocks.
A cave's dimension, region and biome settings are found by the id the layout's biome samples carry (`DeclaredByLevel`), its
diff --git a/src/main/java/art/arcane/iris/builtin/IrisSeed.java b/src/main/java/art/arcane/iris/builtin/IrisSeed.java
index 9f141f2d8..43f79f943 100644
--- a/src/main/java/art/arcane/iris/builtin/IrisSeed.java
+++ b/src/main/java/art/arcane/iris/builtin/IrisSeed.java
@@ -24,21 +24,8 @@ import com.volmit.world.PackWorld;
* The seeds Iris derives from a world's seed for its own features. Iris derives them one after another from a shared
* random, so they cannot be worked out from the world seed alone. Built-in modules seed their randoms and noise with
* them, so worlds generated before the features were modules generate the same; a pack module derives its own seeds
- * from {@link PackWorld#seed()}.
+ * from {@link PackWorld#seed()}. A world Iris generates answers for them through its {@link IrisSeeds} extension.
*/
public enum IrisSeed {
- BIOME, CARVE, COMPLEX, COMPONENT, DECORATOR, DEPOSIT, ENTITY, LOOT, MANTLE, POST, TERRAIN;
-
- /** This seed of {@code world}, which must be a world Iris generates. */
- public long of(PackWorld world) {
- if (world instanceof Source source) {
- return source.seed(this);
- }
- throw new IllegalArgumentException("Built-in modules generate Iris's own worlds, not " + world);
- }
-
- /** Iris's worlds answer for their seeds. */
- public interface Source {
- long seed(IrisSeed seed);
- }
+ BIOME, CARVE, COMPLEX, COMPONENT, DECORATOR, DEPOSIT, ENTITY, LOOT, MANTLE, POST, TERRAIN
}
diff --git a/src/main/java/art/arcane/iris/builtin/placement/PlacementBinding.java b/src/main/java/art/arcane/iris/builtin/IrisSeeds.java
similarity index 53%
rename from src/main/java/art/arcane/iris/builtin/placement/PlacementBinding.java
rename to src/main/java/art/arcane/iris/builtin/IrisSeeds.java
index 899f4b341..a2f6141a0 100644
--- a/src/main/java/art/arcane/iris/builtin/placement/PlacementBinding.java
+++ b/src/main/java/art/arcane/iris/builtin/IrisSeeds.java
@@ -16,25 +16,12 @@
* along with this program. If not, see .
*/
-package art.arcane.iris.builtin.placement;
+package art.arcane.iris.builtin;
-import java.util.function.Supplier;
-
-/** The placement bound to the placing thread. */
-final class PlacementBinding {
- private static final ScopedValue CURRENT = ScopedValue.newInstance();
-
- private PlacementBinding() {
- }
-
- static ObjectPlacement current() {
- if (!CURRENT.isBound()) {
- throw new IllegalStateException("No Iris object placement is running on this thread");
- }
- return CURRENT.get();
- }
-
- static T run(ObjectPlacement placement, Supplier body) {
- return ScopedValue.where(CURRENT, placement).call(body::get);
- }
+/**
+ * The {@link IrisSeed}s of a world Iris generates, which it offers as an extension of the world:
+ * {@code world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.CARVE)}.
+ */
+public interface IrisSeeds {
+ long seed(IrisSeed seed);
}
diff --git a/src/main/java/art/arcane/iris/builtin/LiveWorld.java b/src/main/java/art/arcane/iris/builtin/LiveWorld.java
index d52bc1d0f..64b5bd10e 100644
--- a/src/main/java/art/arcane/iris/builtin/LiveWorld.java
+++ b/src/main/java/art/arcane/iris/builtin/LiveWorld.java
@@ -24,7 +24,6 @@ import art.arcane.iris.builtin.spawn.SpawnCooldowns;
import com.volmit.IrisFeature;
import com.volmit.resource.ResourceId;
import com.volmit.world.BlockPosition;
-import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Optional;
@@ -36,22 +35,9 @@ import java.util.Set;
* the layout through its {@link com.volmit.world.TerrainSampler}; a service has no chunk, so it asks here.
*
*
X and Z are world coordinates; Y is the height above the dimension's bottom, as everywhere in IrisApi.
- * Safe to use from any thread. Reached through {@link #of(PackWorld)}.
+ * Safe to use from any thread. Iris offers it as an extension of its worlds: {@code world.extension(LiveWorld.class)}.
*/
public interface LiveWorld {
- /** The live view of {@code world}, which must be a world Iris generates. */
- static LiveWorld of(PackWorld world) {
- if (world instanceof Source source) {
- return source.liveWorld();
- }
- throw new IllegalArgumentException("Built-in modules work in worlds Iris generates, not " + world);
- }
-
- /** Iris's worlds answer for their live view. */
- interface Source {
- LiveWorld liveWorld();
- }
-
/** The platform's block Y of height 0, the dimension's bottom: a position's height plus this is its Y in the platform. */
int bottomY();
diff --git a/src/main/java/art/arcane/iris/builtin/MatterMantle.java b/src/main/java/art/arcane/iris/builtin/MatterMantle.java
index 34ae03f93..4797970ea 100644
--- a/src/main/java/art/arcane/iris/builtin/MatterMantle.java
+++ b/src/main/java/art/arcane/iris/builtin/MatterMantle.java
@@ -20,34 +20,20 @@ package art.arcane.iris.builtin;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.matter.Matter;
-import com.volmit.host.ReadOnlyMantle;
-import com.volmit.mantle.Mantle;
/**
* Iris's mantle as the matter slices it stores, for the built-ins whose data the platform and the rest of Iris read as
* slices rather than through a {@link com.volmit.mantle.MantleLayer}: caves ({@code MatterCavern}) and markers. The
- * slices are VolmLib's own types, which a pack module may use as well; Iris's worlds implement this next to
- * {@link Mantle}, and {@link #of(Mantle)} reaches it from an invocation's mantle.
+ * slices are VolmLib's own types, which a pack module may use as well. Iris offers it as an extension of its mantle and
+ * chunk invocations: {@code context.extension(MatterMantle.class)}.
+ *
+ *
A chunk invocation's matter mantle holds its own chunk only, which the stage may write, as a chunk stage writes the
+ * mantle of its own chunk; it reads its neighbours through {@link #loadedChunk} alone.
*
*
Heights are as the mantle stores them: above the dimension's bottom. A chunk the invocation reaches is pinned for
* as long as the invocation runs; callers neither release it nor keep it afterwards.
*/
public interface MatterMantle {
- /**
- * The matter side of {@code mantle}, which must be a mantle Iris hands to its stages. A chunk stage's mantle is read-only
- * to the stage; the matter behind it is not, and a built-in chunk stage that writes markers into it (the caves' floors and
- * ceilings) is why this reaches through.
- */
- static MatterMantle of(Mantle mantle) {
- if (mantle instanceof ReadOnlyMantle readOnly) {
- return of(readOnly.host());
- }
- if (mantle instanceof MatterMantle matter) {
- return matter;
- }
- throw new IllegalArgumentException("Built-in modules write Iris's own mantle, not " + mantle);
- }
-
/** The mantle chunk at chunk coordinates {@code chunkX}, {@code chunkZ}, or null outside what the invocation reaches. */
MantleChunk chunk(int chunkX, int chunkZ);
diff --git a/src/main/java/art/arcane/iris/builtin/carve/CarvingBiomeSettings.java b/src/main/java/art/arcane/iris/builtin/carve/CarvingBiomeSettings.java
index 9ee612265..56c8b50ea 100644
--- a/src/main/java/art/arcane/iris/builtin/carve/CarvingBiomeSettings.java
+++ b/src/main/java/art/arcane/iris/builtin/carve/CarvingBiomeSettings.java
@@ -25,6 +25,8 @@ import com.volmit.config.Feature;
import com.volmit.config.LinkedBiomes;
import com.volmit.config.Ref;
import com.volmit.config.Reference;
+import com.volmit.resource.PackResources;
+import com.volmit.resource.ResourceId;
import java.util.Set;
@@ -48,7 +50,7 @@ public final class CarvingBiomeSettings implements IrisFeature, LinkedBiomes {
}
@Override
- public Set treeBiomes() {
- return Set.of(biome());
+ public Set treeBiomes(PackResources pack) {
+ return biome().isBlank() ? Set.of() : Set.of(pack.idOf(biome()));
}
}
diff --git a/src/main/java/art/arcane/iris/builtin/carve/CarvingSettings.java b/src/main/java/art/arcane/iris/builtin/carve/CarvingSettings.java
index 3408c1cc6..997571a32 100644
--- a/src/main/java/art/arcane/iris/builtin/carve/CarvingSettings.java
+++ b/src/main/java/art/arcane/iris/builtin/carve/CarvingSettings.java
@@ -24,6 +24,8 @@ import com.volmit.config.Desc;
import com.volmit.config.Feature;
import com.volmit.config.LinkedBiomes;
import com.volmit.config.MinItems;
+import com.volmit.resource.PackResources;
+import com.volmit.resource.ResourceId;
import java.util.Collection;
import java.util.Collections;
@@ -68,11 +70,11 @@ public final class CarvingSettings implements IrisFeature, LinkedBiomes {
}
@Override
- public Set usedBiomes(Collection dimension) {
- Set biomes = new LinkedHashSet<>();
+ public Set usedBiomes(PackResources pack, Collection dimension) {
+ Set biomes = new LinkedHashSet<>();
for (CarvingEntry entry : entries()) {
- if (entry != null && entry.enabled()) {
- biomes.add(entry.biome());
+ if (entry != null && entry.enabled() && entry.biome() != null && !entry.biome().isBlank()) {
+ biomes.add(pack.idOf(entry.biome()));
}
}
return biomes;
diff --git a/src/main/java/art/arcane/iris/builtin/floating/FloatingChildSettings.java b/src/main/java/art/arcane/iris/builtin/floating/FloatingChildSettings.java
index fdff1ebfe..36a143829 100644
--- a/src/main/java/art/arcane/iris/builtin/floating/FloatingChildSettings.java
+++ b/src/main/java/art/arcane/iris/builtin/floating/FloatingChildSettings.java
@@ -25,6 +25,8 @@ import com.volmit.config.Desc;
import com.volmit.config.Feature;
import com.volmit.config.LinkedBiomes;
import com.volmit.config.MinItems;
+import com.volmit.resource.PackResources;
+import com.volmit.resource.ResourceId;
import java.util.Collection;
import java.util.Collections;
@@ -56,15 +58,21 @@ public final class FloatingChildSettings implements IrisFeature, LinkedBiomes {
}
@Override
- public Set usedBiomes(Collection dimension) {
+ public Set usedBiomes(PackResources pack, Collection dimension) {
CarvingSettings carving = dimension.stream().filter(CarvingSettings.class::isInstance).map(CarvingSettings.class::cast).findFirst().orElse(null);
- Set biomes = new LinkedHashSet<>();
+ Set biomes = new LinkedHashSet<>();
for (FloatingChildBiome child : children()) {
if (child != null) {
- biomes.add(child.biome());
- biomes.add(carving == null ? child.carving() : carving.biomeOf(child.carving()));
+ addBiome(pack, biomes, child.biome());
+ addBiome(pack, biomes, carving == null ? child.carving() : carving.biomeOf(child.carving()));
}
}
return biomes;
}
+
+ private static void addBiome(PackResources pack, Set biomes, String key) {
+ if (key != null && !key.isBlank()) {
+ biomes.add(pack.idOf(key));
+ }
+ }
}
diff --git a/src/main/java/art/arcane/iris/builtin/floating/FloatingHost.java b/src/main/java/art/arcane/iris/builtin/floating/FloatingHost.java
index e862eb7bd..939981af3 100644
--- a/src/main/java/art/arcane/iris/builtin/floating/FloatingHost.java
+++ b/src/main/java/art/arcane/iris/builtin/floating/FloatingHost.java
@@ -21,34 +21,17 @@ package art.arcane.iris.builtin.floating;
import art.arcane.iris.builtin.objects.ObjectPlacement;
import art.arcane.iris.builtin.objects.PlaceableObject;
import art.arcane.volmlib.util.math.RNG;
-import com.volmit.config.PackSettings;
+import com.volmit.generation.InvocationContext;
import com.volmit.resource.ResourceId;
-import com.volmit.world.PackWorld;
import java.util.Optional;
/**
* What {@code iris:floating} asks of Iris beyond the API: the biome of any column, a biome's own terrain height, the sky
- * biome an island paints, and placing Iris objects against an island. Iris's worlds implement it; a module reaches it
- * with {@link #of}.
+ * biome an island paints, and placing Iris objects against an island. Iris offers it as an extension of its worlds and
+ * of the settings of the pack it loads: {@code world.extension(FloatingHost.class)}.
*/
public interface FloatingHost {
- /** The host of the world {@code settings} are the pack's of, which must be a world Iris generates. */
- static FloatingHost of(PackSettings settings) {
- if (settings instanceof Source source) {
- return source.floating();
- }
- 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 FloatingHost of(PackWorld world) {
- if (world instanceof Source source) {
- return source.floating();
- }
- throw new IllegalArgumentException("Built-in modules generate Iris's own worlds, not " + world);
- }
-
/** The biome of the column's surface, the biome an island grows from; any column, not only the chunk's. */
ResourceId surfaceBiome(int worldX, int worldZ);
@@ -70,24 +53,21 @@ public interface FloatingHost {
/** {@code object} shrunk by {@code factor} (below 1), the variant picked with {@code random}. */
Optional shrink(PlaceableObject object, double factor, RNG random);
- /** Places {@code object} floating free at the column, into the chunk the mantle is generating. */
- void placeFloating(PlaceableObject object, int worldX, int worldZ, ObjectPlacement placement, RNG random);
+ /** Places {@code object} floating free at the column, into the chunk the mantle invocation {@code context} generates. */
+ void placeFloating(InvocationContext context, PlaceableObject object, int worldX, int worldZ, ObjectPlacement placement,
+ RNG random);
/**
- * Places {@code object} on an island's top, its lowest block at {@code y}, into the chunk the mantle is generating; nothing
- * is written unless every block it writes is one {@code anchor} lets it write.
+ * Places {@code object} on an island's top, its lowest block at {@code y}, into the chunk the mantle invocation
+ * {@code context} generates; nothing is written unless every block it writes is one {@code anchor} lets it write.
*/
- void placeOnTop(PlaceableObject object, int worldX, int y, int worldZ, ObjectPlacement placement, IslandAnchor anchor, RNG random);
+ void placeOnTop(InvocationContext context, PlaceableObject object, int worldX, int y, int worldZ,
+ ObjectPlacement placement, IslandAnchor anchor, RNG random);
/**
* Places {@code object} upside down under an island, turned {@code yRotation} degrees about Y, as {@link #placeOnTop} does
* on top.
*/
- void placeUnder(PlaceableObject object, int worldX, int y, int worldZ, int yRotation, ObjectPlacement placement,
- IslandAnchor anchor, RNG random);
-
- /** A world that hands out its {@link FloatingHost}. */
- interface Source {
- FloatingHost floating();
- }
+ void placeUnder(InvocationContext context, PlaceableObject object, int worldX, int y, int worldZ, int yRotation,
+ ObjectPlacement placement, IslandAnchor anchor, RNG random);
}
diff --git a/src/main/java/art/arcane/iris/builtin/objects/ObjectHost.java b/src/main/java/art/arcane/iris/builtin/objects/ObjectHost.java
index 85a02cd3e..90d41ce2e 100644
--- a/src/main/java/art/arcane/iris/builtin/objects/ObjectHost.java
+++ b/src/main/java/art/arcane/iris/builtin/objects/ObjectHost.java
@@ -22,9 +22,8 @@ import art.arcane.volmlib.util.math.RNG;
import com.volmit.config.Level;
import com.volmit.IrisFeature;
import com.volmit.config.FeatureSettings;
-import com.volmit.config.PackSettings;
+import com.volmit.generation.InvocationContext;
import com.volmit.resource.ResourceId;
-import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Optional;
@@ -32,25 +31,11 @@ import java.util.function.Function;
/**
* What {@code iris:objects} asks of Iris: the objects of the pack, how Iris scales and places them, and the layout around
- * a world position. Iris's worlds implement it; a module reaches it with {@link #of}. Nothing here hands out the engine.
+ * a world position. Iris offers it as an extension of its worlds and of the settings of the pack it loads:
+ * {@code world.extension(ObjectHost.class)}, {@code settings.extension(ObjectHost.class)}. Nothing here hands out the
+ * engine.
*/
public interface ObjectHost {
- /** The host of the world {@code settings} are the pack's of, which must be a world Iris generates. */
- static ObjectHost of(PackSettings settings) {
- if (settings instanceof Source source) {
- return source.objects();
- }
- 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 ObjectHost of(PackWorld world) {
- if (world instanceof Source source) {
- return source.objects();
- }
- throw new IllegalArgumentException("Built-in modules generate Iris's own worlds, not " + world);
- }
-
/** Whether Iris's debug setting is on. */
boolean debugging();
@@ -66,8 +51,8 @@ public interface ObjectHost {
/** The random a chunk's objects are placed with: the same for the same chunk of the same world. */
RNG chunkRandom(int chunkX, int chunkZ);
- /** The chunk whose objects are being placed on this thread. */
- ObjectChunk chunk();
+ /** The chunk whose objects the mantle invocation {@code context} places. */
+ ObjectChunk chunk(InvocationContext context);
/** The object of the pack that {@code key} names. */
Optional object(String key);
@@ -119,11 +104,6 @@ public interface ObjectHost {
record UpperObjects(ObjectSettings biome, ObjectSettings region, String biomeKey, String regionKey) {
}
- /** Iris's worlds answer for their objects. */
- interface Source {
- ObjectHost objects();
- }
-
/** One region's or biome's declaration of settings. */
record Declaration(Level level, String key, F settings) {
}
diff --git a/src/main/java/art/arcane/iris/builtin/placement/ObjectPlacement.java b/src/main/java/art/arcane/iris/builtin/placement/ObjectPlacement.java
index 3e8ded0ac..de8532bbe 100644
--- a/src/main/java/art/arcane/iris/builtin/placement/ObjectPlacement.java
+++ b/src/main/java/art/arcane/iris/builtin/placement/ObjectPlacement.java
@@ -26,28 +26,17 @@ import com.volmit.resource.PackResources;
import com.volmit.world.BlockPosition;
import java.util.Optional;
-import java.util.function.Supplier;
/**
* The object placement being run, as Iris's built-in placement stages see it: what is placed and with which settings, the
* terrain it is placed on, and the few block operations that only the platform can do. Iris implements it for each
- * placement and binds it to the placing thread while the placement graph runs; the stages read it through {@link #current()}.
+ * placement and offers it as an extension of the placement invocation: {@code context.extension(ObjectPlacement.class)}.
* Heights are in the coordinates of the placement stages: above the dimension's bottom.
*
* It never hands out an engine, pack data or a platform type; everything it answers is an IrisApi, VolmLib or
* {@code art.arcane.iris.builtin} value.
*/
public interface ObjectPlacement {
- /** The placement running on this thread. */
- static ObjectPlacement current() {
- return PlacementBinding.current();
- }
-
- /** Runs {@code placement} with {@code inputs} as {@link #current()} on this thread. */
- static T runBound(ObjectPlacement inputs, Supplier placement) {
- return PlacementBinding.run(inputs, placement);
- }
-
ObjectShape object();
/** The settings as the caller passed them; the stages derive what they change (the rotation) themselves. */
diff --git a/src/main/java/art/arcane/iris/builtin/structure/StructureHost.java b/src/main/java/art/arcane/iris/builtin/structure/StructureHost.java
index 3455b23f6..b2bd0d8fe 100644
--- a/src/main/java/art/arcane/iris/builtin/structure/StructureHost.java
+++ b/src/main/java/art/arcane/iris/builtin/structure/StructureHost.java
@@ -17,40 +17,18 @@
*/
package art.arcane.iris.builtin.structure;
-import com.volmit.config.PackSettings;
-import com.volmit.world.PackWorld;
+import com.volmit.generation.InvocationContext;
/**
* 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}.
+ * Iris's, shared with the jigsaw studio and the structure importers and exporters. Iris offers it as an extension of its
+ * worlds and of the settings of the pack it loads: {@code world.extension(StructureHost.class)}.
*/
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();
+ /** Places the structures that start in the chunk whose mantle the mantle invocation {@code context} generates. */
+ void placeChunk(InvocationContext context);
/** 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/terrain/TerrainPalettes.java b/src/main/java/art/arcane/iris/builtin/terrain/TerrainPalettes.java
index a415ed931..916bc33fa 100644
--- a/src/main/java/art/arcane/iris/builtin/terrain/TerrainPalettes.java
+++ b/src/main/java/art/arcane/iris/builtin/terrain/TerrainPalettes.java
@@ -18,6 +18,7 @@
package art.arcane.iris.builtin.terrain;
import art.arcane.iris.builtin.IrisSeed;
+import art.arcane.iris.builtin.IrisSeeds;
import art.arcane.volmlib.util.cache.AtomicCache;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.block.BlockState;
@@ -61,7 +62,7 @@ public final class TerrainPalettes {
TerrainPalettes(PackWorld world) {
this.world = world;
- this.complexSeed = IrisSeed.COMPLEX.of(world);
+ this.complexSeed = world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.COMPLEX);
}
/** The palettes of {@code world}. */
diff --git a/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java b/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java
index 366b6b415..eb2c3866a 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java
+++ b/src/main/java/art/arcane/iris/engine/actuator/OreWarmUp.java
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.IrisSeed;
+import art.arcane.iris.builtin.IrisSeeds;
import art.arcane.iris.builtin.terrain.OreSettings;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.config.FeatureSettings.Entry;
@@ -49,7 +50,7 @@ final class OreWarmUp {
OreWarmUp(PackWorld world, TerrainOres ores) {
this.world = world;
this.ores = ores;
- this.root = new RNG(IrisSeed.COMPONENT.of(world) + ROOT_SEED_SALT);
+ this.root = new RNG(world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.COMPONENT) + ROOT_SEED_SALT);
}
void warm() {
diff --git a/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java b/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java
index d68bb2432..4691b0ad7 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java
+++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainOres.java
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.IrisSeed;
+import art.arcane.iris.builtin.IrisSeeds;
import art.arcane.iris.builtin.terrain.OreSettings;
import com.volmit.resource.PackResources;
import com.volmit.world.PackWorld;
@@ -36,7 +37,7 @@ final class TerrainOres {
TerrainOres(PackWorld world) {
this.resources = world.resources();
- this.terrainSeed = IrisSeed.TERRAIN.of(world);
+ this.terrainSeed = world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.TERRAIN);
}
/** The ores of {@code world}. */
diff --git a/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java b/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java
index 2af428c30..03071bb1b 100644
--- a/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java
+++ b/src/main/java/art/arcane/iris/engine/actuator/TerrainShaper.java
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.actuator;
import art.arcane.iris.builtin.IrisSeed;
+import art.arcane.iris.builtin.IrisSeeds;
import art.arcane.iris.builtin.terrain.BedrockSettings;
import art.arcane.iris.builtin.terrain.HideOresSettings;
import art.arcane.iris.builtin.terrain.OreSettings;
@@ -66,7 +67,7 @@ final class TerrainShaper {
this.palettes = palettes;
this.layers = layers;
this.ores = ores;
- this.rng = new RNG(IrisSeed.TERRAIN.of(world));
+ this.rng = new RNG(world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.TERRAIN));
this.levelsBelowTheDimensionDeclareOres = world.settings().declared(OreSettings.class).entries().stream()
.anyMatch(entry -> entry.level() != Level.DIMENSION);
}
diff --git a/src/main/java/art/arcane/iris/engine/decorator/BiomeDecorators.java b/src/main/java/art/arcane/iris/engine/decorator/BiomeDecorators.java
index 526ccb134..6d55fd58e 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/BiomeDecorators.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/BiomeDecorators.java
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.decorator;
import art.arcane.iris.builtin.IrisSeed;
+import art.arcane.iris.builtin.IrisSeeds;
import art.arcane.iris.builtin.decorant.DecorantSettings;
import art.arcane.iris.builtin.decorant.DecorationPart;
import art.arcane.iris.builtin.decorant.Decorator;
@@ -59,7 +60,7 @@ public final class BiomeDecorators {
this.world = world;
this.resources = world.resources();
this.log = world.log();
- this.decoratorSeed = IrisSeed.DECORATOR.of(world);
+ this.decoratorSeed = world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.DECORATOR);
}
/** The world's decorators, kept in its state store. */
diff --git a/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java b/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java
index 272797c76..4f5682981 100644
--- a/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java
+++ b/src/main/java/art/arcane/iris/engine/decorator/DecorationScene.java
@@ -18,6 +18,7 @@
package art.arcane.iris.engine.decorator;
import art.arcane.iris.builtin.IrisSeed;
+import art.arcane.iris.builtin.IrisSeeds;
import com.volmit.ModuleLog;
import com.volmit.block.BlockRegistry;
import com.volmit.block.BlockState;
@@ -52,7 +53,7 @@ public final class DecorationScene {
public static DecorationScene of(ChunkStageContext context) {
Mantle mantle = context.mantle();
return new DecorationScene(context.hunk(BlockState.class), context.world().resources().blocks(), context.terrain(),
- mantle == null ? null : mantle.blocks(), BiomeDecorators.of(context.world()), IrisSeed.COMPONENT.of(context.world()),
+ mantle == null ? null : mantle.blocks(), BiomeDecorators.of(context.world()), context.world().extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.COMPONENT),
context.log());
}
diff --git a/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphValidation.java b/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphValidation.java
index 715215451..a44bba695 100644
--- a/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphValidation.java
+++ b/src/main/java/art/arcane/iris/engine/framework/structure/StructureGraphValidation.java
@@ -77,7 +77,7 @@ public final class StructureGraphValidation {
Set replacementOutputStructures = new LinkedHashSet<>();
Map> sampledVerticalEnvelopes = new LinkedHashMap<>();
PackStructureResolver resolver = new PackStructureResolver(data);
- for (ResourceId id : data.getPackResources().ids(IrisStructure.class)) {
+ for (ResourceId id : data.getPackResources().ids(StructureResources.STRUCTURES)) {
String structureKey = id.path();
if (structureKey.equals(LEGACY_INDEX_KEY) || (activeStructureKeys != null && !activeStructureKeys.contains(structureKey))) {
continue;
diff --git a/src/main/java/art/arcane/iris/engine/framework/structure/StructureLocating.java b/src/main/java/art/arcane/iris/engine/framework/structure/StructureLocating.java
index a3842ec4f..f65a38ae5 100644
--- a/src/main/java/art/arcane/iris/engine/framework/structure/StructureLocating.java
+++ b/src/main/java/art/arcane/iris/engine/framework/structure/StructureLocating.java
@@ -18,15 +18,18 @@
package art.arcane.iris.engine.framework.structure;
-import art.arcane.iris.core.modules.IrisPackWorld;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.IrisStructureLocator;
import com.volmit.resource.PackResources;
+import com.volmit.resource.ResourceId;
import com.volmit.service.LocateResult;
import com.volmit.service.StructureLocator;
import com.volmit.world.BlockPosition;
import com.volmit.world.PackWorld;
+
+import java.util.Collection;
import java.util.LinkedHashSet;
+import java.util.Locale;
import java.util.Set;
/**
@@ -35,26 +38,32 @@ import java.util.Set;
* {@link IrisStructureLocator}. The keys it places also name the platform structures its native placements start and
* the ones its structures stand in for; it locates those too. The platform's own locate of a natively started
* structure goes through {@link StructureVanillaStructures#locateStart} instead.
+ *
+ * Iris's locator names structures by key: a pack structure by its pack key, a platform structure by its
+ * {@code namespace:path}. A key with a namespace is that id; any other is the pack's.
*/
public final class StructureLocating implements StructureLocator {
+ private static final char NAMESPACE_SEPARATOR = ':';
+
@Override
- public Set structures(PackResources pack) {
- return new LinkedHashSet<>(StructureResources.structureKeysOf(pack));
+ public Set structures(PackResources pack) {
+ return idsOf(pack, StructureResources.structureKeysOf(pack));
}
@Override
- public Set locatable(PackWorld world) {
- return IrisStructureLocator.locatableEditableKeys(engine(world));
+ public Set locatable(PackWorld world) {
+ return idsOf(world.resources(), IrisStructureLocator.locatableEditableKeys(engine(world)));
}
@Override
- public Set placed(PackWorld world) {
- return IrisStructureLocator.placedKeysAndAliases(engine(world));
+ public Set placed(PackWorld world) {
+ return idsOf(world.resources(), IrisStructureLocator.placedKeysAndAliases(engine(world)));
}
@Override
- public LocateResult locate(PackWorld world, String key, int fromX, int fromZ, int maxRadiusChunks) {
+ public LocateResult locate(PackWorld world, ResourceId structure, int fromX, int fromZ, int maxRadiusChunks) {
Engine engine = engine(world);
+ String key = keyOf(world.resources(), IrisStructureLocator.placedKeysAndAliases(engine), structure);
IrisStructureLocator.LocateResult result = IrisStructureLocator.locate(engine, key, fromX, fromZ, maxRadiusChunks);
return switch (result.status()) {
case FOUND -> LocateResult.found(new BlockPosition(result.originX(), result.baseY() - engine.getMinHeight(), result.originZ()));
@@ -64,6 +73,28 @@ public final class StructureLocating implements StructureLocator {
}
private static Engine engine(PackWorld world) {
- return IrisPackWorld.of(world).engine();
+ return world.extension(Engine.class).orElseThrow();
+ }
+
+ private static Set idsOf(PackResources pack, Collection keys) {
+ Set ids = new LinkedHashSet<>();
+ for (String key : keys) {
+ ids.add(idOf(pack, key));
+ }
+ return ids;
+ }
+
+ private static ResourceId idOf(PackResources pack, String key) {
+ return key.indexOf(NAMESPACE_SEPARATOR) >= 0 ? ResourceId.parse(key.toLowerCase(Locale.ROOT)) : pack.idOf(key);
+ }
+
+ /** The locator's key of {@code structure}: the placed key with that id, else the id as written. */
+ private static String keyOf(PackResources pack, Collection placedKeys, ResourceId structure) {
+ for (String key : placedKeys) {
+ if (idOf(pack, key).equals(structure)) {
+ return key;
+ }
+ }
+ return structure.toString();
}
}
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 bb302a93a..a5504fa6c 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
@@ -87,7 +87,7 @@ public final class StructureResources {
}
IrisPackResources resources = data.getPackResources();
try {
- return resources.find(kind.key(resources.idOf(key))).orElse(null);
+ return resources.find(kind, resources.idOf(key)).orElse(null);
} catch (IllegalStateException failedToLoad) {
return null;
}
@@ -99,6 +99,6 @@ public final class StructureResources {
}
private static List keys(PackResources pack, ResourceKind> kind) {
- return pack.ids(kind.type()).stream().map(ResourceId::path).toList();
+ return pack.ids(kind).stream().map(ResourceId::path).toList();
}
}
diff --git a/src/main/java/art/arcane/iris/engine/framework/structure/StructureVanillaStructures.java b/src/main/java/art/arcane/iris/engine/framework/structure/StructureVanillaStructures.java
index b19815e41..5c7702f88 100644
--- a/src/main/java/art/arcane/iris/engine/framework/structure/StructureVanillaStructures.java
+++ b/src/main/java/art/arcane/iris/engine/framework/structure/StructureVanillaStructures.java
@@ -18,8 +18,6 @@
package art.arcane.iris.engine.framework.structure;
-import art.arcane.iris.core.modules.IrisPackSettings;
-import art.arcane.iris.core.modules.IrisPackWorld;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.IrisStructureLocator;
import art.arcane.iris.engine.framework.StructurePlacementGrid;
@@ -64,7 +62,7 @@ public final class StructureVanillaStructures implements VanillaStructures {
*/
@Override
public VanillaStructureRule rule(ResourceId structure, VanillaStructureContext context) {
- Engine engine = IrisPackSettings.of(context.settings()).engine();
+ Engine engine = context.settings().extension(Engine.class).orElseThrow();
String key = structure.toString();
boolean replaced = IrisStructureLocator.suppressesVanilla(engine, key);
boolean blocked = replaced || ImportedStructures.of(context.settings()).disables(key);
@@ -135,7 +133,7 @@ public final class StructureVanillaStructures implements VanillaStructures {
}
private static Engine engine(PackWorld world) {
- return IrisPackWorld.of(world).engine();
+ return world.extension(Engine.class).orElseThrow();
}
private static Set structureIds(Set keys) {
diff --git a/src/main/java/art/arcane/iris/engine/framework/structure/fit/CarveFootprints.java b/src/main/java/art/arcane/iris/engine/framework/structure/fit/CarveFootprints.java
index 04665da60..e2f29c440 100644
--- a/src/main/java/art/arcane/iris/engine/framework/structure/fit/CarveFootprints.java
+++ b/src/main/java/art/arcane/iris/engine/framework/structure/fit/CarveFootprints.java
@@ -19,6 +19,7 @@
package art.arcane.iris.engine.framework.structure.fit;
import art.arcane.iris.engine.mantle.components.StructureCarvingFootprint;
+import com.volmit.vanilla.StartKey;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -163,8 +164,8 @@ final class CarveFootprints {
}
}
- /** The platform's start has no value equality, so the key pins the exact start a chunk carves against. */
- private record CarveFootprintKey(Object start, int padding) {
+ /** A start's key is equal only to itself, so the key pins the exact start a chunk carves against. */
+ private record CarveFootprintKey(StartKey start, int padding) {
}
private record CachedCarveFootprint(StructureCarvingFootprint footprint, int cells) {
diff --git a/src/main/java/art/arcane/iris/engine/framework/structure/fit/FitStart.java b/src/main/java/art/arcane/iris/engine/framework/structure/fit/FitStart.java
index bad24142e..9418d5350 100644
--- a/src/main/java/art/arcane/iris/engine/framework/structure/fit/FitStart.java
+++ b/src/main/java/art/arcane/iris/engine/framework/structure/fit/FitStart.java
@@ -21,6 +21,7 @@ package art.arcane.iris.engine.framework.structure.fit;
import art.arcane.iris.builtin.structure.StructureTerrain;
import art.arcane.iris.engine.framework.structure.NativeStructureFit;
import com.volmit.vanilla.DecorationStep;
+import com.volmit.vanilla.StartKey;
import com.volmit.vanilla.StructureFit;
import com.volmit.vanilla.TerrainAdaptation;
@@ -88,7 +89,7 @@ final class FitStart {
return bounds;
}
- Object key() {
+ StartKey key() {
return start.key();
}
}
diff --git a/src/main/java/art/arcane/iris/engine/framework/structure/fit/RigidSupport.java b/src/main/java/art/arcane/iris/engine/framework/structure/fit/RigidSupport.java
index d0b927e20..95a8df136 100644
--- a/src/main/java/art/arcane/iris/engine/framework/structure/fit/RigidSupport.java
+++ b/src/main/java/art/arcane/iris/engine/framework/structure/fit/RigidSupport.java
@@ -19,14 +19,13 @@
package art.arcane.iris.engine.framework.structure.fit;
import com.volmit.block.BlockState;
+import com.volmit.vanilla.StartKey;
import com.volmit.vanilla.TemplateCells;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -52,7 +51,7 @@ final class RigidSupport {
try {
BatchCellBudget budget = new BatchCellBudget();
List requests = new ArrayList<>();
- Set