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 21b5a28ca..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 iris:structure settings or a module of the pack.", + "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 iris:structure settings or a module of the pack.", + "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/modded/NativeStructureFailureContractTest.java b/adapters/modded-common/src/test/java/art/arcane/iris/modded/NativeStructureFailureContractTest.java index 2b9ed7994..7ee5f5f67 100644 --- a/adapters/modded-common/src/test/java/art/arcane/iris/modded/NativeStructureFailureContractTest.java +++ b/adapters/modded-common/src/test/java/art/arcane/iris/modded/NativeStructureFailureContractTest.java @@ -52,8 +52,8 @@ public class NativeStructureFailureContractTest { assertTrue(error.getMessage().contains("overworld:overworld")); assertTrue(error.getMessage().contains("generate-structures=false")); - assertTrue(error.getMessage().contains("iris:structure disabled")); - assertTrue(error.getMessage().contains("iris:structure disabledExact")); + assertTrue(error.getMessage().contains("importedStructures.disabled")); + assertTrue(error.getMessage().contains("importedStructures.disabledExact")); } @Test diff --git a/core/src/test/java/art/arcane/iris/core/modules/BuiltInGenerationGraphTest.java b/core/src/test/java/art/arcane/iris/core/modules/BuiltInGenerationGraphTest.java index 4fc5906ec..8bfef778c 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/BuiltInGenerationGraphTest.java +++ b/core/src/test/java/art/arcane/iris/core/modules/BuiltInGenerationGraphTest.java @@ -24,9 +24,13 @@ import art.arcane.iris.builtin.decorant.DecorantSettings; import art.arcane.iris.builtin.decorant.Decorator; import art.arcane.iris.builtin.deposit.DepositGenerator; import art.arcane.iris.builtin.deposit.DepositSettings; +import art.arcane.iris.builtin.structure.StructureSettings; import com.volmit.FeatureAttachment.Target; +import com.volmit.FeatureRegistry; +import com.volmit.IrisFeature; import com.volmit.IrisModule; import com.volmit.ModuleInfo; +import com.volmit.config.Feature; import com.volmit.config.PackSettings; import com.volmit.host.LoadedPack; import com.volmit.host.ResolvedGraph; @@ -43,9 +47,11 @@ import org.junit.rules.TemporaryFolder; import java.io.IOException; import java.util.List; +import java.util.Optional; import java.util.OptionalInt; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -96,14 +102,15 @@ public class BuiltInGenerationGraphTest { } @Test - public void depositsAreSettingsOfEveryLevelWrittenAsTheirIdWithGenerators() throws IOException { + public void depositsAreTheListOfGeneratorsOfEveryLevelWrittenUnderDeposits() throws IOException { try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) { for (Target level : List.of(Target.DIMENSION, Target.REGION, Target.BIOME)) { FeatureSchema deposits = pack.schema().fields(level).stream() .filter(feature -> feature.settings().name().equals(DepositSettings.class.getName())) .findFirst().orElseThrow(); - assertEquals("iris:deposit", deposits.key()); - SchemaOption option = deposits.settings().options().getFirst(); + assertEquals("deposits", deposits.key()); + assertEquals(Optional.of("generators"), deposits.root()); + SchemaOption option = deposits.rootOption().orElseThrow(); assertEquals("generators", option.name()); ValueKind generators = option.kind(); assertEquals("generators are a module class of IrisApi types, not an Iris class", @@ -112,6 +119,71 @@ public class BuiltInGenerationGraphTest { } } + @Test + public void importedStructuresAreAnObjectOfOptionsOfTheDimension() throws IOException { + try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) { + FeatureSchema structures = pack.schema().fields(Target.DIMENSION).stream() + .filter(feature -> feature.settings().name().equals(StructureSettings.class.getName())) + .findFirst().orElseThrow(); + + assertEquals("importedStructures", structures.key()); + assertEquals(Optional.empty(), structures.root()); + assertEquals(List.of("disabled", "disabledExact", "undergroundYShift", "datapackOverrides", "frequencyOverrides", "adjustments"), + structures.settings().options().stream().map(SchemaOption::name).toList()); + } + } + + @Test + public void theBuiltInKeysAreUniquePerTargetAndNoFieldOfIris() throws IOException { + try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) { + for (Target target : Target.values()) { + List keys = pack.schema().fields(target).stream().map(FeatureSchema::key).toList(); + assertEquals(target + " " + keys, keys.size(), keys.stream().distinct().count()); + assertTrue(target + " " + keys, keys.stream().noneMatch(ModuleTargets.reservedFields().get(target)::contains)); + } + } + } + + @Test + public void aModuleCannotTakeTheKeyOfABuiltInOrAFieldOfIris() { + IllegalArgumentException deposits = assertThrows(IllegalArgumentException.class, + () -> BuiltInPack.serve(mock(IrisData.class), folder, List.of(new RivalModule(TakesDeposits.class)))); + assertEquals("region key \"deposits\" is claimed by iris:deposit (host classpath) and test:rival/deposits (host classpath);" + + " give one of the settings another key in its @Feature", deposits.getMessage()); + + IllegalArgumentException field = assertThrows(IllegalArgumentException.class, + () -> BuiltInPack.serve(mock(IrisData.class), folder, List.of(new RivalModule(TakesAHostField.class)))); + assertEquals("biome key \"generators\" is claimed by Iris and test:rival/generators (host classpath);" + + " give one of the settings another key in its @Feature", field.getMessage()); + } + + @Feature(id = "test:rival/deposits", name = "Rival deposits", key = "deposits", targets = Target.REGION) + public static final class TakesDeposits implements IrisFeature { + } + + @Feature(id = "test:rival/generators", name = "Rival generators", key = "generators", targets = Target.BIOME) + public static final class TakesAHostField implements IrisFeature { + } + + private static final class RivalModule implements IrisModule { + private final Class settings; + + RivalModule(Class settings) { + this.settings = settings; + } + + public ModuleInfo info() { + return ModuleInfo.of("test:rival", "Rival", "1"); + } + + public void install(StageGraph graph) { + } + + public void register(FeatureRegistry registry) { + registry.registerSettings(settings); + } + } + @Test public void depositGeneratorsKeepTheMinimumListLengthsTheOldClassHad() throws IOException { try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) { @@ -125,7 +197,7 @@ public class BuiltInGenerationGraphTest { } @Test - public void decoratorsAreBiomeSettingsWrittenUnderTheirIdWithDecorators() throws IOException { + public void decoratorsAreTheBiomesListOfDecoratorsWrittenUnderDecorators() throws IOException { try (LoadedPack pack = BuiltInPack.serve(mock(IrisData.class), folder, List.of())) { for (Target level : List.of(Target.DIMENSION, Target.REGION)) { assertTrue(level + " has no decorators", pack.schema().fields(level).stream() @@ -134,8 +206,9 @@ public class BuiltInGenerationGraphTest { FeatureSchema decorant = pack.schema().fields(Target.BIOME).stream() .filter(feature -> feature.settings().name().equals(DecorantSettings.class.getName())) .findFirst().orElseThrow(); - assertEquals("iris:decorant", decorant.key()); - SchemaOption option = decorant.settings().options().getFirst(); + assertEquals("decorators", decorant.key()); + assertEquals(Optional.of("decorators"), decorant.root()); + SchemaOption option = decorant.rootOption().orElseThrow(); assertEquals("decorators", option.name()); assertEquals("decorators are a module class of IrisApi types, not an Iris class", new ValueKind.ListKind(new ValueKind.ObjectKind(Decorator.class.getName()), false), option.kind()); diff --git a/core/src/test/java/art/arcane/iris/core/modules/BuiltInPack.java b/core/src/test/java/art/arcane/iris/core/modules/BuiltInPack.java index 3c52a833b..4245a67bf 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/BuiltInPack.java +++ b/core/src/test/java/art/arcane/iris/core/modules/BuiltInPack.java @@ -61,6 +61,7 @@ public final class BuiltInPack { List modules = Stream.concat(IrisModuleHost.builtInModules().stream(), packModules.stream()).toList(); LoadedPack pack = LoadedPack.load(packFolder, ModuleHost.of(modules) .exposing(IrisModuleHost.BUILT_IN_API_PACKAGE) + .reservingFields(ModuleTargets.reservedFields()) .describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE) .copyingJarsTo(folder.newFolder().toPath())); PackModuleSet moduleSet = mock(PackModuleSet.class); diff --git a/core/src/test/java/art/arcane/iris/core/modules/ChunkSettingsScanTimingTest.java b/core/src/test/java/art/arcane/iris/core/modules/ChunkSettingsScanTimingTest.java index 578d79484..4d2072961 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/ChunkSettingsScanTimingTest.java +++ b/core/src/test/java/art/arcane/iris/core/modules/ChunkSettingsScanTimingTest.java @@ -70,7 +70,7 @@ public class ChunkSettingsScanTimingTest { @Rule public TemporaryFolder folder = new TemporaryFolder(); - @Feature(id = "test:scan", name = "Scan", targets = {Target.DIMENSION, Target.REGION, Target.BIOME}) + @Feature(id = "test:scan", name = "Scan", key = "scan", targets = {Target.DIMENSION, Target.REGION, Target.BIOME}) static final class ScanSettings implements IrisFeature { } diff --git a/core/src/test/java/art/arcane/iris/core/modules/DecorantSettingsDecodingTest.java b/core/src/test/java/art/arcane/iris/core/modules/DecorantSettingsDecodingTest.java index edec949e0..f84b1f653 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/DecorantSettingsDecodingTest.java +++ b/core/src/test/java/art/arcane/iris/core/modules/DecorantSettingsDecodingTest.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; +import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -27,12 +28,12 @@ import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; /** - * The decorators packs have always written, now under {@code "iris:decorant": {"decorators": [...]}} as the migration - * script leaves them, read into {@link Decorator}, a settings class of IrisApi types only. + * The decorators packs have always written, the {@code "decorators": [...]} list, read into {@link Decorator}, a settings + * class of IrisApi types only. */ public class DecorantSettingsDecodingTest { private static final String BIOME_DECORATORS = """ - {"name": "Meadow", "iris:decorant": {"decorators": [ + {"name": "Meadow", "decorators": [ {"chance": 0.003, "variance": {"style": "STATIC"}, "zoom": 1, "palette": [{"block": "minecraft:white_tulip"}, {"block": "minecraft:cornflower", "weight": 3}], "style": {"style": "SIMPLEX", "zoom": 4}}, @@ -43,7 +44,7 @@ public class DecorantSettingsDecodingTest { "snippet/decorator/bush", "snippet/bush", {} - ]}} + ]} """; @Rule @@ -132,20 +133,21 @@ public class DecorantSettingsDecodingTest { } @Test - public void theOldBareListUnderTheOldKeyIsNotSettings() { - JSONObject old = new JSONObject("{\"decorators\": [{\"chance\": 1}]}"); + public void theFeatureIdIsNotAKey() { + JSONObject byId = new JSONObject("{\"iris:decorant\": [{\"chance\": 1}]}"); - assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, old, "biome meadow")); - assertFalse(decoder.keys(Target.BIOME).contains("decorators")); + assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, byId, "biome meadow")); + assertEquals(Set.of("decorators", "deposits"), decoder.keys(Target.BIOME)); } @Test - public void aBareListUnderTheFeatureIdIsRefused() { - JSONObject bare = new JSONObject("{\"iris:decorant\": [{\"chance\": 1}]}"); + public void anObjectOfOptionsUnderDecoratorsIsRefused() { + JSONObject object = new JSONObject("{\"decorators\": {\"decorators\": [{\"chance\": 1}]}}"); - IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.BIOME, bare, "biome meadow")); + IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.BIOME, object, "biome meadow")); - assertTrue(refused.getMessage(), refused.getMessage().contains("write the settings as an object")); + assertEquals("Cannot read settings iris:decorant under \"decorators\" in biome meadow: write a list, [...], of the decorators," + + " not an object of options", refused.getMessage()); } private List decorators(String biomeJson) { diff --git a/core/src/test/java/art/arcane/iris/core/modules/DepositSettingsDecodingTest.java b/core/src/test/java/art/arcane/iris/core/modules/DepositSettingsDecodingTest.java index 56320d2ec..fb91ac9f9 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/DepositSettingsDecodingTest.java +++ b/core/src/test/java/art/arcane/iris/core/modules/DepositSettingsDecodingTest.java @@ -24,6 +24,7 @@ import java.nio.file.Path; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -32,12 +33,12 @@ import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; /** - * The deposit generators packs have always written, now under {@code "iris:deposit": {"generators": [...]}}, read into {@link DepositGenerator}, a settings class of IrisApi types only, - * with the values Iris's own deposit generator class read from the same JSON. + * The deposit generators packs have always written, the {@code "deposits": [...]} list, read into {@link DepositGenerator}, + * a settings class of IrisApi types only, with the values Iris's own deposit generator class read from the same JSON. */ public class DepositSettingsDecodingTest { private static final String REGION_DEPOSITS = """ - {"iris:deposit": {"generators": [ + {"deposits": [ {"minHeight": 15, "maxPerChunk": 26, "maxHeight": 410, "minPerChunk": 4, "minSize": 3, "maxSize": 8, "palette": [{"block": "minecraft:iron_ore"}, {"block": "minecraft:coal_ore"}], "varience": 4}, {"heightDistribution": "TRIANGLE", "placementScope": "FULL_HEIGHT", "surfaceClearance": 0, "shape": "VANILLA_ELLIPSOID", @@ -47,7 +48,7 @@ public class DepositSettingsDecodingTest { "snippet/deposit/diamonds", "snippet/diamonds", {} - ]}} + ]} """; @Rule @@ -142,20 +143,39 @@ public class DepositSettingsDecodingTest { } @Test - public void theOldBareListUnderTheOldKeyIsNotSettings() { - JSONObject old = new JSONObject("{\"deposits\": [{\"maxHeight\": 16}]}"); + public void theFeatureIdIsNotAKey() { + JSONObject byId = new JSONObject("{\"iris:deposit\": [{\"maxHeight\": 16}]}"); - assertSame(ModuleSettings.NONE, decoder.decode(Target.REGION, old, "region forests")); - assertFalse(decoder.keys(Target.REGION).contains("deposits")); + assertSame(ModuleSettings.NONE, decoder.decode(Target.REGION, byId, "region forests")); + assertEquals(Set.of("deposits"), decoder.keys(Target.REGION)); } @Test - public void aBareListUnderTheFeatureIdIsRefused() { - JSONObject bare = new JSONObject("{\"iris:deposit\": [{\"maxHeight\": 16}]}"); + public void anObjectOfOptionsUnderDepositsIsRefused() { + JSONObject object = new JSONObject("{\"deposits\": {\"generators\": [{\"maxHeight\": 16}]}}"); - IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.REGION, bare, "region forests")); + IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.REGION, object, "region forests")); - assertTrue(refused.getMessage(), refused.getMessage().contains("write the settings as an object")); + assertEquals("Cannot read settings iris:deposit under \"deposits\" in region forests: write a list, [...], of the generators," + + " not an object of options", refused.getMessage()); + } + + @Test + public void nullUnderDepositsIsRefused() { + JSONObject nothing = new JSONObject("{\"deposits\": null}"); + + IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.REGION, nothing, "region forests")); + + assertTrue(refused.getMessage(), refused.getMessage().contains("under \"deposits\" in region forests: the value is null; write a list")); + } + + @Test + public void aWronglyShapedGeneratorNamesTheKeyAndTheFile() { + JSONObject broken = new JSONObject("{\"deposits\": [{\"maxHeight\": \"tall\"}]}"); + + IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, () -> decoder.decode(Target.REGION, broken, "region forests")); + + assertTrue(refused.getMessage(), refused.getMessage().startsWith("Cannot read settings iris:deposit under \"deposits\" in region forests: ")); } private List deposits(String regionJson) { diff --git a/core/src/test/java/art/arcane/iris/core/modules/ModuleChunkGenerationTest.java b/core/src/test/java/art/arcane/iris/core/modules/ModuleChunkGenerationTest.java index 94870095f..f1ff3532e 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/ModuleChunkGenerationTest.java +++ b/core/src/test/java/art/arcane/iris/core/modules/ModuleChunkGenerationTest.java @@ -65,7 +65,7 @@ public class ModuleChunkGenerationTest { private Engine engine; private Hunk blocks; - @Feature(id = "iris:pillar", name = "Pillar", targets = {Target.BIOME, Target.REGION, Target.DIMENSION}) + @Feature(id = "iris:pillar", name = "Pillar", key = "pillar", targets = {Target.BIOME, Target.REGION, Target.DIMENSION}) public static final class PillarSettings implements IrisFeature { private BlockState block = BlockState.parse("minecraft:stone"); private int x; diff --git a/core/src/test/java/art/arcane/iris/core/modules/ModuleSettingsDecoderTest.java b/core/src/test/java/art/arcane/iris/core/modules/ModuleSettingsDecoderTest.java index 0039975e4..a014cabff 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/ModuleSettingsDecoderTest.java +++ b/core/src/test/java/art/arcane/iris/core/modules/ModuleSettingsDecoderTest.java @@ -70,7 +70,7 @@ public class ModuleSettingsDecoderTest { private LoadedPack pack; private ModuleSettingsDecoder decoder; - @Feature(id = "iris:moss", name = "Moss", targets = {Target.BIOME, Target.REGION}) + @Feature(id = "iris:moss", name = "Moss", key = "moss", targets = {Target.BIOME, Target.REGION}) public static final class MossSettings implements IrisFeature { private int radius = 3; private BlockState block = new BlockState("minecraft:moss_block"); @@ -83,17 +83,17 @@ public class ModuleSettingsDecoderTest { private int size = 1; } - @Feature(id = "iris:moss/cover", name = "Cover", targets = Target.BIOME) + @Feature(id = "iris:moss/cover", name = "Cover", key = "mossCover", targets = Target.BIOME) public static final class CoverSettings implements IrisFeature { private double amount = 1; } - @Feature(id = "iris:moss/marks", name = "Marks", targets = Target.BIOME) + @Feature(id = "iris:moss/marks", name = "Marks", key = "mossMarks", targets = Target.BIOME) public static final class MarksSettings implements IrisFeature { private List marks = List.of(); } - @Feature(id = "iris:moss/values", name = "Values", targets = Target.BIOME) + @Feature(id = "iris:moss/values", name = "Values", key = "mossValues", targets = Target.BIOME) public static final class ValuesSettings implements IrisFeature { private List palette = List.of(); private NoiseStyle style = NoiseStyle.of("SIMPLEX"); @@ -141,13 +141,13 @@ public class ModuleSettingsDecoderTest { } @Test - public void readsSettingsUnderTheirIdKeepingOmittedDefaults() { - MossSettings byId = moss("{\"iris:moss\": {\"radius\": 7, \"block\": \"minecraft:oak_log[axis=y]\"}}"); - MossSettings partial = moss("{\"iris:moss\": {\"palette\": \"iris:moss/wet\"}}"); + public void readsSettingsUnderTheirKeyKeepingOmittedDefaults() { + MossSettings byKey = moss("{\"moss\": {\"radius\": 7, \"block\": \"minecraft:oak_log[axis=y]\"}}"); + MossSettings partial = moss("{\"moss\": {\"palette\": \"iris:moss/wet\"}}"); - assertEquals(7, byId.radius); - assertEquals(BlockState.parse("minecraft:oak_log[axis=y]"), byId.block); - assertEquals(ResourceId.parse("iris:moss/default"), byId.palette); + assertEquals(7, byKey.radius); + assertEquals(BlockState.parse("minecraft:oak_log[axis=y]"), byKey.block); + assertEquals(ResourceId.parse("iris:moss/default"), byKey.palette); assertEquals(3, partial.radius); assertEquals(ResourceId.parse("iris:moss/wet"), partial.palette); assertEquals(1, partial.patch.size); @@ -156,12 +156,12 @@ public class ModuleSettingsDecoderTest { @Test public void declaresNothingWhereNoKeyIsPresent() { assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, new JSONObject("{\"name\": \"Dunes\"}"), "biome desert/dunes")); - assertSame(ModuleSettings.NONE, decoder.decode(Target.DIMENSION, new JSONObject("{\"iris:moss\": {}}"), "dimension overworld")); + assertSame(ModuleSettings.NONE, decoder.decode(Target.DIMENSION, new JSONObject("{\"moss\": {}}"), "dimension overworld")); } @Test - public void aShortKeyIsNotAKeyOfTheSettings() { - assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, new JSONObject("{\"moss\": {\"radius\": 7}}"), "biome desert/dunes")); + public void theFeatureIdIsNotAKeyOfTheSettings() { + assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, new JSONObject("{\"iris:moss\": {\"radius\": 7}}"), "biome desert/dunes")); } @Test @@ -169,10 +169,10 @@ public class ModuleSettingsDecoderTest { Path snippets = Files.createDirectories(packFolder.resolve("snippet/moss-patch")); Files.writeString(snippets.resolve("wide.json"), "{\"size\": 9}"); - assertEquals(9, moss("{\"iris:moss\": {\"patch\": \"snippet/wide\"}}").patch.size); + assertEquals(9, moss("{\"moss\": {\"patch\": \"snippet/wide\"}}").patch.size); IllegalArgumentException missing = assertThrows(IllegalArgumentException.class, - () -> moss("{\"iris:moss\": {\"patch\": \"snippet/narrow\"}}")); + () -> moss("{\"moss\": {\"patch\": \"snippet/narrow\"}}")); assertTrue(missing.getMessage(), missing.getMessage().contains("Snippet snippet/narrow has no file snippet/moss-patch/narrow.json")); } @@ -181,7 +181,7 @@ public class ModuleSettingsDecoderTest { Path snippets = Files.createDirectories(packFolder.resolve("snippet/moss-patch")); Files.writeString(snippets.resolve("wide.json"), "{\"size\": 9}"); - assertEquals(9, moss("{\"iris:moss\": {\"patch\": \"snippet/moss-patch/wide\"}}").patch.size); + assertEquals(9, moss("{\"moss\": {\"patch\": \"snippet/moss-patch/wide\"}}").patch.size); } @Test @@ -189,7 +189,7 @@ public class ModuleSettingsDecoderTest { Path styles = Files.createDirectories(packFolder.resolve("snippet/style")); Files.writeString(styles.resolve("deepslate.json"), "{\"style\": \"STATIC\"}"); ValuesSettings values = decoder.decode(Target.BIOME, new JSONObject(""" - {"iris:moss/values": { + {"mossValues": { "palette": [{"block": "minecraft:oak_log", "data": {"axis": "y", "waterlogged": true, "level": 3}, "weight": 2, "backup": {"block": "stone"}, "tileData": {"Delay": 20, "SpawnData": {"entity": {"id": "zombie"}}}}, {"block": "iron_ore"}], @@ -223,26 +223,26 @@ public class ModuleSettingsDecoderTest { @Test public void badValuesNameTheSettingsKeyAndResource() { IllegalArgumentException failure = assertThrows(IllegalArgumentException.class, - () -> moss("{\"iris:moss\": {\"block\": \"stone\"}}")); + () -> moss("{\"moss\": {\"block\": \"stone\"}}")); - assertTrue(failure.getMessage(), failure.getMessage().startsWith("Cannot read settings iris:moss under \"iris:moss\" in biome desert/dunes: ")); + assertTrue(failure.getMessage(), failure.getMessage().startsWith("Cannot read settings iris:moss under \"moss\" in biome desert/dunes: ")); } @Test public void listsTheKeysModulesReadPerTarget() { - assertEquals(Set.of("iris:moss", "iris:moss/cover", "iris:moss/marks", "iris:moss/values"), decoder.keys(Target.BIOME)); + assertEquals(Set.of("moss", "mossCover", "mossMarks", "mossValues"), decoder.keys(Target.BIOME)); assertEquals(Set.of(), decoder.keys(Target.DIMENSION)); } @Test public void settingsAreAlwaysAnObjectEvenWithOneOption() { - assertEquals(0.25, decoder.decode(Target.BIOME, new JSONObject("{\"iris:moss/cover\": {\"amount\": 0.25}}"), "biome desert/dunes") + assertEquals(0.25, decoder.decode(Target.BIOME, new JSONObject("{\"mossCover\": {\"amount\": 0.25}}"), "biome desert/dunes") .find(CoverSettings.class).orElseThrow().amount, 0); for (String bare : List.of("0.5", "[1, 2]", "true")) { IllegalArgumentException refused = assertThrows(IllegalArgumentException.class, - () -> decoder.decode(Target.BIOME, new JSONObject("{\"iris:moss/cover\": " + bare + "}"), "biome desert/dunes")); - assertEquals("Cannot read settings iris:moss/cover under \"iris:moss/cover\" in biome desert/dunes: write the settings as an object," + () -> decoder.decode(Target.BIOME, new JSONObject("{\"mossCover\": " + bare + "}"), "biome desert/dunes")); + assertEquals("Cannot read settings iris:moss/cover under \"mossCover\" in biome desert/dunes: write the settings as an object," + " {\"