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

@@ -18,17 +18,13 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.spi.IrisLogging;
import com.volmit.host.ResolvedStage;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* The names in a dimension's {@code disabledComponents}: the flag of one of Iris's own mantle stages
* ({@code CARVED}) or the id of any mantle stage ({@code example:moss/veins}).
*/
/** The names in a dimension's {@code disabledComponents}: ids of mantle stages, such as {@code iris:carve/caves}. */
final class DisabledComponents {
private final Set<String> names;
@@ -37,23 +33,23 @@ final class DisabledComponents {
}
boolean disables(ResolvedStage stage) {
return names.stream().anyMatch(name -> isNamed(stage, name));
return names.contains(stage.stage().id().toString());
}
/** The names that match none of {@code stages}, sorted. */
List<String> unknown(List<ResolvedStage> stages) {
return names.stream().filter(name -> stages.stream().noneMatch(stage -> isNamed(stage, name))).sorted().toList();
List<String> stageIds = MantleStageFlags.stageIds(stages);
return names.stream().filter(name -> !stageIds.contains(name)).sorted().toList();
}
void warnAboutUnknown(List<ResolvedStage> stages) {
for (String name : unknown(stages)) {
IrisLogging.warn("disabledComponents names \"%s\", which is neither a mantle flag of Iris (%s) nor the id of a mantle stage of the pack; ignored.",
name, MantleStageFlags.builtIn());
/** Fails when a name matches no mantle stage of the pack, listing the ids it could name. */
void requireKnown(List<ResolvedStage> stages) {
List<String> unknown = unknown(stages);
if (unknown.isEmpty()) {
return;
}
}
private static boolean isNamed(ResolvedStage stage, String name) {
return stage.stage().id().toString().equals(name)
|| MantleStageFlags.builtInFlag(stage.stage().id()).filter(flag -> flag.name().equals(name)).isPresent();
throw new IllegalArgumentException("disabledComponents names " + unknown + ", which "
+ (unknown.size() == 1 ? "is not the id" : "are not ids") + " of mantle stages of the pack: "
+ MantleStageFlags.stageIds(stages));
}
}
@@ -26,7 +26,6 @@ import com.volmit.ModuleLog;
import com.volmit.config.PackSettings;
import com.volmit.host.WorldStates;
import com.volmit.placement.Placements;
import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import com.volmit.world.RunningWorld;
import java.util.Optional;
@@ -75,10 +74,6 @@ public final class IrisPackWorld implements PackWorld {
return engine.getSeedManager().getSeed();
}
@Override
public long seed(ResourceId purpose) {
return IrisWorldSeeds.seed(engine.getSeedManager(), purpose);
}
@Override
public IrisPackResources resources() {
@@ -35,6 +35,7 @@ import com.volmit.config.Range;
import com.volmit.noise.StyledRange;
import com.volmit.geometry.BlockPosition;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import java.util.Map;
import java.util.Optional;
@@ -95,16 +96,17 @@ public final class IrisValues {
}
/**
* {@code style} as the generator style Iris builds noise from; a style name Iris does not know is flat. For behaviour that
* reads Iris's generator itself, such as the cave carvers' signed 3D reads, which {@code PackResources.noise()} does not offer.
* The expression and image map ids become the pack keys of {@code resources} that have them.
* {@code style} as the generator style Iris builds noise from. For behaviour that reads Iris's generator itself, such as
* the cave carvers' signed 3D reads, which {@code PackResources.noise()} does not offer. The expression and image map
* ids become the pack keys of {@code resources} that have them. A style name Iris does not know, or an expression the
* pack does not have, throws {@link IllegalArgumentException}.
*/
public static IrisGeneratorStyle generatorStyle(com.volmit.noise.NoiseStyle style, IrisPackResources resources) {
IrisGeneratorStyle iris = new IrisGeneratorStyle(irisStyle(style.style()));
iris.setCellularFrequency(style.cellularFrequency());
iris.setCellularZoom(style.cellularZoom());
iris.setZoom(style.zoom());
iris.setExpression(style.expression().map(id -> resources.keyOf(PackResources.EXPRESSIONS, id)).orElse(null));
iris.setExpression(style.expression().map(id -> expressionKey(id, resources)).orElse(null));
iris.setImageMap(style.imageMap().map(id -> resources.keyOf(PackResources.IMAGE_MAPS, id)).orElse(null));
iris.setMultiplier(style.multiplier());
iris.setFracture(style.fracture().map(fracture -> generatorStyle(fracture, resources)).orElse(null));
@@ -148,7 +150,14 @@ public final class IrisValues {
try {
return NoiseStyle.valueOf(name);
} catch (IllegalArgumentException unknown) {
return NoiseStyle.FLAT;
throw new IllegalArgumentException("Iris has no noise style \"" + name + "\"", unknown);
}
}
private static String expressionKey(ResourceId id, IrisPackResources resources) {
if (!resources.ids(PackResources.EXPRESSIONS).contains(id)) {
throw new IllegalArgumentException("The pack has no expression " + id);
}
return resources.keyOf(PackResources.EXPRESSIONS, id);
}
}
@@ -1,39 +0,0 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisSeedPurposes;
import art.arcane.iris.engine.framework.SeedManager;
import com.volmit.random.WorldRandom;
import com.volmit.resource.ResourceId;
import java.util.Map;
import java.util.function.ToLongFunction;
/**
* How Iris answers {@link com.volmit.world.PackWorld#seed(ResourceId)}: the built-in modules' {@link IrisSeedPurposes}
* get the seeds Iris's worlds always used for those features, every other purpose the API's rule.
*/
final class IrisWorldSeeds {
/** Object placements warped their surface with the component seed moved by this much. */
private static final long OBJECT_WARP_OFFSET = 1024L;
private static final Map<ResourceId, ToLongFunction<SeedManager>> LEGACY_SEEDS = Map.ofEntries(
Map.entry(IrisSeedPurposes.BIOME, SeedManager::getBiome),
Map.entry(IrisSeedPurposes.CARVE, SeedManager::getCarve),
Map.entry(IrisSeedPurposes.COMPLEX, SeedManager::getComplex),
Map.entry(IrisSeedPurposes.COMPONENT, SeedManager::getComponent),
Map.entry(IrisSeedPurposes.DECORATOR, SeedManager::getDecorator),
Map.entry(IrisSeedPurposes.DEPOSIT, SeedManager::getDeposit),
Map.entry(IrisSeedPurposes.ENTITY, SeedManager::getEntity),
Map.entry(IrisSeedPurposes.LOOT, SeedManager::getLoot),
Map.entry(IrisSeedPurposes.MANTLE, SeedManager::getMantle),
Map.entry(IrisSeedPurposes.OBJECT_WARP, seeds -> seeds.getComponent() + OBJECT_WARP_OFFSET),
Map.entry(IrisSeedPurposes.POST, SeedManager::getPost),
Map.entry(IrisSeedPurposes.TERRAIN, SeedManager::getTerrain));
private IrisWorldSeeds() {
}
static long seed(SeedManager seeds, ResourceId purpose) {
ToLongFunction<SeedManager> legacy = LEGACY_SEEDS.get(purpose);
return legacy != null ? legacy.applyAsLong(seeds) : WorldRandom.purposeSeed(seeds.getSeed(), purpose);
}
}
@@ -18,45 +18,25 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
import com.volmit.host.ResolvedStage;
import com.volmit.resource.ResourceId;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* The mantle flag of each mantle stage: it marks a mantle chunk whose stage has run, and names the stage in a
* dimension's {@code disabledComponents} when it is one of Iris's own. Iris's own mantle stages keep the flags
* their mantle components had, so packs that disable {@code CARVED} keep doing so and existing worlds stay
* marked. Every other stage gets a custom flag in resolved order, so adding or removing a pack mantle stage can
* renumber the stages after it; those flags stay internal and a dimension names such a stage by its id.
* The mantle flag of each mantle stage, which marks a mantle chunk whose stage has run. Every stage gets a custom
* flag in resolved order, so adding or removing a mantle stage can renumber the stages after it. The flags stay
* internal: a dimension names a stage in {@code disabledComponents} by its id.
*/
public final class MantleStageFlags {
private static final List<BuiltIn> BUILT_IN = List.of(
new BuiltIn(IrisStages.Carve.CAVES.id(), ReservedFlag.CARVED),
new BuiltIn(IrisStages.Objects.PLACE.id(), ReservedFlag.OBJECT),
new BuiltIn(IrisStages.Floating.OBJECTS.id(), ReservedFlag.FLOATING_OBJECT),
new BuiltIn(IrisStages.Structure.PLACE.id(), ReservedFlag.JIGSAW));
private MantleStageFlags() {
}
/** The flags of Iris's own mantle stages, in their order, which a dimension can list in {@code disabledComponents}. */
public static List<MantleFlag> builtIn() {
return BUILT_IN.stream().map(BuiltIn::flag).toList();
}
/** The ids of the mantle stages that have no flag of their own, which a dimension names by id in {@code disabledComponents}. */
public static List<String> packStageIds(List<ResolvedStage> stages) {
return stages.stream()
.map(stage -> stage.stage().id())
.filter(id -> builtInFlag(id).isEmpty())
.map(ResourceId::toString)
.toList();
/** The ids of {@code stages}, which a dimension names in {@code disabledComponents}. */
public static List<String> stageIds(List<ResolvedStage> stages) {
return stages.stream().map(stage -> stage.stage().id()).map(ResourceId::toString).toList();
}
/** One flag per stage, in the order of {@code stages}. */
@@ -64,11 +44,6 @@ public final class MantleStageFlags {
List<MantleFlag> flags = new ArrayList<>(stages.size());
int nextCustom = MantleFlag.MIN_ORDINAL;
for (ResolvedStage stage : stages) {
Optional<MantleFlag> builtIn = builtInFlag(stage.stage().id());
if (builtIn.isPresent()) {
flags.add(builtIn.get());
continue;
}
if (nextCustom > MantleFlag.MAX_ORDINAL) {
throw new IllegalStateException("The pack has more mantle stages than Iris has mantle flags for; stage "
+ stage.stage().id() + " of module " + stage.module() + " is one too many");
@@ -77,11 +52,4 @@ public final class MantleStageFlags {
}
return List.copyOf(flags);
}
static Optional<MantleFlag> builtInFlag(ResourceId stage) {
return BUILT_IN.stream().filter(builtIn -> builtIn.stage().equals(stage)).map(BuiltIn::flag).findFirst();
}
private record BuiltIn(ResourceId stage, MantleFlag flag) {
}
}
@@ -62,7 +62,7 @@ public final class ModuleMantleComponent implements MantleComponent {
/**
* One component per mantle stage of the engine's pack, in resolved order, each its own pass. A stage named in
* {@code disabledComponents} is turned off; a name that matches no stage is warned about.
* {@code disabledComponents} is turned off; a name that matches no stage fails.
*/
public static List<ModuleMantleComponent> forPack(Engine engine, Collection<String> disabledComponents) {
return forPack(engine, engine.getData().getModules().pack(), disabledComponents);
@@ -71,7 +71,7 @@ public final class ModuleMantleComponent implements MantleComponent {
static List<ModuleMantleComponent> forPack(Engine engine, LoadedPack pack, Collection<String> disabledComponents) {
ResolvedGraph graph = pack.mantle();
DisabledComponents disabled = new DisabledComponents(disabledComponents);
disabled.warnAboutUnknown(graph.stages());
disabled.requireKnown(graph.stages());
MantleRunner runner = new MantleRunner(graph);
IrisPackSettings settings = new IrisPackSettings(engine);
List<MantleFlag> flags = MantleStageFlags.assign(graph.stages());
@@ -25,7 +25,6 @@ import com.volmit.config.PackSettings;
import com.volmit.host.WorldStates;
import com.volmit.placement.Placements;
import com.volmit.resource.PackResources;
import com.volmit.resource.ResourceId;
import com.volmit.world.PackWorld;
import com.volmit.world.RunningWorld;
@@ -63,10 +62,6 @@ final class ToolWorld implements PackWorld, AutoCloseable {
return seeds.getSeed();
}
@Override
public long seed(ResourceId purpose) {
return IrisWorldSeeds.seed(seeds, purpose);
}
@Override
public PackResources resources() {
@@ -4,11 +4,10 @@ import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.modules.MantleStageFlags;
import art.arcane.iris.engine.framework.ListFunction;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
/**
* What studio offers for a dimension's {@code disabledComponents}: the flags of Iris's own mantle stages, such as
* {@code CARVED} for caves, then the ids of the pack's mantle stages.
* What studio offers for a dimension's {@code disabledComponents}: the ids of the pack's mantle stages, such as
* {@code iris:carve/caves}.
*/
public class ComponentFlagFunction implements ListFunction<KList<String>> {
@Override
@@ -23,8 +22,6 @@ public class ComponentFlagFunction implements ListFunction<KList<String>> {
@Override
public KList<String> apply(IrisData data) {
KList<String> names = MantleStageFlags.builtIn().stream().map(MantleFlag::toString).collect(KList.collector());
names.addAll(MantleStageFlags.packStageIds(data.getModules().pack().mantle().stages()));
return names;
return new KList<>(MantleStageFlags.stageIds(data.getModules().pack().mantle().stages()));
}
}
@@ -213,7 +213,7 @@ public class IrisDimension extends IrisRegistrant {
private KList<String> datapackImports = new KList<>();
@RegistryListFunction(ComponentFlagFunction.class)
@ArrayType(type = String.class)
@Desc("Mantle passes to skip in this dimension: CARVED (caves), OBJECT (objects), FLOATING_OBJECT (objects on floating islands) or JIGSAW (structures), or the id of a pack module's mantle stage, such as example:moss/veins. A name that matches nothing is warned about and ignored.")
@Desc("Mantle passes to skip in this dimension, by the id of their mantle stage, such as iris:carve/caves (caves), iris:objects/place (objects), iris:floating/objects (objects on floating islands), iris:structure/place (structures) or a pack module's example:moss/veins. A name that matches no stage fails the world.")
private KList<String> disabledComponents = new KList<>();
public int getMaxHeight() {
@@ -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));
}
}
}