diff --git a/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/IrisStructureLocateCommandContractTest.java b/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/IrisStructureLocateCommandContractTest.java
index 2be4d87f1..6a8f77ead 100644
--- a/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/IrisStructureLocateCommandContractTest.java
+++ b/adapters/bukkit/plugin/src/test/java/art/arcane/iris/core/commands/IrisStructureLocateCommandContractTest.java
@@ -118,7 +118,7 @@ public class IrisStructureLocateCommandContractTest {
@Test
public void unregisteredDiagnosticExplainsEveryRejectedRoute() {
assertEquals(
- "Native structure minecraft:village is disabled by this dimension's importedStructures settings.",
+ "Native structure minecraft:village is disabled by this dimension's importedStructures settings or a module of the pack.",
CommandFind.describeStructureExclusion(
CommandFind.StructureLookupRoute.POLICY_DISABLED, "minecraft:village",
NativeStructureGenerationStatus.DISABLED_BY_PACK,
@@ -214,7 +214,7 @@ public class IrisStructureLocateCommandContractTest {
@Test
public void findNativePolicyMessagesMatchModdedDiagnostics() {
assertEquals(
- "Native structure minecraft:village_plains is disabled by this dimension's importedStructures settings.",
+ "Native structure minecraft:village_plains is disabled by this dimension's importedStructures settings or a module of the pack.",
NativeStructureGenerationPolicy.generationStatusMessage(
"minecraft:village_plains", NativeStructureGenerationStatus.DISABLED_BY_PACK));
assertEquals(
diff --git a/adapters/modded-common/src/test/java/art/arcane/iris/nativegen/NativeStructureReferenceRepairTest.java b/adapters/modded-common/src/test/java/art/arcane/iris/nativegen/NativeStructureReferenceRepairTest.java
index f78891cb7..0e4ca8ddd 100644
--- a/adapters/modded-common/src/test/java/art/arcane/iris/nativegen/NativeStructureReferenceRepairTest.java
+++ b/adapters/modded-common/src/test/java/art/arcane/iris/nativegen/NativeStructureReferenceRepairTest.java
@@ -43,6 +43,7 @@ import net.minecraft.world.level.levelgen.structure.structures.OceanMonumentStru
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
@@ -56,6 +57,9 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class NativeStructureReferenceRepairTest {
@BeforeClass
@@ -138,7 +142,7 @@ public class NativeStructureReferenceRepairTest {
NativeStructureReferenceEnvelope.referenceBounds(start, structure, terrain));
IrisDimension dimension = new IrisDimension();
dimension.getImportedStructures().getDisabled().add(structureKey);
- IrisData data = allocateWithoutConstructor(IrisData.class);
+ IrisData data = packWithoutModules();
Engine engine = engine(dimension, data);
IrisNativeStructureDecision currentDecision = NativeStructureGenerationPolicy.resolve(
engine, structureKey, false);
@@ -322,6 +326,16 @@ public class NativeStructureReferenceRepairTest {
handler);
}
+ /**
+ * A pack without modules: the generation policy asks the pack's vanilla structure hooks, and there are none. The
+ * adapters' tests do not see IrisApi's host classes, so the catalog is a deep stub.
+ */
+ private static IrisData packWithoutModules() {
+ IrisData data = mock(IrisData.class, RETURNS_DEEP_STUBS);
+ when(data.getDataFolder()).thenReturn(new File("pack"));
+ return data;
+ }
+
private static Engine engine(IrisDimension dimension, IrisData data) throws Exception {
TestEngine engine = allocateWithoutConstructor(TestEngine.class);
engine.dimension = dimension;
diff --git a/core/src/main/java/art/arcane/iris/core/modules/IrisBlockRegistry.java b/core/src/main/java/art/arcane/iris/core/modules/IrisBlockRegistry.java
index b7c93cf9c..f5f9cb962 100644
--- a/core/src/main/java/art/arcane/iris/core/modules/IrisBlockRegistry.java
+++ b/core/src/main/java/art/arcane/iris/core/modules/IrisBlockRegistry.java
@@ -18,26 +18,62 @@
package art.arcane.iris.core.modules;
+import art.arcane.iris.core.loader.IrisData;
+import art.arcane.iris.engine.object.material.IrisBlockData;
+import art.arcane.iris.engine.object.prefab.TileData;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.spi.PlatformFace;
import com.volmit.block.BlockFace;
import com.volmit.block.BlockRegistry;
+import com.volmit.block.BlockSpec;
import com.volmit.block.BlockState;
import com.volmit.block.BlockTrait;
+import com.volmit.object.BlockEntityData;
import com.volmit.resource.ResourceId;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* IrisApi's view of the bound platform's blocks. States convert through their keys, as {@link PlatformBlockStates}
* does; the platform decides which blocks exist, so a key it does not know fails. Traits, tags and attachment to
* a face are the platform's own answers: its block tags, its falling blocks and its face support.
+ *
+ * {@link BlockSpec}s resolve as Iris resolves the block data packs write ({@link IrisValues#blockData}): a block of
+ * the pack's {@code blocks} folder, the platform's block, the backup, then air. Each spec is converted once per
+ * pack snapshot, so its resolution is too.
*/
final class IrisBlockRegistry implements BlockRegistry {
+ private final IrisData data;
+ private final Map specs = new ConcurrentHashMap<>();
+
+ /** @param data the pack whose {@code blocks} folder custom blocks come from */
+ IrisBlockRegistry(IrisData data) {
+ this.data = data;
+ }
+
@Override
public BlockState resolve(String key) {
return BlockState.parse(PlatformBlockStates.namespaced(platformState(key).key()));
}
+ @Override
+ public BlockState resolve(BlockSpec spec) {
+ return BlockState.parse(PlatformBlockStates.namespaced(blockData(spec).getBlockData(data).key()));
+ }
+
+ @Override
+ public Optional blockEntity(BlockSpec spec) {
+ TileData tile = blockData(spec).tryGetTile(data);
+ return tile == null ? Optional.empty() : Optional.of(BlockEntities.of(tile));
+ }
+
+ private IrisBlockData blockData(BlockSpec spec) {
+ return specs.computeIfAbsent(spec, IrisValues::blockData);
+ }
+
@Override
public boolean hasTrait(BlockState state, BlockTrait trait) {
PlatformBlockState platform = platformState(state.key());
diff --git a/core/src/main/java/art/arcane/iris/core/modules/IrisNoiseFactory.java b/core/src/main/java/art/arcane/iris/core/modules/IrisNoiseFactory.java
new file mode 100644
index 000000000..aaa653802
--- /dev/null
+++ b/core/src/main/java/art/arcane/iris/core/modules/IrisNoiseFactory.java
@@ -0,0 +1,68 @@
+/*
+ * 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.core.modules;
+
+import art.arcane.iris.core.loader.IrisData;
+import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
+import art.arcane.iris.util.project.noise.CNG;
+import art.arcane.volmlib.util.math.RNG;
+import com.volmit.noise.NoiseFactory;
+import com.volmit.noise.NoiseSampler;
+import com.volmit.noise.NoiseStyle;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Builds the noise of IrisApi noise styles with Iris's own generators: each style becomes the
+ * {@link IrisGeneratorStyle} that reads the same JSON ({@link IrisValues#generatorStyle}), once per pack snapshot, and
+ * builds its noise from an {@link RNG} of the seed exactly as Iris's own features do, with Iris's per-style cache of
+ * built generators.
+ */
+final class IrisNoiseFactory implements NoiseFactory {
+ private final IrisData data;
+ private final Map styles = new ConcurrentHashMap<>();
+
+ IrisNoiseFactory(IrisData data) {
+ this.data = data;
+ }
+
+ @Override
+ public NoiseSampler sampler(NoiseStyle style, long seed) {
+ IrisGeneratorStyle iris = styles.computeIfAbsent(style, IrisValues::generatorStyle);
+ try {
+ return new CngSampler(iris.create(new RNG(seed), data));
+ } catch (RuntimeException failure) {
+ throw new IllegalArgumentException("Cannot build the noise of " + style + ": " + failure.getMessage(), failure);
+ }
+ }
+
+ /** Iris's noise as an IrisApi sampler; CNG is safe for the concurrent reads generation makes. */
+ private record CngSampler(CNG noise) implements NoiseSampler {
+ @Override
+ public double sample(double worldX, double worldZ) {
+ return noise.noise(worldX, worldZ);
+ }
+
+ @Override
+ public double sample(double worldX, double y, double worldZ) {
+ return noise.noise(worldX, y, worldZ);
+ }
+ }
+}
diff --git a/core/src/main/java/art/arcane/iris/core/modules/IrisPackResources.java b/core/src/main/java/art/arcane/iris/core/modules/IrisPackResources.java
index cddb38dd9..988ef5161 100644
--- a/core/src/main/java/art/arcane/iris/core/modules/IrisPackResources.java
+++ b/core/src/main/java/art/arcane/iris/core/modules/IrisPackResources.java
@@ -26,6 +26,7 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import com.volmit.block.BlockRegistry;
import com.volmit.host.ResourceKindRegistration;
+import com.volmit.noise.NoiseFactory;
import com.volmit.object.GeneratedObject;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
@@ -57,6 +58,9 @@ import java.util.function.Supplier;
* another namespace, is absent; any other type fails with {@link IllegalArgumentException}. A resource that exists
* but cannot be loaded fails with {@link IllegalStateException}. Each resource is built once and kept for the
* snapshot. The module kinds are looked up the first time one is asked for, which loads the pack's modules.
+ *
+ * Blocks resolve through the platform and the pack's {@code blocks} folder ({@link IrisBlockRegistry}), and noise
+ * styles through Iris's generators, expressions and image maps ({@link IrisNoiseFactory}), both kept per snapshot.
*/
public final class IrisPackResources implements PackResources {
private static final String SERVED_TYPES = "GeneratedObject, PackBiome, PackRegion and the types of the pack's module resource kinds";
@@ -64,7 +68,8 @@ public final class IrisPackResources implements PackResources {
private final IrisData data;
private final PackResourceIds ids;
private final UUID snapshotId = UUID.randomUUID();
- private final BlockRegistry blocks = new IrisBlockRegistry();
+ private final BlockRegistry blocks;
+ private final NoiseFactory noise;
private final Map, Kind>> irisKinds;
private final Supplier>> moduleKindList;
private volatile Map, Kind>> moduleKinds;
@@ -82,6 +87,8 @@ public final class IrisPackResources implements PackResources {
this.data = data;
this.ids = new PackResourceIds(data.getDataFolder());
this.moduleKindList = moduleKinds;
+ this.blocks = new IrisBlockRegistry(data);
+ this.noise = new IrisNoiseFactory(data);
this.irisKinds = Map.of(
GeneratedObject.class, Kind.ofLoader(ids, data::getObjectLoader, (id, object) -> object.getGeometry()),
PackBiome.class, Kind.ofLoader(ids, data::getBiomeLoader, this::biomeOf),
@@ -115,6 +122,11 @@ public final class IrisPackResources implements PackResources {
return blocks;
}
+ @Override
+ public NoiseFactory noise() {
+ return noise;
+ }
+
@Override
@SuppressWarnings("unchecked") // The kinds are keyed by the type they serve.
public Optional find(ResourceKey key) {
diff --git a/core/src/main/java/art/arcane/iris/core/modules/IrisPackSettings.java b/core/src/main/java/art/arcane/iris/core/modules/IrisPackSettings.java
index d39267ff6..2722584d3 100644
--- a/core/src/main/java/art/arcane/iris/core/modules/IrisPackSettings.java
+++ b/core/src/main/java/art/arcane/iris/core/modules/IrisPackSettings.java
@@ -33,10 +33,9 @@ import java.util.ArrayList;
import java.util.List;
/**
- * The settings an engine's pack declares, for working out mantle stage reaches when the pack loads: the
- * engine's dimension, then every region it can reach, then every biome. Iris's built-in mantle stages size
- * their reach from Iris's own pack data instead of module settings; they reach the engine through
- * {@link #of(PackSettings)}.
+ * The settings an engine's pack declares, for working out mantle stage reaches when the pack loads and for vanilla
+ * structure hooks: the engine's dimension, then every region it can reach, then every biome. Iris's built-in modules
+ * decide from Iris's own pack data instead of module settings; they reach the engine through {@link #of(PackSettings)}.
*/
public final class IrisPackSettings implements PackSettings {
static final String DIMENSION = "dimension";
@@ -54,7 +53,7 @@ public final class IrisPackSettings implements PackSettings {
/** Iris's own view of {@code settings}, which Iris hands to every reach it works out. */
public static IrisPackSettings of(PackSettings settings) {
if (!(settings instanceof IrisPackSettings irisSettings)) {
- throw new IllegalArgumentException("Built-in reaches are worked out from an Iris engine's pack, not " + settings);
+ throw new IllegalArgumentException("Built-in modules read an Iris engine's pack, not " + settings);
}
return irisSettings;
}
diff --git a/core/src/main/java/art/arcane/iris/core/modules/IrisValues.java b/core/src/main/java/art/arcane/iris/core/modules/IrisValues.java
new file mode 100644
index 000000000..ad229d57b
--- /dev/null
+++ b/core/src/main/java/art/arcane/iris/core/modules/IrisValues.java
@@ -0,0 +1,105 @@
+/*
+ * 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.core.modules;
+
+import art.arcane.iris.engine.object.material.IrisBlockData;
+import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
+import art.arcane.iris.engine.object.noise.IrisStyledRange;
+import art.arcane.iris.engine.object.noise.NoiseStyle;
+import art.arcane.iris.engine.object.value.IrisPosition;
+import art.arcane.iris.engine.object.value.IrisRange;
+import art.arcane.volmlib.util.collection.KMap;
+import com.volmit.block.BlockSpec;
+import com.volmit.config.Range;
+import com.volmit.noise.StyledRange;
+import com.volmit.world.BlockPosition;
+
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * Iris's own classes for IrisApi's value types. Each pair reads the same pack JSON, so Iris resolves a value the way
+ * it resolves its own class (a {@link BlockSpec} as an {@link IrisBlockData}, a noise style as an
+ * {@link IrisGeneratorStyle}) and studio describes the value with Iris's own description of that class.
+ */
+public final class IrisValues {
+ private static final Map> IRIS_CLASSES = Map.of(
+ BlockSpec.class.getName(), IrisBlockData.class,
+ com.volmit.noise.NoiseStyle.class.getName(), IrisGeneratorStyle.class,
+ StyledRange.class.getName(), IrisStyledRange.class,
+ Range.class.getName(), IrisRange.class,
+ BlockPosition.class.getName(), IrisPosition.class);
+
+ private IrisValues() {
+ }
+
+ /** The Iris class that reads the same JSON as the IrisApi value type named {@code apiTypeName}, if it is one. */
+ public static Optional> irisClassOf(String apiTypeName) {
+ return Optional.ofNullable(IRIS_CLASSES.get(apiTypeName));
+ }
+
+ /** The IrisApi value types and the Iris classes that read the same JSON. */
+ static Map> irisClasses() {
+ return IRIS_CLASSES;
+ }
+
+ /** {@code spec} as the block data Iris resolves: its block, properties, weight, backup and tile data. */
+ static IrisBlockData blockData(BlockSpec spec) {
+ IrisBlockData block = new IrisBlockData(spec.block());
+ block.setData(irisMap(spec.data()));
+ block.setWeight(spec.weight());
+ block.setBackup(spec.backup().map(IrisValues::blockData).orElse(null));
+ block.setTileData(irisMap(spec.tileData()));
+ return block;
+ }
+
+ /** Iris's maps hold no null values; a JSON null in a map reads as absent, as it does for Iris's own fields. */
+ private static KMap irisMap(Map values) {
+ KMap map = new KMap<>();
+ values.forEach((key, value) -> {
+ if (value != null) {
+ map.put(key, value);
+ }
+ });
+ return map;
+ }
+
+ /** {@code style} as the generator style Iris builds noise from; a style name Iris does not know is flat. */
+ static IrisGeneratorStyle generatorStyle(com.volmit.noise.NoiseStyle style) {
+ IrisGeneratorStyle iris = new IrisGeneratorStyle(irisStyle(style.style()));
+ iris.setCellularFrequency(style.cellularFrequency());
+ iris.setCellularZoom(style.cellularZoom());
+ iris.setZoom(style.zoom());
+ iris.setExpression(style.expression().orElse(null));
+ iris.setImageMap(style.imageMap().orElse(null));
+ iris.setMultiplier(style.multiplier());
+ iris.setFracture(style.fracture().map(IrisValues::generatorStyle).orElse(null));
+ iris.setExponent(style.exponent());
+ iris.setCacheSize(style.cacheSize());
+ return iris;
+ }
+
+ private static NoiseStyle irisStyle(String name) {
+ try {
+ return NoiseStyle.valueOf(name);
+ } catch (IllegalArgumentException unknown) {
+ return NoiseStyle.FLAT;
+ }
+ }
+}
diff --git a/core/src/main/java/art/arcane/iris/core/modules/ModuleSettingsDecoder.java b/core/src/main/java/art/arcane/iris/core/modules/ModuleSettingsDecoder.java
index 20b11d7d5..c862c95e2 100644
--- a/core/src/main/java/art/arcane/iris/core/modules/ModuleSettingsDecoder.java
+++ b/core/src/main/java/art/arcane/iris/core/modules/ModuleSettingsDecoder.java
@@ -57,7 +57,9 @@ import java.util.stream.Stream;
* Reads the module settings a dimension, region or biome declares: each settings feature of the pack at
* that target, under its id or, for built-ins, its alias. Settings are created with their no-argument
* constructor and the JSON is read into them, so an omitted option keeps its default. A {@link Snippet}
- * type may be written as {@code "snippet/"}, read from {@code snippet//.json}.
+ * type may be written as {@code "snippet/"} or, as Iris's own snippets are, {@code "snippet//"},
+ * both read from {@code snippet//.json}. IrisApi's value types ({@code BlockSpec},
+ * {@code NoiseStyle} and the rest) are read like settings, and an {@code Object} as Gson reads any JSON value.
*
* Settings with exactly one option may be written as that option's value: {@code "snow": 0.5} reads as
* {@code "snow": {"amount": 0.5}}. Iris's own classes that built-in settings hold (see
@@ -244,13 +246,20 @@ public final class ModuleSettingsDecoder {
}
}
+ /** The file name below the snippet folder: {@code snippet/} and {@code snippet//} name the same file. */
+ private static String snippetName(String snippetFolder, String reference) {
+ String name = reference.substring(SNIPPET_PREFIX.length());
+ String folderPrefix = snippetFolder + "/";
+ return name.startsWith(folderPrefix) ? name.substring(folderPrefix.length()) : name;
+ }
+
private String readSnippet(String snippetFolder, String reference) {
if (!reference.startsWith(SNIPPET_PREFIX)) {
throw new JsonParseException("\"" + reference + "\" is neither an object nor a snippet reference; write the object,"
+ " or snippet/ for the file " + SNIPPET_FOLDER + "/" + snippetFolder + "/" + JSON_EXTENSION);
}
Path folder = packFolder.resolve(SNIPPET_FOLDER).resolve(snippetFolder).normalize();
- Path file = folder.resolve(reference.substring(SNIPPET_PREFIX.length()) + JSON_EXTENSION).normalize();
+ Path file = folder.resolve(snippetName(snippetFolder, reference) + JSON_EXTENSION).normalize();
if (!file.startsWith(folder) || !Files.isRegularFile(file)) {
throw new JsonParseException("Snippet " + reference + " has no file " + packFolder.relativize(file));
}
diff --git a/core/src/main/java/art/arcane/iris/core/modules/ModuleVanillaStructures.java b/core/src/main/java/art/arcane/iris/core/modules/ModuleVanillaStructures.java
new file mode 100644
index 000000000..9d456f5da
--- /dev/null
+++ b/core/src/main/java/art/arcane/iris/core/modules/ModuleVanillaStructures.java
@@ -0,0 +1,107 @@
+/*
+ * 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.core.modules;
+
+import art.arcane.iris.engine.framework.Engine;
+import com.volmit.config.PackSettings;
+import com.volmit.host.VanillaStructureHookRegistration;
+import com.volmit.resource.PackResources;
+import com.volmit.resource.ResourceId;
+import com.volmit.vanilla.VanillaStructureContext;
+import com.volmit.vanilla.VanillaStructureRule;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * What the pack's modules want for each of the platform's own structures in one engine's world: every vanilla structure
+ * hook of the pack asked once per structure, the rules combined ({@link VanillaStructureRule#and}). Kept per engine and
+ * pack snapshot, so a hotload or a reload of the pack's resources asks the hooks again. The platform side
+ * ({@code NativeStructureGenerationPolicy}) applies the result on Bukkit and the modded platforms alike.
+ */
+public final class ModuleVanillaStructures {
+ private static final Map WORLDS = Collections.synchronizedMap(new WeakHashMap<>());
+
+ private final PackResources snapshot;
+ private final List hooks;
+ private final VanillaStructureContext world;
+ private final Map rules = new ConcurrentHashMap<>();
+
+ private ModuleVanillaStructures(Engine engine, PackResources snapshot) {
+ this.snapshot = snapshot;
+ this.hooks = engine.getData().getModules().pack().catalog().vanillaStructureHooks();
+ this.world = new World(snapshot, new IrisPackSettings(engine));
+ }
+
+ /** The combined rule of the pack's modules for the platform structure {@code structureKey} in {@code engine}'s world. */
+ public static VanillaStructureRule ruleFor(Engine engine, String structureKey) {
+ return of(engine).rule(structureKey);
+ }
+
+ private static ModuleVanillaStructures of(Engine engine) {
+ PackResources current = engine.getData().getPackResources();
+ ModuleVanillaStructures known = WORLDS.get(engine);
+ if (known != null && known.snapshot == current) {
+ return known;
+ }
+ ModuleVanillaStructures fresh = new ModuleVanillaStructures(engine, current);
+ WORLDS.put(engine, fresh);
+ return fresh;
+ }
+
+ private VanillaStructureRule rule(String structureKey) {
+ return rules.computeIfAbsent(structureKey, this::askHooks);
+ }
+
+ /** A key that is no resource id names no structure a module could decide over. */
+ private VanillaStructureRule askHooks(String structureKey) {
+ ResourceId structure;
+ try {
+ structure = ResourceId.parse(structureKey);
+ } catch (IllegalArgumentException notAnId) {
+ return VanillaStructureRule.GENERATE;
+ }
+ VanillaStructureRule combined = VanillaStructureRule.GENERATE;
+ for (VanillaStructureHookRegistration registration : hooks) {
+ combined = combined.and(ask(registration, structure));
+ }
+ return combined;
+ }
+
+ private VanillaStructureRule ask(VanillaStructureHookRegistration registration, ResourceId structure) {
+ VanillaStructureRule rule;
+ try {
+ rule = registration.hook().rule(structure, world);
+ } catch (RuntimeException failure) {
+ throw new IllegalStateException("Module " + registration.module() + " failed deciding over vanilla structure "
+ + structure + ": " + failure, failure);
+ }
+ if (rule == null) {
+ throw new IllegalStateException("Module " + registration.module() + " gave no rule for vanilla structure " + structure);
+ }
+ return rule;
+ }
+
+ /** The world the hooks decide for: the engine's pack snapshot and the settings its dimension reaches. */
+ private record World(PackResources resources, PackSettings settings) implements VanillaStructureContext {
+ }
+}
diff --git a/core/src/main/java/art/arcane/iris/core/project/IrisCodeWorkspace.java b/core/src/main/java/art/arcane/iris/core/project/IrisCodeWorkspace.java
index 120e92fc7..eef61784e 100644
--- a/core/src/main/java/art/arcane/iris/core/project/IrisCodeWorkspace.java
+++ b/core/src/main/java/art/arcane/iris/core/project/IrisCodeWorkspace.java
@@ -21,6 +21,7 @@ package art.arcane.iris.core.project;
import art.arcane.iris.core.IrisSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
+import art.arcane.iris.core.modules.IrisValues;
import art.arcane.iris.core.modules.PackModulesException;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.iris.spi.IrisLogging;
@@ -230,6 +231,9 @@ public class IrisCodeWorkspace {
}
for (ObjectType type : dm.getModules().pack().schema().snippets()) {
+ if (IrisValues.irisClassOf(type.name()).isPresent()) {
+ continue;
+ }
schemaEntries.add(moduleSnippetSchema(dm, type, immediateSchemas));
}
schemaEntries.addAll(ModuleResourceSchemas.entries(dm, immediateSchemas));
@@ -252,7 +256,10 @@ public class IrisCodeWorkspace {
return ws;
}
- /** A module's snippet type gets its own schema for the files under {@code snippet//}, as Iris's snippets do. */
+ /**
+ * A module's snippet type gets its own schema for the files under {@code snippet//}, as Iris's snippets do. IrisApi's
+ * value types share their snippet folders with the Iris classes that read the same JSON, whose schemas Iris writes.
+ */
private static JSONObject moduleSnippetSchema(IrisData data, ObjectType type, boolean immediate) {
String name = type.snippet().orElseThrow();
JSONObject entry = snippetSchemaEntry(name);
diff --git a/core/src/main/java/art/arcane/iris/core/project/ModuleSchemaRenderer.java b/core/src/main/java/art/arcane/iris/core/project/ModuleSchemaRenderer.java
index fb7dcc47e..f37957ab2 100644
--- a/core/src/main/java/art/arcane/iris/core/project/ModuleSchemaRenderer.java
+++ b/core/src/main/java/art/arcane/iris/core/project/ModuleSchemaRenderer.java
@@ -41,7 +41,8 @@ import java.util.function.Function;
* schema studio writes: each feature as a property of its target under its id and, for built-ins, its
* alias, each settings class once as a definition, references as completion lists (resource references as the keys
* of the module resource kind they name). Settings with one option also accept that option's bare value; Iris's own
- * classes in built-in settings use Iris's own definitions.
+ * classes in built-in settings use Iris's own definitions, and so do IrisApi's value types, which read the same JSON as
+ * an Iris class ({@code BlockSpec} as Iris's block data), with the snippet references their {@code @Snippet} allows.
*/
final class ModuleSchemaRenderer {
private static final String DEFINITION_PREFIX = "module-";
@@ -70,16 +71,22 @@ final class ModuleSchemaRenderer {
private final ReferenceCompletions references;
private final ResourceCompletions resources;
private final HostDefinitions hostDefinitions;
+ private final Function> sameJsonHostTypes;
private final Function> snippetFiles;
- /** {@code snippetFiles} lists the snippet references a pack has for a snippet folder, such as {@code snippet/thick}. */
+ /**
+ * @param sameJsonHostTypes the Iris class that reads the same JSON as a module type, for IrisApi's value types
+ * @param snippetFiles lists the snippet references a pack has for a snippet folder, such as {@code snippet/thick}
+ */
ModuleSchemaRenderer(PackSchema schema, Map definitions, ReferenceCompletions references,
- ResourceCompletions resources, HostDefinitions hostDefinitions, Function> snippetFiles) {
+ ResourceCompletions resources, HostDefinitions hostDefinitions,
+ Function> sameJsonHostTypes, Function> snippetFiles) {
this.schema = schema;
this.definitions = definitions;
this.references = references;
this.resources = resources;
this.hostDefinitions = hostDefinitions;
+ this.sameJsonHostTypes = sameJsonHostTypes;
this.snippetFiles = snippetFiles;
}
@@ -137,22 +144,30 @@ final class ModuleSchemaRenderer {
}
definitions.put(key, new JSONObject());
ObjectType type = schema.type(typeName);
- definitions.put(key, type.snippet().isPresent() ? objectOrSnippet(type) : objectSchema(type));
+ JSONObject object = describedObject(type);
+ definitions.put(key, type.snippet().isPresent() ? objectOrSnippet(object, type) : object);
return key;
}
- private JSONObject objectOrSnippet(ObjectType type) {
+ /** Iris's own description where an Iris class reads the same JSON, otherwise the module's. */
+ private JSONObject describedObject(ObjectType type) {
+ return sameJsonHostTypes.apply(type.name())
+ .map(hostType -> new JSONObject().put("$ref", DEFINITION_REF + hostDefinitions.definition(hostType)))
+ .orElseGet(() -> objectSchema(type));
+ }
+
+ private JSONObject objectOrSnippet(JSONObject object, ObjectType type) {
String folder = type.snippet().orElseThrow();
JSONObject reference = new JSONObject();
reference.put("type", "string");
- JSONArray files = new JSONArray(snippetFiles.apply(folder));
+ JSONArray files = new JSONArray(List.