From 405ab0fb2d8baaf4a10fd4474ff8d8e16646fb6c Mon Sep 17 00:00:00 2001 From: piexel Date: Sat, 10 Oct 2026 13:15:34 +0200 Subject: [PATCH] Iris's worlds give the built-ins their IrisSeed; facade tests --- .../iris/core/modules/IrisPackWorld.java | 21 +++- .../core/modules/IrisWorldFacadesTest.java | 95 +++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 core/src/test/java/art/arcane/iris/core/modules/IrisWorldFacadesTest.java diff --git a/core/src/main/java/art/arcane/iris/core/modules/IrisPackWorld.java b/core/src/main/java/art/arcane/iris/core/modules/IrisPackWorld.java index 8b37a9fb7..2f87e9001 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/IrisPackWorld.java +++ b/core/src/main/java/art/arcane/iris/core/modules/IrisPackWorld.java @@ -18,8 +18,10 @@ package art.arcane.iris.core.modules; +import art.arcane.iris.builtin.IrisSeed; import art.arcane.iris.builtin.PendingSettings; import art.arcane.iris.engine.framework.Engine; +import art.arcane.iris.engine.framework.SeedManager; import com.volmit.config.PackSettings; import com.volmit.host.WorldStates; import com.volmit.world.PackWorld; @@ -32,7 +34,7 @@ import java.util.function.Function; * pack's resources reload under it. Iris's built-in modules reach the engine through {@link #of(PackWorld)}, as built-in * reaches do through {@link IrisPackSettings#of}. */ -public final class IrisPackWorld implements PackWorld, PendingSettings { +public final class IrisPackWorld implements PackWorld, PendingSettings, IrisSeed.Source { private final Engine engine; private final IrisPackResources resources; private final WorldStates states = new WorldStates(); @@ -77,6 +79,23 @@ public final class IrisPackWorld implements PackWorld, PendingSettings { return states.state(type, () -> create.apply(this)); } + @Override + public long seed(IrisSeed seed) { + SeedManager seeds = engine.getSeedManager(); + return switch (seed) { + case BIOME -> seeds.getBiome(); + case CARVE -> seeds.getCarve(); + case COMPONENT -> seeds.getComponent(); + case DECORATOR -> seeds.getDecorator(); + case DEPOSIT -> seeds.getDeposit(); + case ENTITY -> seeds.getEntity(); + case LOOT -> seeds.getLoot(); + case MANTLE -> seeds.getMantle(); + case POST -> seeds.getPost(); + case TERRAIN -> seeds.getTerrain(); + }; + } + @Override public boolean hidesOres() { return pendingSettings.hidesOres(); diff --git a/core/src/test/java/art/arcane/iris/core/modules/IrisWorldFacadesTest.java b/core/src/test/java/art/arcane/iris/core/modules/IrisWorldFacadesTest.java new file mode 100644 index 000000000..12f52e9ec --- /dev/null +++ b/core/src/test/java/art/arcane/iris/core/modules/IrisWorldFacadesTest.java @@ -0,0 +1,95 @@ +/* + * 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.IrisSeed; +import art.arcane.iris.builtin.PendingSettings; +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.world.PackWorld; +import org.junit.Test; + +import java.util.EnumMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** An Iris world answers the built-ins' narrow questions: Iris's own seeds, and the settings still on its dimension. */ +public class IrisWorldFacadesTest { + @Test + public void everyIrisSeedIsTheSeedManagersSeedOfThatName() { + SeedManager seeds = mock(SeedManager.class); + when(seeds.getBiome()).thenReturn(1L); + when(seeds.getCarve()).thenReturn(2L); + when(seeds.getComponent()).thenReturn(3L); + when(seeds.getDecorator()).thenReturn(4L); + when(seeds.getDeposit()).thenReturn(5L); + when(seeds.getEntity()).thenReturn(6L); + when(seeds.getLoot()).thenReturn(7L); + when(seeds.getMantle()).thenReturn(8L); + when(seeds.getPost()).thenReturn(9L); + when(seeds.getTerrain()).thenReturn(10L); + Engine engine = engine(new IrisDimension()); + when(engine.getSeedManager()).thenReturn(seeds); + PackWorld world = new IrisPackWorld(engine); + Map expected = new EnumMap<>(IrisSeed.class); + long next = 1; + for (IrisSeed seed : IrisSeed.values()) { + expected.put(seed, next++); + } + + for (IrisSeed seed : IrisSeed.values()) { + assertEquals(seed.name(), expected.get(seed).longValue(), seed.of(world)); + } + } + + @Test + public void pendingSettingsAreTheDimensionsOwn() { + IrisDimension dimension = new IrisDimension(); + dimension.setHideOresForHiddenOre(true); + dimension.setPostProcessingWalls(false); + PendingSettings pending = PendingSettings.of(new IrisPackWorld(engine(dimension))); + + assertTrue(pending.hidesOres()); + assertFalse(pending.postProcessingWalls()); + assertTrue("slabs are on by default", pending.postProcessingSlabs()); + } + + @Test + public void aWorldIrisDoesNotGenerateHasNeither() { + PackWorld foreign = mock(PackWorld.class); + + assertThrows(IllegalArgumentException.class, () -> IrisSeed.POST.of(foreign)); + assertThrows(IllegalArgumentException.class, () -> PendingSettings.of(foreign)); + } + + private static Engine engine(IrisDimension dimension) { + Engine engine = mock(Engine.class); + when(engine.getData()).thenReturn(mock(IrisData.class)); + when(engine.getDimension()).thenReturn(dimension); + return engine; + } +}