Drop Iris's compatibility seeds, reserved stage flags and noise fallbacks

- Iris answers every purpose seed by the API's rule; IrisWorldSeeds and
  its legacy map are gone.
- Every mantle stage gets an assigned flag; disabledComponents names
  stages by id, and a name that matches no stage fails the world.
- An unknown noise style or a missing expression throws.
This commit is contained in:
piexel committed 2026-11-06 07:31:11 +01:00
1 parent 6e1a206013
commit 949157fd26
15 files changed
+122 -260

No files matched your search

@@ -0,0 +1,45 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisSeedPurposes;
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.world.dimension.IrisDimension;
import com.volmit.random.WorldRandom;
import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** An Iris world seeds every purpose by the API's rule, Iris's own purposes included. */
public class IrisPackWorldSeedTest {
private static final long WORLD_SEED = 42L;
@Test
public void irisPurposesFollowTheApisRule() {
PackWorld world = new IrisPackWorld(engine());
assertEquals(WorldRandom.purposeSeed(WORLD_SEED, IrisSeedPurposes.TERRAIN), world.seed(IrisSeedPurposes.TERRAIN));
assertEquals(WorldRandom.purposeSeed(WORLD_SEED, IrisSeedPurposes.OBJECT_WARP), world.seed(IrisSeedPurposes.OBJECT_WARP));
}
@Test
public void otherPurposesFollowTheApisRule() {
ResourceId patches = new ResourceId("example", "moss/patches");
assertEquals(WorldRandom.purposeSeed(WORLD_SEED, patches), new IrisPackWorld(engine()).seed(patches));
}
private static Engine engine() {
SeedManager seeds = mock(SeedManager.class);
when(seeds.getSeed()).thenReturn(WORLD_SEED);
Engine engine = mock(Engine.class);
when(engine.getData()).thenReturn(mock(IrisData.class));
when(engine.getDimension()).thenReturn(new IrisDimension());
when(engine.getSeedManager()).thenReturn(seeds);
return engine;
}
}
@@ -7,6 +7,7 @@ import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.material.IrisBlockData;
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
import art.arcane.iris.engine.object.noise.expression.IrisExpression;
import art.arcane.iris.engine.object.prefab.TileData;
import art.arcane.iris.spi.IrisPlatform;
import art.arcane.iris.spi.IrisPlatforms;
@@ -201,15 +202,29 @@ public class IrisValuesTest {
}
@Test
public void aStyleNameIrisDoesNotKnowIsFlat() {
IrisData data = packWithoutCustomBlocks();
IrisNoiseFactory noise = noiseOf(data);
NoiseSampler unknown = noise.sampler(NoiseStyle.of("NOT_A_STYLE"), 7);
NoiseSampler flat = noise.sampler(NoiseStyle.of(NoiseStyle.FLAT), 7);
public void aStyleNameIrisDoesNotKnowFails() {
IrisNoiseFactory noise = noiseOf(packWithoutCustomBlocks());
for (double[] column : COLUMNS) {
assertEquals(flat.sample(column[0], column[1]), unknown.sample(column[0], column[1]), 0);
}
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
() -> noise.sampler(NoiseStyle.of("NOT_A_STYLE"), 7));
assertEquals("Iris has no noise style \"NOT_A_STYLE\"", failure.getMessage());
}
@Test
public void anExpressionThePackDoesNotHaveFails() {
IrisData data = packWithoutCustomBlocks();
@SuppressWarnings("unchecked")
ResourceLoader<IrisExpression> noExpressions = mock(ResourceLoader.class);
when(noExpressions.getPossibleKeys()).thenReturn(new String[0]);
when(data.getExpressionLoader()).thenReturn(noExpressions);
IrisNoiseFactory noise = noiseOf(data);
String json = "{\"style\": \"SIMPLEX\", \"expression\": {\"namespace\": \"test\", \"path\": \"missing\"}}";
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
() -> noise.sampler(new Gson().fromJson(json, NoiseStyle.class), 7));
assertEquals("The pack has no expression test:missing", failure.getMessage());
}
@Test
@@ -1,93 +0,0 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisSeedPurposes;
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.world.dimension.IrisDimension;
import com.volmit.random.WorldRandom;
import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import org.junit.Test;
import java.util.LinkedHashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** An Iris world answers Iris's seed purposes with its legacy seeds and every other purpose by the API's rule. */
public class IrisWorldSeedsTest {
private static final long WORLD_SEED = 42L;
@Test
public void everyIrisSeedPurposeIsTheSeedManagersSeedOfThatName() {
Map<ResourceId, Long> expected = new LinkedHashMap<>();
expected.put(IrisSeedPurposes.BIOME, 1L);
expected.put(IrisSeedPurposes.CARVE, 2L);
expected.put(IrisSeedPurposes.COMPLEX, 3L);
expected.put(IrisSeedPurposes.COMPONENT, 4L);
expected.put(IrisSeedPurposes.DECORATOR, 5L);
expected.put(IrisSeedPurposes.DEPOSIT, 6L);
expected.put(IrisSeedPurposes.ENTITY, 7L);
expected.put(IrisSeedPurposes.LOOT, 8L);
expected.put(IrisSeedPurposes.MANTLE, 9L);
expected.put(IrisSeedPurposes.POST, 10L);
expected.put(IrisSeedPurposes.TERRAIN, 11L);
PackWorld world = new IrisPackWorld(engine(numberedSeeds()));
expected.forEach((purpose, seed) -> assertEquals(purpose.toString(), seed.longValue(), world.seed(purpose)));
}
@Test
public void anyOtherPurposeFollowsTheApisRule() {
ResourceId patches = new ResourceId("example", "moss/patches");
PackWorld world = new IrisPackWorld(engine(numberedSeeds()));
assertEquals(WorldRandom.purposeSeed(WORLD_SEED, patches), world.seed(patches));
}
private static SeedManager numberedSeeds() {
SeedManager seeds = mock(SeedManager.class);
when(seeds.getSeed()).thenReturn(WORLD_SEED);
when(seeds.getBiome()).thenReturn(1L);
when(seeds.getCarve()).thenReturn(2L);
when(seeds.getComplex()).thenReturn(3L);
when(seeds.getComponent()).thenReturn(4L);
when(seeds.getDecorator()).thenReturn(5L);
when(seeds.getDeposit()).thenReturn(6L);
when(seeds.getEntity()).thenReturn(7L);
when(seeds.getLoot()).thenReturn(8L);
when(seeds.getMantle()).thenReturn(9L);
when(seeds.getPost()).thenReturn(10L);
when(seeds.getTerrain()).thenReturn(11L);
return seeds;
}
private static Engine engine(SeedManager seeds) {
Engine engine = mock(Engine.class);
when(engine.getData()).thenReturn(mock(IrisData.class));
when(engine.getDimension()).thenReturn(new IrisDimension());
when(engine.getSeedManager()).thenReturn(seeds);
return engine;
}
}
@@ -18,11 +18,9 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisSeedPurposes;
import art.arcane.iris.core.IrisSettings;
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.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisPlatforms;
import com.volmit.ModuleLog;
@@ -50,7 +48,6 @@ import static org.mockito.Mockito.when;
*/
public class ModuleLogTest {
private static final String MODULE = "iris:decorant";
private static final long POST_SEED = 9L;
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
private final ByteArrayOutputStream err = new ByteArrayOutputStream();
@@ -131,17 +128,13 @@ public class ModuleLogTest {
}
@Test
public void theWorldOffersIrissOwnCodeTheEngineAndAnswersItsSeedPurposesWithTheLegacySeeds() {
public void theWorldOffersIrissOwnCodeTheEngine() {
Engine engine = mock(Engine.class);
when(engine.getData()).thenReturn(mock(IrisData.class));
when(engine.getDimension()).thenReturn(new IrisDimension());
SeedManager seeds = mock(SeedManager.class);
when(seeds.getPost()).thenReturn(POST_SEED);
when(engine.getSeedManager()).thenReturn(seeds);
PackWorld world = new IrisPackWorld(engine);
assertSame(engine, world.extension(Engine.class).orElseThrow());
assertEquals(POST_SEED, world.seed(IrisSeedPurposes.POST));
assertTrue("nothing else is offered", world.extension(String.class).isEmpty());
}
@@ -23,9 +23,7 @@ import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.EngineGeneration;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
import com.volmit.ModuleSetup;
@@ -35,19 +33,13 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.MockedStatic;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.ArgumentMatchers.eq;
import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
/** Every mantle stage is a mantle pass of its own, in the stage graph's order. */
@@ -78,16 +70,17 @@ public class ModuleMantleComponentTest {
@Test
public void everyMantleStageIsAPassOfItsOwnWithItsFlagAndThePacksReach() throws IOException {
try (LoadedPack ignored = BuiltInPack.serve(data, folder, List.of(marks))) {
List<ModuleMantleComponent> components = ModuleMantleComponent.forPack(engine, List.of("CARVED"));
List<ModuleMantleComponent> components = ModuleMantleComponent.forPack(engine, List.of("iris:carve/caves"));
assertEquals(List.of("iris:carve/caves", "iris:objects/place", "iris:floating/objects", "iris:structure/place", "test:marks/mark"),
components.stream().map(component -> component.stage().stage().id().toString()).toList());
assertEquals(List.of(ReservedFlag.CARVED, ReservedFlag.OBJECT, ReservedFlag.FLOATING_OBJECT, ReservedFlag.JIGSAW, MantleFlag.of(MantleFlag.MIN_ORDINAL)),
int first = MantleFlag.MIN_ORDINAL;
assertEquals(List.of(MantleFlag.of(first), MantleFlag.of(first + 1), MantleFlag.of(first + 2), MantleFlag.of(first + 3), MantleFlag.of(first + 4)),
components.stream().map(ModuleMantleComponent::getFlag).toList());
assertEquals(List.of(0, 1, 2, 3, 4), components.stream().map(ModuleMantleComponent::getPriority).toList());
assertEquals("a pack without objects or structures: caves 1, floating objects at least 16", List.of(1, 0, 16, 0, MARK_REACH),
components.stream().map(ModuleMantleComponent::getRadius).toList());
assertEquals("disabledComponents: [CARVED] turns the cave pass off", List.of(false, true, true, true, true),
assertEquals("disabledComponents: [iris:carve/caves] turns the cave pass off", List.of(false, true, true, true, true),
components.stream().map(ModuleMantleComponent::isEnabled).toList());
}
}
@@ -102,28 +95,15 @@ public class ModuleMantleComponentTest {
}
@Test
public void anIrisStageIsDisabledByItsIdAsWellAsByItsFlag() throws IOException {
public void aNameThatIsNoStageFailsListingTheStageIds() throws IOException {
try (LoadedPack ignored = BuiltInPack.serve(data, folder, List.of(marks))) {
List<ModuleMantleComponent> byId = ModuleMantleComponent.forPack(engine, List.of("iris:objects/place"));
List<ModuleMantleComponent> byFlag = ModuleMantleComponent.forPack(engine, List.of("OBJECT"));
List<String> names = List.of("test:marks/missing", "CARVED", "iris:carve/caves");
assertEquals(List.of(true, false, true, true, true), byId.stream().map(ModuleMantleComponent::isEnabled).toList());
assertEquals(List.of(true, false, true, true, true), byFlag.stream().map(ModuleMantleComponent::isEnabled).toList());
}
}
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
() -> ModuleMantleComponent.forPack(engine, names));
@Test
public void aNameThatIsNoStageIsWarnedAboutAndDisablesNothing() throws IOException {
try (LoadedPack ignored = BuiltInPack.serve(data, folder, List.of(marks));
MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
List<String> names = List.of("test:marks/missing", "CUSTOM:64", "CARVED");
List<ModuleMantleComponent> components = ModuleMantleComponent.forPack(engine, names);
assertEquals(List.of(false, true, true, true, true), components.stream().map(ModuleMantleComponent::isEnabled).toList());
logging.verify(() -> IrisLogging.warn(contains("disabledComponents names"), eq("CUSTOM:64"), any()), times(1));
logging.verify(() -> IrisLogging.warn(contains("disabledComponents names"), eq("test:marks/missing"), any()), times(1));
logging.verify(() -> IrisLogging.warn(anyString(), any(Object[].class)), times(2));
assertEquals("disabledComponents names [CARVED, test:marks/missing], which are not ids of mantle stages of the pack: "
+ "[iris:carve/caves, iris:objects/place, iris:floating/objects, iris:structure/place, test:marks/mark]", failure.getMessage());
}
}
}
@@ -18,13 +18,13 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
/** Studio offers the flags of Iris's own mantle stages for a dimension's disabledComponents, then the pack's mantle stage ids. */
/** Studio offers the ids of the pack's mantle stages, in their order, for a dimension's disabledComponents. */
public class ComponentFlagFunctionTest {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void offersTheFlagsOfIrisMantleStagesInTheirOrderThenThePacksMantleStageIds() throws IOException {
public void offersTheIdsOfThePacksMantleStagesInTheirOrder() throws IOException {
IrisModule moss = new IrisModule() {
public ModuleInfo info() { return ModuleInfo.of("test:moss", "Moss", "1"); }
public void setup(ModuleSetup setup) {
@@ -34,7 +34,8 @@ public class ComponentFlagFunctionTest {
IrisData data = mock(IrisData.class);
try (LoadedPack ignored = BuiltInPack.serve(data, folder, List.of(moss))) {
assertEquals(List.of("CARVED", "OBJECT", "FLOATING_OBJECT", "JIGSAW", "test:moss/veins"), new ComponentFlagFunction().apply(data));
assertEquals(List.of("iris:carve/caves", "iris:objects/place", "iris:floating/objects", "iris:structure/place", "test:moss/veins"),
new ComponentFlagFunction().apply(data));
}
}
}