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 f84b1f653..647016d36 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
@@ -137,7 +137,8 @@ public class DecorantSettingsDecodingTest {
JSONObject byId = new JSONObject("{\"iris:decorant\": [{\"chance\": 1}]}");
assertSame(ModuleSettings.NONE, decoder.decode(Target.BIOME, byId, "biome meadow"));
- assertEquals(Set.of("decorators", "deposits"), decoder.keys(Target.BIOME));
+ assertTrue(decoder.keys(Target.BIOME).containsAll(Set.of("decorators", "deposits")));
+ assertFalse(decoder.keys(Target.BIOME).contains("iris:decorant"));
}
@Test
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 fb91ac9f9..62b56e3b1 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
@@ -147,7 +147,8 @@ public class DepositSettingsDecodingTest {
JSONObject byId = new JSONObject("{\"iris:deposit\": [{\"maxHeight\": 16}]}");
assertSame(ModuleSettings.NONE, decoder.decode(Target.REGION, byId, "region forests"));
- assertEquals(Set.of("deposits"), decoder.keys(Target.REGION));
+ assertTrue(decoder.keys(Target.REGION).contains("deposits"));
+ assertFalse(decoder.keys(Target.REGION).contains("iris:deposit"));
}
@Test
diff --git a/core/src/test/java/art/arcane/iris/core/modules/OreSettingsDecodingTest.java b/core/src/test/java/art/arcane/iris/core/modules/OreSettingsDecodingTest.java
new file mode 100644
index 000000000..7a162afa2
--- /dev/null
+++ b/core/src/test/java/art/arcane/iris/core/modules/OreSettingsDecodingTest.java
@@ -0,0 +1,183 @@
+/*
+ * 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.builtin.deposit.DepositVariant;
+import art.arcane.iris.builtin.deposit.DepositVariantSettings;
+import art.arcane.iris.builtin.deposit.OreFrequencySettings;
+import art.arcane.iris.builtin.deposit.OreSizeSettings;
+import art.arcane.iris.builtin.terrain.HideOresSettings;
+import art.arcane.iris.builtin.terrain.OreGenerator;
+import art.arcane.iris.builtin.terrain.OreSettings;
+import art.arcane.volmlib.util.json.JSONObject;
+import com.google.gson.Gson;
+import com.volmit.FeatureAttachment.Target;
+import com.volmit.block.BlockSpec;
+import com.volmit.host.LoadedPack;
+import com.volmit.host.ModuleHost;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * The ore settings packs have always written, read by the terrain and deposit modules under their old keys: {@code ores} (a
+ * list at a dimension, region or biome), {@code hideOresForHiddenOre} (a boolean at a dimension), {@code depositVariants} (a list)
+ * and the two ore deposit multipliers (numbers at a biome). The dimension is the overworld file as it was before the port.
+ */
+public class OreSettingsDecodingTest {
+ private static final String PACK = "/art/arcane/iris/core/modules/pack-before-the-port";
+
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder();
+
+ private Path packFolder;
+ private LoadedPack pack;
+ private ModuleSettingsDecoder decoder;
+
+ @Before
+ public void loadBuiltIns() throws IOException, URISyntaxException {
+ packFolder = Path.of(OreSettingsDecodingTest.class.getResource(PACK).toURI());
+ pack = LoadedPack.load(packFolder, ModuleHost.of(IrisModuleHost.builtInModules())
+ .reservingFields(ModuleTargets.reservedFields())
+ .describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
+ decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
+ }
+
+ @After
+ public void closePack() {
+ pack.close();
+ }
+
+ @Test
+ public void theOverworldReadsItsOresInTheOrderTheFileListsThem() throws IOException {
+ JSONObject dimension = new JSONObject(Files.readString(packFolder.resolve("dimensions/overworld.json")));
+
+ List ores = decoder.decode(Target.DIMENSION, dimension, "dimension overworld")
+ .find(OreSettings.class).orElseThrow().generators();
+
+ assertEquals(dimension.getJSONArray("ores").length(), ores.size());
+ assertEquals(11, ores.size());
+ OreGenerator firstBedrock = ores.getFirst();
+ assertEquals(1, firstBedrock.threshold(), 0);
+ assertEquals(0, firstBedrock.range().min(), 0);
+ assertEquals(0, firstBedrock.range().max(), 0);
+ assertEquals(List.of(BlockSpec.of("minecraft:bedrock")), firstBedrock.palette().palette());
+ assertEquals("FLAT", firstBedrock.chanceStyle().style());
+ assertFalse(firstBedrock.generateSurface());
+ OreGenerator secondBedrock = ores.get(1);
+ assertEquals(0.625, secondBedrock.threshold(), 0);
+ assertEquals("a snippet reference reads the snippet's style", "STATIC", secondBedrock.chanceStyle().style());
+ OreGenerator lastDeepslate = ores.getLast();
+ assertEquals(0.125, lastDeepslate.threshold(), 0);
+ assertEquals(64, lastDeepslate.range().min(), 0);
+ assertEquals(List.of(BlockSpec.of("minecraft:deepslate")), lastDeepslate.palette().palette());
+ }
+
+ @Test
+ public void oresOfARegionAndABiomeReadSurfaceFlagsStylesAndPalettes() {
+ JSONObject ores = new JSONObject("""
+ {"ores": [
+ {"generateSurface": true, "threshold": 0.3, "range": {"min": 50, "max": 90},
+ "chanceStyle": {"style": "SIMPLEX", "zoom": 4},
+ "palette": {"zoom": 2, "palette": [{"block": "minecraft:gold_ore"}, {"block": "minecraft:gold_block", "weight": 3}]}},
+ {}
+ ]}
+ """);
+
+ for (Target target : List.of(Target.REGION, Target.BIOME)) {
+ List read = decoder.decode(target, ores, "test").find(OreSettings.class).orElseThrow().generators();
+
+ assertEquals(2, read.size());
+ assertTrue(read.getFirst().generateSurface());
+ assertEquals(0.3, read.getFirst().threshold(), 0);
+ assertEquals("SIMPLEX", read.getFirst().chanceStyle().style());
+ assertEquals(4, read.getFirst().chanceStyle().zoom(), 0);
+ assertEquals(2, read.getFirst().palette().zoom(), 0);
+ assertEquals(List.of(BlockSpec.of("minecraft:gold_ore"), BlockSpec.of("minecraft:gold_block").withWeight(3)), read.getFirst().palette().palette());
+ assertEquals("an empty generator keeps Iris's defaults", 0.5, read.get(1).threshold(), 0);
+ assertEquals(List.of(), read.get(1).palette().palette());
+ }
+ }
+
+ @Test
+ public void hideOresForHiddenOreIsABooleanOnTheDimension() {
+ ModuleSettings hidden = decoder.decode(Target.DIMENSION, new JSONObject("{\"hideOresForHiddenOre\": true}"), "dimension test");
+ ModuleSettings shown = decoder.decode(Target.DIMENSION, new JSONObject("{\"hideOresForHiddenOre\": false}"), "dimension test");
+
+ assertTrue(hidden.find(HideOresSettings.class).orElseThrow().hide());
+ assertFalse(shown.find(HideOresSettings.class).orElseThrow().hide());
+ assertTrue("a dimension that does not write it declares nothing", decoder.decode(Target.DIMENSION, new JSONObject("{}"), "dimension test").isEmpty());
+ }
+
+ @Test
+ public void depositVariantsAreAListAtEveryLevel() {
+ JSONObject json = new JSONObject("""
+ {"depositVariants": [
+ {"minHeight": -64, "maxHeight": 0, "remap": {"minecraft:iron_ore": "minecraft:deepslate_iron_ore", "minecraft:coal_ore": "minecraft:deepslate_coal_ore"}},
+ {"maxHeight": 10}
+ ]}
+ """);
+
+ for (Target target : List.of(Target.DIMENSION, Target.REGION, Target.BIOME)) {
+ List variants = decoder.decode(target, json, "test").find(DepositVariantSettings.class).orElseThrow().variants();
+
+ assertEquals(2, variants.size());
+ assertEquals(-64, variants.getFirst().minHeight());
+ assertEquals(0, variants.getFirst().maxHeight());
+ assertEquals(Map.of("minecraft:iron_ore", "minecraft:deepslate_iron_ore", "minecraft:coal_ore", "minecraft:deepslate_coal_ore"),
+ variants.getFirst().remap());
+ assertEquals(0, variants.get(1).minHeight());
+ assertEquals(10, variants.get(1).maxHeight());
+ assertEquals(Map.of(), variants.get(1).remap());
+ }
+ }
+
+ @Test
+ public void theTwoOreDepositMultipliersAreNumbersOnTheBiome() {
+ ModuleSettings tuned = decoder.decode(Target.BIOME, new JSONObject("{\"oreDepositFrequencyMultiplier\": 0.4, \"oreDepositSizeMultiplier\": 2}"), "biome test");
+ ModuleSettings plain = decoder.decode(Target.BIOME, new JSONObject("{}"), "biome test");
+
+ assertEquals(0.4, tuned.find(OreFrequencySettings.class).orElseThrow().multiplier(), 0);
+ assertEquals(2, tuned.find(OreSizeSettings.class).orElseThrow().multiplier(), 0);
+ assertTrue(plain.find(OreFrequencySettings.class).isEmpty());
+ assertTrue(plain.find(OreSizeSettings.class).isEmpty());
+ }
+
+ @Test
+ public void everyKeyIsOnlyReadAtTheLevelsTheOldFieldExistedAt() {
+ assertTrue(decoder.keys(Target.DIMENSION).containsAll(List.of("ores", "hideOresForHiddenOre", "depositVariants")));
+ assertTrue(decoder.keys(Target.REGION).containsAll(List.of("ores", "depositVariants")));
+ assertFalse(decoder.keys(Target.REGION).contains("hideOresForHiddenOre"));
+ assertTrue(decoder.keys(Target.BIOME).containsAll(List.of("ores", "depositVariants", "oreDepositFrequencyMultiplier", "oreDepositSizeMultiplier")));
+ assertFalse(decoder.keys(Target.DIMENSION).contains("oreDepositFrequencyMultiplier"));
+ }
+}
diff --git a/core/src/test/java/art/arcane/iris/engine/actuator/OreWarmUpTest.java b/core/src/test/java/art/arcane/iris/engine/actuator/OreWarmUpTest.java
index 76a76f332..f52cda083 100644
--- a/core/src/test/java/art/arcane/iris/engine/actuator/OreWarmUpTest.java
+++ b/core/src/test/java/art/arcane/iris/engine/actuator/OreWarmUpTest.java
@@ -1,26 +1,23 @@
package art.arcane.iris.engine.actuator;
-import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.SeedManager;
-import art.arcane.iris.engine.object.terrain.deposit.IrisOreGenerator;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.volmlib.util.collection.KList;
-import art.arcane.volmlib.util.math.RNG;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-/** Ore generators keep the noise of the first random they are warmed with, so the order and the randoms of the warm-up are pinned. */
+/** Ore generators keep the noise of the first seed they are warmed with, so the order and the seeds of the warm-up are pinned. */
public class OreWarmUpTest {
private static final long COMPONENT_SEED = 100L;
private static final long ROOT_SEED = COMPONENT_SEED + 7777L;
@@ -28,54 +25,52 @@ public class OreWarmUpTest {
private final List warmed = new ArrayList<>();
@Test
- public void biomesByKeyThenRegionsByKeyThenTheDimensionWarmWithConsecutiveRandomsOfTheWorld() {
+ public void biomesByKeyThenRegionsByKeyThenTheDimensionWarmWithConsecutiveSeedsOfTheWorld() {
SeedManager seeds = mock(SeedManager.class);
when(seeds.getComponent()).thenReturn(COMPONENT_SEED);
IrisDimension dimension = mock(IrisDimension.class);
Engine engine = mock(Engine.class);
when(engine.getSeedManager()).thenReturn(seeds);
- when(engine.getData()).thenReturn(mock(IrisData.class));
when(engine.getDimension()).thenReturn(dimension);
- IrisBiome biomeB = biome("b", ore("b0"), null, ore("b1"));
- IrisBiome biomeA = biome("a", ore("a0"));
- IrisRegion regionY = region("y", ore("y0"));
- IrisRegion regionX = region("x", ore("x0"), ore("x1"));
- KList dimensionOres = list(ore("d0"));
+ TerrainOres ores = mock(TerrainOres.class);
+ IrisBiome biomeB = biome("b", ores, "b0", "b1");
+ IrisBiome biomeA = biome("a", ores, "a0");
+ IrisRegion regionY = region("y", ores, "y0");
+ IrisRegion regionX = region("x", ores, "x0", "x1");
+ ResolvedOres dimensionOres = resolved("d0");
+ when(ores.of(dimension)).thenReturn(dimensionOres);
when(engine.getAllBiomes()).thenReturn(new KList<>(List.of(biomeB, biomeA)));
when(dimension.getAllRegions(engine)).thenReturn(new KList<>(List.of(regionY, regionX)));
- when(dimension.getOres()).thenReturn(dimensionOres);
- new OreWarmUp(engine).warm();
+ new OreWarmUp(engine, ores).warm();
assertEquals(List.of("a0@" + ROOT_SEED, "b0@" + (ROOT_SEED + 1), "b1@" + (ROOT_SEED + 2),
"x0@" + (ROOT_SEED + 3), "x1@" + (ROOT_SEED + 4), "y0@" + (ROOT_SEED + 5), "d0@" + (ROOT_SEED + 6)), warmed);
}
- private IrisOreGenerator ore(String name) {
- IrisOreGenerator ore = mock(IrisOreGenerator.class);
- doAnswer(call -> warmed.add(name + "@" + call.getArgument(0).getSeed())).when(ore).warm(any(RNG.class), any());
- return ore;
+ private ResolvedOres resolved(String... names) {
+ List ores = new ArrayList<>();
+ for (String name : names) {
+ ResolvedOre ore = mock(ResolvedOre.class);
+ doAnswer(call -> warmed.add(name + "@" + call.getArgument(0))).when(ore).warm(anyLong());
+ ores.add(ore);
+ }
+ return new ResolvedOres(ores);
}
- private static IrisBiome biome(String key, IrisOreGenerator... ores) {
+ private IrisBiome biome(String key, TerrainOres ores, String... oreNames) {
IrisBiome biome = mock(IrisBiome.class);
when(biome.getLoadKey()).thenReturn(key);
- when(biome.getOres()).thenReturn(list(ores));
+ ResolvedOres declared = resolved(oreNames);
+ when(ores.of(biome)).thenReturn(declared);
return biome;
}
- private static IrisRegion region(String key, IrisOreGenerator... ores) {
+ private IrisRegion region(String key, TerrainOres ores, String... oreNames) {
IrisRegion region = mock(IrisRegion.class);
when(region.getLoadKey()).thenReturn(key);
- when(region.getOres()).thenReturn(list(ores));
+ ResolvedOres declared = resolved(oreNames);
+ when(ores.of(region)).thenReturn(declared);
return region;
}
-
- private static KList list(IrisOreGenerator... ores) {
- KList list = new KList<>();
- for (IrisOreGenerator ore : ores) {
- list.add(ore);
- }
- return list;
- }
}
diff --git a/core/src/test/java/art/arcane/iris/engine/actuator/ResolvedOreTest.java b/core/src/test/java/art/arcane/iris/engine/actuator/ResolvedOreTest.java
new file mode 100644
index 000000000..c6ebf2226
--- /dev/null
+++ b/core/src/test/java/art/arcane/iris/engine/actuator/ResolvedOreTest.java
@@ -0,0 +1,166 @@
+package art.arcane.iris.engine.actuator;
+
+import art.arcane.iris.builtin.terrain.OreGenerator;
+import art.arcane.iris.core.loader.IrisData;
+import art.arcane.iris.core.loader.ResourceLoader;
+import art.arcane.iris.core.modules.IrisPackResources;
+import art.arcane.iris.engine.UsableBlockPlatform;
+import art.arcane.iris.engine.framework.Engine;
+import art.arcane.iris.engine.framework.SeedManager;
+import art.arcane.iris.engine.object.material.IrisBlockData;
+import art.arcane.iris.spi.PlatformBlockState;
+import com.google.gson.Gson;
+import com.volmit.noise.NoiseSampler;
+import org.junit.After;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ResolvedOreTest {
+ private static final long TERRAIN_SEED = 1337L;
+ private static final long WARM_SEED = 99L;
+ /** Taken from {@code IrisOreGenerator} (now deleted) generating the same ores with the same seeds, before ores moved into the terrain module. */
+ private static final int TRANSCRIPT_LENGTH = 128237;
+ private static final int TRANSCRIPT_HASH = -1665706847;
+ private static final String[] ORES = {
+ "{\"palette\":{\"palette\":[{\"block\":\"coal_ore\"}]},\"chanceStyle\":{\"style\":\"STATIC\"},\"threshold\":0.2,\"range\":{\"min\":0,\"max\":64}}",
+ "{\"palette\":{\"palette\":[{\"block\":\"iron_ore\"},{\"block\":\"deepslate_iron_ore\"}]},\"chanceStyle\":{\"style\":\"SIMPLEX\",\"zoom\":4},"
+ + "\"threshold\":0.5,\"range\":{\"min\":-16,\"max\":40}}",
+ "{\"palette\":{\"palette\":[{\"block\":\"gold_ore\"},{\"block\":\"gold_block\"},{\"block\":\"raw_gold_block\"}]},\"chanceStyle\":{\"style\":\"PERLIN\",\"zoom\":2},"
+ + "\"threshold\":0.35,\"range\":{\"min\":10,\"max\":20}}",
+ "{\"palette\":{\"palette\":[]},\"chanceStyle\":{\"style\":\"STATIC\"},\"threshold\":1,\"range\":{\"min\":0,\"max\":100}}",
+ "{\"palette\":{\"palette\":[{\"block\":\"bedrock\"}]},\"chanceStyle\":{\"style\":\"FLAT\"},\"threshold\":1,\"range\":{\"min\":0,\"max\":3}}",
+ };
+
+ @After
+ public void unbindPlatform() {
+ UsableBlockPlatform.unbind();
+ }
+
+ @Test
+ public void everyOreGeneratesAsIrisOreGeneratorDid() {
+ UsableBlockPlatform.bind();
+ Engine engine = engine();
+ StringBuilder transcript = new StringBuilder();
+ for (String json : ORES) {
+ ResolvedOre ore = ResolvedOre.of(new Gson().fromJson(json, OreGenerator.class), engine);
+ ore.warm(WARM_SEED);
+ for (int x = -30; x < 30; x += 3) {
+ for (int z = -30; z < 30; z += 4) {
+ for (int y = -20; y < 70; y += 5) {
+ PlatformBlockState state = ore.generate(x, y, z);
+ transcript.append(state == null ? "-" : state.key()).append(';');
+ }
+ }
+ }
+ }
+ assertTrue("the palettes' blocks are placed", transcript.indexOf("minecraft:deepslate_iron_ore") >= 0
+ && transcript.indexOf("minecraft:iron_ore") >= 0 && transcript.indexOf("minecraft:coal_ore") >= 0 && transcript.indexOf("minecraft:bedrock") >= 0);
+ assertTrue("positions without ore occur", transcript.indexOf("-") >= 0);
+ assertEquals(TRANSCRIPT_LENGTH, transcript.length());
+ assertEquals(TRANSCRIPT_HASH, transcript.toString().hashCode());
+ }
+
+ @Test
+ public void theNoiseKeepsTheFirstSeedItIsBuiltFrom() {
+ UsableBlockPlatform.bind();
+ OreGenerator settings = new Gson().fromJson(ORES[1], OreGenerator.class);
+ List seeds = new ArrayList<>();
+ ResolvedOre ore = new ResolvedOre(settings, (style, seed) -> {
+ seeds.add(seed);
+ return constant(0);
+ }, null, TERRAIN_SEED, List.of(UsableBlockPlatform.block("iron_ore")));
+
+ ore.warm(WARM_SEED);
+ ore.warm(WARM_SEED + 1);
+ ore.generate(0, 0, 0);
+
+ assertEquals(List.of(WARM_SEED), seeds);
+ }
+
+ @Test
+ public void anOreNothingWarmedBuildsItsNoiseFromTheTerrainSeed() {
+ UsableBlockPlatform.bind();
+ OreGenerator settings = new Gson().fromJson(ORES[1], OreGenerator.class);
+ List seeds = new ArrayList<>();
+ ResolvedOre ore = new ResolvedOre(settings, (style, seed) -> {
+ seeds.add(seed);
+ return constant(0);
+ }, null, TERRAIN_SEED, List.of(UsableBlockPlatform.block("iron_ore")));
+
+ ore.generate(0, 0, 0);
+ ore.generate(1, 1, 1);
+
+ assertEquals(List.of(TERRAIN_SEED), seeds);
+ }
+
+ @Test
+ public void nothingGeneratesOutsideTheBandOrWithAnEmptyPaletteOrAboveTheThreshold() {
+ UsableBlockPlatform.bind();
+ PlatformBlockState iron = UsableBlockPlatform.block("iron_ore");
+ OreGenerator settings = new Gson().fromJson(ORES[1], OreGenerator.class);
+ ResolvedOre atThreshold = new ResolvedOre(settings, (style, seed) -> constant(0.5), null, TERRAIN_SEED, List.of(iron));
+ ResolvedOre aboveThreshold = new ResolvedOre(settings, (style, seed) -> constant(0.51), null, TERRAIN_SEED, List.of(iron));
+ ResolvedOre noBlocks = new ResolvedOre(settings, (style, seed) -> constant(0), null, TERRAIN_SEED, List.of());
+ OreGenerator emptyPalette = new Gson().fromJson(ORES[3], OreGenerator.class);
+ ResolvedOre empty = new ResolvedOre(emptyPalette, (style, seed) -> constant(0), null, TERRAIN_SEED, List.of());
+
+ assertEquals("noise at the threshold becomes ore", iron, atThreshold.generate(0, 0, 0));
+ assertNull(aboveThreshold.generate(0, 0, 0));
+ assertNull("below the band", atThreshold.generate(0, -17, 0));
+ assertNull("above the band", atThreshold.generate(0, 41, 0));
+ assertEquals("the band's ends are in it", iron, atThreshold.generate(0, 40, 0));
+ assertNull(noBlocks.generate(0, 0, 0));
+ assertNull(empty.generate(0, 50, 0));
+ }
+
+ @Test
+ public void oresDefaultToNoBlocksSurfaceOffAndTheDocumentedBand() {
+ OreGenerator ore = new Gson().fromJson("{}", OreGenerator.class);
+
+ assertEquals(List.of(), ore.palette().palette());
+ assertEquals("STATIC", ore.chanceStyle().style());
+ assertEquals(false, ore.generateSurface());
+ assertEquals(0.5, ore.threshold(), 0);
+ assertEquals(30, ore.range().min(), 0);
+ assertEquals(80, ore.range().max(), 0);
+ }
+
+ private static NoiseSampler constant(double value) {
+ return new NoiseSampler() {
+ @Override
+ public double sample(double worldX, double worldZ) {
+ return value;
+ }
+
+ @Override
+ public double sample(double worldX, double y, double worldZ) {
+ return value;
+ }
+ };
+ }
+
+ private static Engine engine() {
+ IrisData data = mock(IrisData.class);
+ @SuppressWarnings("unchecked")
+ ResourceLoader blocks = mock(ResourceLoader.class);
+ when(data.getBlockLoader()).thenReturn(blocks);
+ when(data.getDataFolder()).thenReturn(new File("pack"));
+ IrisPackResources resources = new IrisPackResources(data);
+ when(data.getPackResources()).thenReturn(resources);
+ SeedManager seeds = mock(SeedManager.class);
+ when(seeds.getTerrain()).thenReturn(TERRAIN_SEED);
+ Engine engine = mock(Engine.class);
+ when(engine.getData()).thenReturn(data);
+ when(engine.getSeedManager()).thenReturn(seeds);
+ return engine;
+ }
+}
diff --git a/core/src/test/java/art/arcane/iris/engine/actuator/TerrainModuleTest.java b/core/src/test/java/art/arcane/iris/engine/actuator/TerrainModuleTest.java
index 0e9d5ba07..d07d5df13 100644
--- a/core/src/test/java/art/arcane/iris/engine/actuator/TerrainModuleTest.java
+++ b/core/src/test/java/art/arcane/iris/engine/actuator/TerrainModuleTest.java
@@ -15,9 +15,13 @@ import art.arcane.iris.util.project.context.ChunkedDataCache;
import art.arcane.iris.util.project.hunk.Hunk;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
+import art.arcane.iris.builtin.terrain.HideOresSettings;
+import art.arcane.iris.core.modules.BuiltInPack;
import org.junit.After;
import org.junit.Test;
+import java.util.List;
+
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
@@ -26,6 +30,7 @@ import static org.junit.Assert.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -48,7 +53,7 @@ public class TerrainModuleTest {
@SuppressWarnings("unchecked")
public void aColumnIsBedrockThenRockThenLayersThenFluid() {
UsableBlockPlatform.bind();
- TerrainModule.TerrainShaper shaper = new TerrainModule.TerrainShaper(engine());
+ TerrainModule.TerrainShaper shaper = new TerrainModule.TerrainShaper(engine(true), mock(TerrainOres.class));
Hunk blocks = Hunk.newArrayHunk(16, 64, 16);
IrisBiome biome = mock(IrisBiome.class);
KList layers = new KList<>();
@@ -69,6 +74,49 @@ public class TerrainModuleTest {
assertNull("nothing above the fluid", blocks.get(3, FLUID_HEIGHT + 1, 4));
}
+ @Test
+ @SuppressWarnings("unchecked")
+ public void oresOfTheBiomeThenTheRegionThenTheDimensionReplaceTheBlocksTheirBandsReach() {
+ UsableBlockPlatform.bind();
+ Engine engine = engine(false);
+ IrisDimension dimension = engine.getDimension();
+ IrisBiome biome = mock(IrisBiome.class);
+ when(biome.generateLayers(any(), anyDouble(), anyDouble(), any(RNG.class), anyInt(), anyInt(), any(), any())).thenReturn(new KList<>());
+ when(biome.generateSeaLayers(anyDouble(), anyDouble(), any(RNG.class), anyInt(), any())).thenReturn(new KList<>());
+ ChunkContext context = context(biome);
+ IrisRegion region = context.getRegion().get(0, 0);
+ PlatformBlockState biomeOre = mock(PlatformBlockState.class);
+ PlatformBlockState regionOre = mock(PlatformBlockState.class);
+ PlatformBlockState dimensionOre = mock(PlatformBlockState.class);
+ TerrainOres ores = mock(TerrainOres.class);
+ ResolvedOres biomeOres = oresAt(2, biomeOre);
+ ResolvedOres regionOres = oresAt(2, regionOre, 3, regionOre);
+ ResolvedOres dimensionOres = oresAt(2, dimensionOre, 3, dimensionOre, 4, dimensionOre);
+ when(ores.of(biome)).thenReturn(biomeOres);
+ when(ores.of(region)).thenReturn(regionOres);
+ when(ores.of(dimension)).thenReturn(dimensionOres);
+ Hunk blocks = Hunk.newArrayHunk(16, 64, 16);
+
+ new TerrainModule.TerrainShaper(engine, ores).shape(0, 0, blocks, context);
+
+ assertSame("the biome's ore comes first", biomeOre, blocks.get(3, 2, 4));
+ assertSame("then the region's", regionOre, blocks.get(3, 3, 4));
+ assertSame("then the dimension's", dimensionOre, blocks.get(3, 4, 4));
+ assertSame("rock where no ore reaches", rock, blocks.get(3, 5, 4));
+ }
+
+ /** Underground ores that give {@code block} at each listed height and nothing elsewhere. */
+ private static ResolvedOres oresAt(Object... heightsAndBlocks) {
+ ResolvedOre ore = mock(ResolvedOre.class);
+ when(ore.generatesSurface()).thenReturn(false);
+ when(ore.minY()).thenReturn(0D);
+ when(ore.maxY()).thenReturn(10D);
+ for (int index = 0; index < heightsAndBlocks.length; index += 2) {
+ when(ore.generate(anyInt(), eq((int) heightsAndBlocks[index]), anyInt())).thenReturn((PlatformBlockState) heightsAndBlocks[index + 1]);
+ }
+ return new ResolvedOres(List.of(ore));
+ }
+
@SuppressWarnings("unchecked")
private ChunkContext context(IrisBiome biome) {
ChunkedDataCache biomes = mock(ChunkedDataCache.class);
@@ -88,11 +136,11 @@ public class TerrainModuleTest {
return context;
}
- private Engine engine() {
+ private Engine engine(boolean hidesOres) {
IrisDimension dimension = mock(IrisDimension.class);
when(dimension.getFluidHeight()).thenReturn(FLUID_HEIGHT);
when(dimension.isBedrock()).thenReturn(true);
- when(dimension.isHideOresForHiddenOre()).thenReturn(true);
+ when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(new HideOresSettings(hidesOres)));
IrisComplex complex = mock(IrisComplex.class);
when(complex.getImageMapRuntime()).thenReturn(mock(IrisImageMapRuntime.class));
SeedManager seeds = mock(SeedManager.class);
diff --git a/core/src/test/java/art/arcane/iris/engine/modifier/ResolvedDepositTest.java b/core/src/test/java/art/arcane/iris/engine/modifier/ResolvedDepositTest.java
index 25f45dc81..e88266f97 100644
--- a/core/src/test/java/art/arcane/iris/engine/modifier/ResolvedDepositTest.java
+++ b/core/src/test/java/art/arcane/iris/engine/modifier/ResolvedDepositTest.java
@@ -1,6 +1,8 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.deposit.DepositGenerator;
+import art.arcane.iris.builtin.deposit.OreFrequencySettings;
+import art.arcane.iris.builtin.deposit.OreSizeSettings;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.core.modules.PackResourceFixture;
@@ -91,10 +93,8 @@ public class ResolvedDepositTest {
@Test
public void biomeOreTuningDefaultsPreserveExistingGeneration() {
- IrisBiome biome = new IrisBiome();
-
- assertEquals(1D, biome.getOreDepositFrequencyMultiplier(), 0D);
- assertEquals(1D, biome.getOreDepositSizeMultiplier(), 0D);
+ assertEquals(1D, new OreFrequencySettings().multiplier(), 0D);
+ assertEquals(1D, new OreSizeSettings().multiplier(), 0D);
}
@Test
diff --git a/core/src/test/java/art/arcane/iris/engine/modifier/ResolvedDepositVariantTest.java b/core/src/test/java/art/arcane/iris/engine/modifier/ResolvedDepositVariantTest.java
new file mode 100644
index 000000000..a4ed1db2c
--- /dev/null
+++ b/core/src/test/java/art/arcane/iris/engine/modifier/ResolvedDepositVariantTest.java
@@ -0,0 +1,75 @@
+package art.arcane.iris.engine.modifier;
+
+import art.arcane.iris.builtin.deposit.DepositVariant;
+import art.arcane.iris.engine.UsableBlockPlatform;
+import art.arcane.iris.spi.IrisPlatforms;
+import art.arcane.iris.spi.PlatformBlockState;
+import com.google.gson.Gson;
+import org.junit.After;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
+public class ResolvedDepositVariantTest {
+ private static final String DEEP_IRON = """
+ {"minHeight": -64, "maxHeight": 0, "remap": {"minecraft:iron_ore": "minecraft:deepslate_iron_ore", "unknown_block": "minecraft:stone"}}
+ """;
+
+ private static void knowEveryBlockButTheUnknownOne() {
+ UsableBlockPlatform.bind();
+ when(IrisPlatforms.get().registries().blockOrNull(anyString(), anyBoolean())).thenAnswer(call -> {
+ String name = call.getArgument(0);
+ return name.equals("unknown_block") ? null : UsableBlockPlatform.block(name);
+ });
+ }
+
+ @After
+ public void unbindPlatform() {
+ UsableBlockPlatform.unbind();
+ }
+
+ @Test
+ public void aVariantAppliesWithinItsInclusiveBand() {
+ ResolvedDepositVariant variant = new ResolvedDepositVariant(new Gson().fromJson(DEEP_IRON, DepositVariant.class));
+
+ assertTrue(variant.appliesAt(-64));
+ assertTrue(variant.appliesAt(0));
+ assertFalse(variant.appliesAt(-65));
+ assertFalse(variant.appliesAt(1));
+ }
+
+ @Test
+ public void anOreIsRemappedByItsMaterialAndOtherBlocksAreNot() {
+ knowEveryBlockButTheUnknownOne();
+ ResolvedDepositVariant variant = new ResolvedDepositVariant(new Gson().fromJson(DEEP_IRON, DepositVariant.class));
+ PlatformBlockState iron = UsableBlockPlatform.block("iron_ore");
+
+ PlatformBlockState remapped = variant.remapOrNull(iron);
+
+ assertEquals("minecraft:deepslate_iron_ore", remapped.key());
+ assertNull(variant.remapOrNull(UsableBlockPlatform.block("coal_ore")));
+ assertNull(variant.remapOrNull(null));
+ }
+
+ @Test
+ public void aRuleWhoseSourceTheServerDoesNotKnowRemapsNothing() {
+ knowEveryBlockButTheUnknownOne();
+ DepositVariant unknown = new Gson().fromJson("{\"remap\": {\"unknown_block\": \"minecraft:stone\"}}", DepositVariant.class);
+
+ assertNull(new ResolvedDepositVariant(unknown).remapOrNull(UsableBlockPlatform.block("unknown_block")));
+ }
+
+ @Test
+ public void aVariantWithoutRemapsChangesNothing() {
+ UsableBlockPlatform.bind();
+ ResolvedDepositVariant variant = new ResolvedDepositVariant(new Gson().fromJson("{\"maxHeight\": 5}", DepositVariant.class));
+
+ assertNull(variant.remapOrNull(UsableBlockPlatform.block("iron_ore")));
+ }
+}