mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Iris's worlds give the built-ins their IrisSeed; facade tests
This commit is contained in:
1 parent
c270f79827
commit
405ab0fb2d
2 files changed
+115
-1
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<IrisSeed, Long> 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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user