diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/IrisModdedChunkGenerator.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/IrisModdedChunkGenerator.java index 4893e24d8..088f82936 100644 --- a/adapters/modded-common/src/main/java/art/arcane/iris/modded/IrisModdedChunkGenerator.java +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/IrisModdedChunkGenerator.java @@ -533,10 +533,10 @@ public final class IrisModdedChunkGenerator extends ChunkGenerator { } String remedy = integratedEnvironment() ? "enable 'Generate Structures' for this world; Iris requires it, then deny families through " - + "iris:structure disabled or complete keys through iris:structure disabledExact" + + "importedStructures.disabled or complete keys through importedStructures.disabledExact" : "set generate-structures=true in server.properties, restart the server, " - + "then deny families through iris:structure disabled or complete keys through " - + "iris:structure disabledExact"; + + "then deny families through importedStructures.disabled or complete keys through " + + "importedStructures.disabledExact"; throw new IllegalStateException("Iris generator '" + dimensionKey + "' cannot bind while generate-structures=false; " + remedy); } diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/ModdedNativeStructureStage.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/ModdedNativeStructureStage.java index a0ebab242..4f9f17e70 100644 --- a/adapters/modded-common/src/main/java/art/arcane/iris/modded/ModdedNativeStructureStage.java +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/ModdedNativeStructureStage.java @@ -290,8 +290,8 @@ final class ModdedNativeStructureStage { + " because generate-structures=false disables them outside the pack. That flag is fixed when " + "the world is created (server.properties generate-structures, or the Generate Structures " + "toggle in singleplayer), so it cannot be changed for this world: create a new world with " - + "structures enabled, then deny families through iris:structure disabled or complete keys " - + "through iris:structure disabledExact"); + + "structures enabled, then deny families through importedStructures.disabled or complete keys " + + "through importedStructures.disabledExact"); } ChunkPos chunkPos = chunk.getPos(); SectionPos sectionPos = SectionPos.of(chunkPos, world.getMinSectionY()); diff --git a/core/src/main/java/art/arcane/iris/core/datapack/DatapackIngestService.java b/core/src/main/java/art/arcane/iris/core/datapack/DatapackIngestService.java index 385adce6a..d538d96ae 100644 --- a/core/src/main/java/art/arcane/iris/core/datapack/DatapackIngestService.java +++ b/core/src/main/java/art/arcane/iris/core/datapack/DatapackIngestService.java @@ -677,7 +677,7 @@ public final class DatapackIngestService { if (report.changed()) { message(sender, C.YELLOW + "New datapack structures were installed. A server restart is required for them to register and generate."); message(sender, C.GRAY + "After the restart they generate natively only in Iris dimensions that declare their source URL - no import needed. To get editable Iris copies (jigsaw pools, pieces & objects written into the pack) run /iris structure import , or set general.autoImportDatapackStructures=true to do it on every ingest. Place any registered key directly with a 'structures' placement using nativeStructures."); - message(sender, C.GRAY + "Datapacks replace matching vanilla structure keys by default. Set 'iris:structure datapackOverrides' to false to keep minecraft-namespaced structure definitions untouched; deny non-minecraft datapack and mod structure families with iris:structure disabled or complete keys with iris:structure disabledExact."); + message(sender, C.GRAY + "Datapacks replace matching vanilla structure keys by default. Set 'importedStructures.datapackOverrides' to false to keep minecraft-namespaced structure definitions untouched; deny non-minecraft datapack and mod structure families with importedStructures.disabled or complete keys with importedStructures.disabledExact."); if (!restart) { message(sender, C.GRAY + "Run with restart=true to restart now, or restart manually. After restart, run /iris structure list to see the new keys."); } diff --git a/core/src/main/java/art/arcane/iris/core/loader/JsonSchemaValidator.java b/core/src/main/java/art/arcane/iris/core/loader/JsonSchemaValidator.java index 52cf01c84..cfe1766dd 100644 --- a/core/src/main/java/art/arcane/iris/core/loader/JsonSchemaValidator.java +++ b/core/src/main/java/art/arcane/iris/core/loader/JsonSchemaValidator.java @@ -19,7 +19,7 @@ public final class JsonSchemaValidator { /** * Warns about every top-level key that is neither a field of {@code objectClass} nor one of - * {@code moduleKeys}, the ids the pack's modules read at this resource's target. + * {@code moduleKeys}, the keys the pack's modules read at this resource's target. */ public static void validateTopLevelKeys(JSONObject parsed, String rawText, File file, String resourceTypeName, Class objectClass, Set moduleKeys) { diff --git a/core/src/main/java/art/arcane/iris/core/loader/ResourceLoader.java b/core/src/main/java/art/arcane/iris/core/loader/ResourceLoader.java index 6a3a21e18..ffb0cc46f 100644 --- a/core/src/main/java/art/arcane/iris/core/loader/ResourceLoader.java +++ b/core/src/main/java/art/arcane/iris/core/loader/ResourceLoader.java @@ -437,7 +437,7 @@ public class ResourceLoader implements MeteredCache { } } - /** The ids and aliases the pack's modules read at {@code target}; none for resources that hold no module settings. */ + /** The keys the pack's modules read at {@code target}; none for resources that hold no module settings. */ private Set moduleKeys(Optional target) { return target.map(found -> getManager().getModules().settings().keys(found)).orElse(Set.of()); } diff --git a/core/src/main/java/art/arcane/iris/core/modules/IrisModuleHost.java b/core/src/main/java/art/arcane/iris/core/modules/IrisModuleHost.java index 2ed901252..258dd09e4 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/IrisModuleHost.java +++ b/core/src/main/java/art/arcane/iris/core/modules/IrisModuleHost.java @@ -83,6 +83,7 @@ public final class IrisModuleHost { private static ModuleHost build() { return ModuleHost.of(builtInModules()) .exposing(BUILT_IN_API_PACKAGE) + .reservingFields(ModuleTargets.reservedFields()) .describingHostTypesIn(HOST_TYPE_PACKAGE) .reservingFolders(IrisData.ownFolderNames().toArray(String[]::new)) .copyingJarsTo(jarCopyRoot()) 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 fd3792a3e..a192f7042 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 @@ -18,6 +18,7 @@ package art.arcane.iris.core.modules; +import art.arcane.volmlib.util.json.JSONArray; import art.arcane.volmlib.util.json.JSONObject; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -31,6 +32,7 @@ import com.google.gson.stream.JsonWriter; import com.volmit.FeatureAttachment.Target; import com.volmit.IrisFeature; import com.volmit.block.BlockState; +import com.volmit.config.OptionsMetadata; import com.volmit.config.Snippet; import com.volmit.host.FeatureCatalog; import com.volmit.host.FeatureDescriptor; @@ -41,6 +43,7 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collection; import java.util.EnumMap; import java.util.LinkedHashMap; import java.util.List; @@ -53,13 +56,14 @@ 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. Settings are created with their no-argument + * that target, under the key the feature declares. 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/"} 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 are always written as their object. Iris's own classes that built-in settings hold (see + * Settings are written in the one shape their class declares: an object of the class's options or, when the feature + * names a {@code root} option, exactly that option's value. Iris's own classes that built-in settings hold (see * {@link IrisModuleHost#isHostType}) are read by Iris's pack Gson, exactly as Iris reads them elsewhere. */ public final class ModuleSettingsDecoder { @@ -89,7 +93,7 @@ public final class ModuleSettingsDecoder { } } - /** Every JSON key the pack's modules read at {@code target}: the feature ids, object generators' included. */ + /** Every JSON key the pack's modules read at {@code target}: the keys of their features, object generators' included. */ public Set keys(Target target) { return keys.get(target); } @@ -127,8 +131,8 @@ public final class ModuleSettingsDecoder { private IrisFeature read(FeatureDescriptor feature, Object value, String resource) { try { - requireObjectOrSnippet(feature, value); - IrisFeature decoded = gson.fromJson(JSONObject.valueToString(value), feature.type()); + requireShape(feature, value); + IrisFeature decoded = gson.fromJson(settingsJson(feature, value), feature.type()); if (decoded == null) { throw new JsonParseException("the value is null"); } @@ -139,6 +143,21 @@ public final class ModuleSettingsDecoder { } } + /** The settings object the value stands for: the value itself, or the root option holding it. */ + private static String settingsJson(FeatureDescriptor feature, Object value) { + return feature.root() + .map(root -> new JSONObject().put(root, value).toString()) + .orElseGet(() -> JSONObject.valueToString(value)); + } + + private static void requireShape(FeatureDescriptor feature, Object value) { + if (feature.root().isPresent()) { + requireRootValue(feature, feature.root().get(), value); + return; + } + requireObjectOrSnippet(feature, value); + } + private static void requireObjectOrSnippet(FeatureDescriptor feature, Object value) { if (value instanceof JSONObject || (value instanceof String && feature.type().isAnnotationPresent(Snippet.class))) { return; @@ -146,6 +165,31 @@ public final class ModuleSettingsDecoder { throw new JsonParseException("write the settings as an object, {\"