mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Batch 6 part 4a: purpose seeds and the running world for the built-ins
Finding 40, first step. IrisPackWorld answers seed(purpose) through IrisWorldSeeds (iris:seed/* map to SeedManager's legacy seeds, any other id to WorldRandom.purposeSeed) and running() with IrisRunningWorld (the engine's layout over the whole world, chunk-stage settings, highest block, cave floors, sky, platform loot tables, studio as debug), built on first use. IrisObjectHost loses the layout and settings lookups the API now answers and gains placedLoot; spawner cooldowns are offered as SpawnCooldowns. Tests follow; generation output is unchanged (goldens, pins and probes pass as they were).
This commit is contained in:
1 parent
711fdd078a
commit
df10a90117
34 files changed
+541
-484
No files matched your search
@@ -30,6 +30,7 @@ import art.arcane.iris.engine.framework.SeedManager;
|
||||
import art.arcane.iris.engine.loot.BlockDropping;
|
||||
import art.arcane.iris.engine.loot.LootResources;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||
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;
|
||||
@@ -88,19 +89,25 @@ public class BuiltInModulesJarServicesTest {
|
||||
when(blocks.resolve(any(BlockSpec.class))).thenAnswer(invocation -> BlockState.parse("minecraft:" + invocation.<BlockSpec>getArgument(0).block()));
|
||||
when(data.getPackResources().blocks()).thenReturn(blocks);
|
||||
when(data.getPackResources().items()).thenReturn(item -> OptionalInt.of(0));
|
||||
ModuleResourceFixture.serveColumnSettings(data);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getMinHeight()).thenReturn(-64);
|
||||
when(engine.getHeight()).thenReturn(384);
|
||||
IrisWorld engineWorld = mock(IrisWorld.class);
|
||||
when(engineWorld.minHeight()).thenReturn(-64);
|
||||
when(engine.getWorld()).thenReturn(engineWorld);
|
||||
IrisComplex complex = mock(IrisComplex.class, RETURNS_DEEP_STUBS);
|
||||
when(complex.getHeightStream().get(X, Z)).thenReturn(64D);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
SeedManager seeds = mock(SeedManager.class);
|
||||
when(seeds.getLoot()).thenReturn(5L);
|
||||
when(engine.getSeedManager()).thenReturn(seeds);
|
||||
biome = bare(IrisBiome.class);
|
||||
dimension = bare(IrisDimension.class);
|
||||
biome = bare(IrisBiome.class, "biome");
|
||||
tables.biome(biome);
|
||||
dimension = bare(IrisDimension.class, "dimension");
|
||||
when(engine.getBiome(X, Y, Z)).thenReturn(biome);
|
||||
when(engine.getSurfaceBiome(X, Z)).thenReturn(biome);
|
||||
IrisRegion region = bare(IrisRegion.class);
|
||||
IrisRegion region = bare(IrisRegion.class, "region");
|
||||
when(engine.getRegion(X, Z)).thenReturn(region);
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
world = new EngineGeneration(engine).world();
|
||||
@@ -148,8 +155,9 @@ public class BuiltInModulesJarServicesTest {
|
||||
.copyingJarsTo(folder.newFolder().toPath()));
|
||||
}
|
||||
|
||||
private static <T extends IrisRegistrant> T bare(Class<T> type) {
|
||||
private static <T extends IrisRegistrant> T bare(Class<T> type, String key) {
|
||||
T owner = mock(type);
|
||||
when(owner.getLoadKey()).thenReturn(key);
|
||||
when(owner.getModuleSettings()).thenReturn(ModuleSettings.NONE);
|
||||
return owner;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.ResourceLoader;
|
||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||
@@ -39,11 +38,13 @@ import com.volmit.geometry.BlockFace;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import com.volmit.item.ItemRegistry;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.random.WorldRandom;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.resource.ResourceKind;
|
||||
import com.volmit.world.PackBiome;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import com.volmit.object.BlockEntityData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -149,10 +150,19 @@ public final class CarveTestWorld implements PackWorld {
|
||||
return ModuleLogs.discarding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long seed(ResourceId purpose) {
|
||||
return IrisSeedPurposes.CARVE.equals(purpose) ? carveSeed : WorldRandom.purposeSeed(carveSeed, purpose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RunningWorld> running() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> extension(Class<T> type) {
|
||||
IrisSeeds seeds = seed -> seed == IrisSeed.CARVE ? carveSeed : carveSeed + seed.ordinal();
|
||||
return type == IrisSeeds.class ? Optional.of(type.cast(seeds)) : Optional.empty();
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
+62
-47
@@ -18,19 +18,16 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.builtin.LiveWorld.BiomeKind;
|
||||
import art.arcane.iris.builtin.LiveWorld.Level;
|
||||
import art.arcane.iris.builtin.LiveWorld.ObjectLoots;
|
||||
import art.arcane.iris.builtin.LiveWorld.Sky;
|
||||
import art.arcane.iris.builtin.loot.LootSettings;
|
||||
import art.arcane.iris.builtin.loot.ObjectLoot;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost.ObjectLoots;
|
||||
import art.arcane.iris.builtin.spawn.SpawnCooldowns;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.engine.UsableBlockPlatform;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
import art.arcane.iris.engine.UsableBlockPlatform;
|
||||
import art.arcane.iris.engine.framework.PlacedObject;
|
||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
@@ -40,11 +37,17 @@ import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import com.volmit.world.RunningWorld.Sky;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -59,15 +62,17 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** What the built-in services ask a running world: the engine's answers for a block, as values. */
|
||||
public class IrisLiveWorldTest {
|
||||
/** What services ask a running Iris world: the engine's layout, settings and platform state, its spawners' cooldowns and the loot of its objects. */
|
||||
public class IrisRunningWorldTest {
|
||||
private static final int X = 10;
|
||||
private static final int Y = 70;
|
||||
private static final int Z = -20;
|
||||
private static final int BOTTOM = -64;
|
||||
private static final int HEIGHT = 384;
|
||||
|
||||
private Engine engine;
|
||||
private LiveWorld live;
|
||||
private PackWorld world;
|
||||
private RunningWorld running;
|
||||
|
||||
@BeforeClass
|
||||
public static void bindPlatform() {
|
||||
@@ -84,64 +89,65 @@ public class IrisLiveWorldTest {
|
||||
engine = mock(Engine.class);
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture.serve(data);
|
||||
ModuleResourceFixture.serveColumnSettings(data);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getMinHeight()).thenReturn(BOTTOM);
|
||||
live = new EngineGeneration(engine).world().extension(LiveWorld.class).orElseThrow();
|
||||
when(engine.getHeight()).thenReturn(HEIGHT);
|
||||
world = new EngineGeneration(engine).world();
|
||||
running = world.running().orElseThrow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void everyLevelReadsTheSettingsOfItsOwnerAtTheBlock() {
|
||||
public void theSettingsAtAColumnAreTheDimensionsTheRegionsAndTheSurfaceBiomes() {
|
||||
IrisDimension dimension = owner(IrisDimension.class, "dimension");
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
IrisRegion region = owner(IrisRegion.class, "region");
|
||||
IrisBiome surface = owner(IrisBiome.class, "surface");
|
||||
IrisBiome here = owner(IrisBiome.class, "here");
|
||||
IrisBiome cave = owner(IrisBiome.class, "cave");
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getRegion(X, Z)).thenReturn(region);
|
||||
when(engine.getSurfaceBiome(X, Z)).thenReturn(surface);
|
||||
when(engine.getBiome(X, Y, Z)).thenReturn(here);
|
||||
when(engine.getCaveBiome(X, Y, Z)).thenReturn(cave);
|
||||
|
||||
assertEquals(List.of("dimension", "region", "surface", "here", "cave"), List.of(
|
||||
tableAt(Level.DIMENSION), tableAt(Level.REGION), tableAt(Level.SURFACE_BIOME), tableAt(Level.BIOME), tableAt(Level.CAVE_BIOME)));
|
||||
SettingsStack<LootSettings> column = running.settings().at(LootSettings.class, X, Z);
|
||||
|
||||
assertEquals(List.of("dimension", "region", "surface"), List.of(tableOf(column, Level.DIMENSION), tableOf(column, Level.REGION),
|
||||
tableOf(column, Level.BIOME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aLevelWithoutSettingsOrOwnerHasNone() {
|
||||
IrisRegion bare = mock(IrisRegion.class);
|
||||
when(bare.getModuleSettings()).thenReturn(ModuleSettings.NONE);
|
||||
when(engine.getRegion(X, Z)).thenReturn(bare);
|
||||
|
||||
assertTrue(live.settings(LootSettings.class, Level.REGION, X, Y, Z).isEmpty());
|
||||
assertTrue(live.settings(LootSettings.class, Level.BIOME, X, Y, Z).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void biomesAreAskedByTheIdsThePackGivesThem() {
|
||||
public void theLayoutCoversTheWholeWorldWithBiomesByTheIdsThePackGivesThem() {
|
||||
IrisBiome surface = mock(IrisBiome.class);
|
||||
when(surface.getLoadKey()).thenReturn("Plains/Meadow");
|
||||
when(surface.getInferredType()).thenReturn(InferredType.SHORE);
|
||||
when(engine.getSurfaceBiome(X, Z)).thenReturn(surface);
|
||||
when(engine.getCaveBiome(X, Y, Z)).thenReturn(null);
|
||||
when(engine.getCaveBiome(X, Y, Z)).thenReturn(surface);
|
||||
|
||||
assertEquals(engine.getData().getPackResources().idOf("Plains/Meadow"), live.surfaceBiome(X, Z));
|
||||
assertEquals(live.surfaceBiome(X, Z), live.caveBiome(X, Y, Z));
|
||||
assertEquals(BiomeKind.SHORE, live.surfaceKind(X, Z));
|
||||
assertEquals(BOTTOM, live.bottomY());
|
||||
assertEquals(engine.getData().getPackResources().idOf("Plains/Meadow"), running.layout().surfaceBiome(X, Z));
|
||||
assertEquals(Optional.of(running.layout().surfaceBiome(X, Z)), running.layout().caveBiome(X, Y, Z));
|
||||
assertEquals(BiomeKind.SHORE, running.layout().surfaceKind(X, Z));
|
||||
assertTrue("far columns are in the layout", running.layout().bounds().contains(-29_999_999, 0, 29_999_999));
|
||||
assertEquals(HEIGHT, running.layout().bounds().maxY());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theHighestBlockIsTheEnginesHeightNow() {
|
||||
when(engine.getHeight(X, Z, true)).thenReturn(60);
|
||||
when(engine.getHeight(X, Z, false)).thenReturn(63);
|
||||
|
||||
assertEquals(60, running.highestBlock(X, Z, true));
|
||||
assertEquals(63, running.highestBlock(X, Z, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theSkyIsTheWorldsTimeAndWeatherOnceThereIsAPlatformWorld() {
|
||||
IrisWorld world = mock(IrisWorld.class);
|
||||
when(engine.getWorld()).thenReturn(world);
|
||||
assertEquals(Optional.empty(), live.sky());
|
||||
IrisWorld platformLess = mock(IrisWorld.class);
|
||||
when(engine.getWorld()).thenReturn(platformLess);
|
||||
assertEquals(Optional.empty(), running.sky());
|
||||
|
||||
PlatformWorld platform = mock(PlatformWorld.class);
|
||||
when(platform.getTime()).thenReturn(18000L);
|
||||
when(platform.isThundering()).thenReturn(true);
|
||||
when(world.platformWorld()).thenReturn(platform);
|
||||
when(platformLess.platformWorld()).thenReturn(platform);
|
||||
|
||||
assertEquals(Optional.of(new Sky(18000L, false, true)), live.sky());
|
||||
assertEquals(Optional.of(new Sky(18000L, false, true)), running.sky());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,7 +157,14 @@ public class IrisLiveWorldTest {
|
||||
when(mantle.findMarkers(2, 3, art.arcane.volmlib.util.matter.slices.MarkerMatter.CAVE_FLOOR))
|
||||
.thenReturn(new KList<>(new IrisPosition(40, 0, 50), new IrisPosition(41, 30, 51)));
|
||||
|
||||
assertEquals(List.of(new BlockPosition(40, 64, 50), new BlockPosition(41, 94, 51)), live.caveFloors(2, 3));
|
||||
assertEquals(List.of(new BlockPosition(40, 64, 50), new BlockPosition(41, 94, 51)), running.caveFloors(2, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aStudioWorldIsADebugWorld() {
|
||||
when(engine.isStudio()).thenReturn(true);
|
||||
|
||||
assertTrue(running.debug());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,23 +174,24 @@ public class IrisLiveWorldTest {
|
||||
placement.setOverrideGlobalLoot(true);
|
||||
when(engine.getObjectPlacement(X, Y, Z)).thenReturn(new PlacedObject(placement, null, 1, X, Z));
|
||||
when(engine.getObjectPlacement(X + 1, Y, Z)).thenReturn(new PlacedObject(null, null, 1, X + 1, Z));
|
||||
ObjectHost objects = world.extension(ObjectHost.class).orElseThrow();
|
||||
|
||||
ObjectLoots loots = live.objectLoots(X, Y, Z).orElseThrow();
|
||||
ObjectLoots loots = objects.placedLoot(X, Y, Z).orElseThrow();
|
||||
|
||||
assertEquals(1, loots.packTables().size());
|
||||
assertEquals("chest", loots.packTables().getFirst().name());
|
||||
assertTrue(loots.platformTables().isEmpty());
|
||||
assertTrue(loots.overridesGlobalLoot());
|
||||
assertTrue(loots.defined());
|
||||
assertTrue(live.objectLoots(X + 1, Y, Z).isEmpty());
|
||||
assertTrue(live.objectLoots(X + 2, Y, Z).isEmpty());
|
||||
assertTrue(objects.placedLoot(X + 1, Y, Z).isEmpty());
|
||||
assertTrue(objects.placedLoot(X + 2, Y, Z).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void spawnCooldownsCountPerWorldAndPerChunkAndForgetWhatRanOut() {
|
||||
IrisEngineData saved = new IrisEngineData();
|
||||
when(engine.getEngineData()).thenReturn(saved);
|
||||
SpawnCooldowns cooldowns = live.spawnCooldowns();
|
||||
SpawnCooldowns cooldowns = world.extension(SpawnCooldowns.class).orElseThrow();
|
||||
|
||||
assertTrue(cooldowns.canSpawn("wolves", 600_000L));
|
||||
cooldowns.spawned("wolves");
|
||||
@@ -199,10 +213,11 @@ public class IrisLiveWorldTest {
|
||||
T owner = mock(type);
|
||||
LootSettings loot = TestSettings.of(LootSettings.class, "{\"tables\": [\"" + table + "\"]}");
|
||||
when(owner.getModuleSettings()).thenReturn(BuiltInPack.settings(loot));
|
||||
when(owner.getLoadKey()).thenReturn(table);
|
||||
return owner;
|
||||
}
|
||||
|
||||
private String tableAt(Level level) {
|
||||
return live.settings(LootSettings.class, level, X, Y, Z).orElseThrow().tables().getFirst();
|
||||
private static String tableOf(SettingsStack<LootSettings> column, Level level) {
|
||||
return column.level(level).orElseThrow().tables().getFirst();
|
||||
}
|
||||
}
|
||||
+40
-20
@@ -18,27 +18,57 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
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.EnumMap;
|
||||
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 gives the built-ins Iris's own seeds. */
|
||||
public class IrisWorldFacadesTest {
|
||||
/** 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 everyIrisSeedIsTheSeedManagersSeedOfThatName() {
|
||||
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);
|
||||
@@ -50,24 +80,14 @@ public class IrisWorldFacadesTest {
|
||||
when(seeds.getMantle()).thenReturn(9L);
|
||||
when(seeds.getPost()).thenReturn(10L);
|
||||
when(seeds.getTerrain()).thenReturn(11L);
|
||||
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(), world.extension(IrisSeeds.class).orElseThrow().seed(seed));
|
||||
}
|
||||
return seeds;
|
||||
}
|
||||
|
||||
private static Engine engine(IrisDimension dimension) {
|
||||
private static Engine engine(SeedManager seeds) {
|
||||
Engine engine = mock(Engine.class);
|
||||
when(engine.getData()).thenReturn(mock(IrisData.class));
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getDimension()).thenReturn(new IrisDimension());
|
||||
when(engine.getSeedManager()).thenReturn(seeds);
|
||||
return engine;
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
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;
|
||||
@@ -132,7 +131,7 @@ public class ModuleLogTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theWorldOffersIrissOwnCodeTheEngineAndItsSeedsAsExtensions() {
|
||||
public void theWorldOffersIrissOwnCodeTheEngineAndAnswersItsSeedPurposesWithTheLegacySeeds() {
|
||||
Engine engine = mock(Engine.class);
|
||||
when(engine.getData()).thenReturn(mock(IrisData.class));
|
||||
when(engine.getDimension()).thenReturn(new IrisDimension());
|
||||
@@ -142,7 +141,7 @@ public class ModuleLogTest {
|
||||
PackWorld world = new IrisPackWorld(engine);
|
||||
|
||||
assertSame(engine, world.extension(Engine.class).orElseThrow());
|
||||
assertEquals(POST_SEED, world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.POST));
|
||||
assertEquals(POST_SEED, world.seed(IrisSeedPurposes.POST));
|
||||
assertTrue("nothing else is offered", world.extension(String.class).isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.host.DiscoveredModule;
|
||||
import com.volmit.host.FeatureCatalog;
|
||||
@@ -53,6 +54,21 @@ public final class ModuleResourceFixture {
|
||||
return fixture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes {@code data} (a mock this fixture serves) a pack folder of the fixture's namespace whose registrants' module settings
|
||||
* decode, so a running world's settings at a column name its dimension, region and biomes by the ids the fixture gives.
|
||||
*/
|
||||
public static void serveColumnSettings(IrisData data) {
|
||||
when(data.getDataFolder()).thenReturn(new File(NAMESPACE));
|
||||
when(of(data).resources.settingsStacks()).thenReturn(new SettingsStacks());
|
||||
}
|
||||
|
||||
/** Makes the pack's biome of {@code biome}'s load key {@code biome}, so settings a biome id names are {@code biome}'s. */
|
||||
public ModuleResourceFixture biome(IrisBiome biome) {
|
||||
when(resources.irisBiome(idOf(biome.getLoadKey()))).thenReturn(Optional.of(biome));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** The fixture {@code data} (a mock) already serves from, or a new one. */
|
||||
public static synchronized ModuleResourceFixture of(IrisData data) {
|
||||
ModuleResourceFixture served = SERVED.get(data.getPackResources());
|
||||
|
||||
@@ -32,6 +32,8 @@ public class TreeDefinitionIndexTest {
|
||||
IrisDimension dimension = mock(IrisDimension.class);
|
||||
IrisRegion region = new IrisRegion();
|
||||
IrisBiome biome = new IrisBiome();
|
||||
region.setLoadKey("forest");
|
||||
biome.setLoadKey("forest/oaks");
|
||||
|
||||
ObjectPlacement explicit = TestSettings.of(ObjectPlacement.class,
|
||||
"{\"place\":[\"custom/ancient_oak\"],\"trees\":[{\"treeTypes\":[\"TREE\"],\"sizes\":[{}]}]}");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package art.arcane.iris.engine.decorator;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.decorant.DecorantSettings;
|
||||
import art.arcane.iris.builtin.decorant.DecorationPart;
|
||||
import art.arcane.iris.builtin.decorant.Decorator;
|
||||
@@ -72,7 +71,7 @@ public class BiomeDecoratorsTest {
|
||||
|
||||
@Test
|
||||
public void everyDecoratorNoiseSeedIsAFunctionOfTheWorldsDecoratorSeedItsBiomeAndItsPlace() {
|
||||
long decoratorSeed = world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.DECORATOR);
|
||||
long decoratorSeed = world.seed(IrisSeedPurposes.DECORATOR);
|
||||
long first = decorators.decorators(meadow, DecorationPart.NONE)[0].seed();
|
||||
long second = decorators.decorators(meadow, DecorationPart.NONE)[1].seed();
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ public class HintedLocatorTest {
|
||||
when(data.getBiomeLoader()).thenReturn(biomeLoader);
|
||||
ModuleResourceFixture.serve(data);
|
||||
ModuleResourceFixture.serveModules(data, new ObjectModule());
|
||||
ModuleResourceFixture.serveColumnSettings(data);
|
||||
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||
stubReachableBiomes();
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ public class LootEnvironmentPinTest {
|
||||
private static final int Z = 20;
|
||||
private static final int SURFACE_Y = 70;
|
||||
private static final int CAVE_Y = 40;
|
||||
private static final int WORLD_HEIGHT = 256;
|
||||
|
||||
private Engine engine;
|
||||
private IrisDimension dimension;
|
||||
@@ -63,15 +64,18 @@ public class LootEnvironmentPinTest {
|
||||
engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture fixture = ModuleResourceFixture.serve(data);
|
||||
ModuleResourceFixture.serveColumnSettings(data);
|
||||
for (String key : List.of("a", "b", "c", "d", "e")) {
|
||||
fixture.resource(LootResources.TABLES, key, table(key));
|
||||
}
|
||||
IrisComplex complex = engine.getComplex();
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getHeight()).thenReturn(WORLD_HEIGHT);
|
||||
dimension = mock(IrisDimension.class);
|
||||
region = mock(IrisRegion.class);
|
||||
surface = biome("surface");
|
||||
cave = biome("cave");
|
||||
fixture.biome(cave);
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getRegion(X, Z)).thenReturn(region);
|
||||
when(engine.getSurfaceBiome(X, Z)).thenReturn(surface);
|
||||
|
||||
@@ -266,6 +266,8 @@ public class LootResolverTest {
|
||||
}
|
||||
|
||||
private static final class ResolutionFixture {
|
||||
private static final int WORLD_HEIGHT = 256;
|
||||
|
||||
private final Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
||||
private final PackWorld world;
|
||||
|
||||
@@ -276,11 +278,13 @@ public class LootResolverTest {
|
||||
IrisComplex complex = engine.getComplex();
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture tables = ModuleResourceFixture.serve(data);
|
||||
ModuleResourceFixture.serveColumnSettings(data);
|
||||
for (String key : List.of("dimension", "region", "surface")) {
|
||||
tables.resource(LootResources.TABLES, key, TestSettings.of(LootTable.class, "{\"name\": \"" + key + "\"}"));
|
||||
}
|
||||
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getHeight()).thenReturn(WORLD_HEIGHT);
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(dimension.getModuleSettings()).thenReturn(fallbackTo("dimension"));
|
||||
when(region.getModuleSettings()).thenReturn(fallbackTo("region"));
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PlacementLootTest {
|
||||
when(resources.blocks()).thenReturn(blocks);
|
||||
when(blocks.find(any(String.class))).thenAnswer(invocation -> java.util.Optional.of(BlockState.parse(invocation.getArgument(0))));
|
||||
when(blocks.resolve(any(BlockSpec.class))).thenAnswer(invocation -> BlockState.parse(invocation.<BlockSpec>getArgument(0).block()));
|
||||
placement = new PlacementLoot(resources, () -> Set.of("minecraft:chests/simple_dungeon"), LOOT_SEED, ModuleLogs.discarding());
|
||||
placement = new PlacementLoot(resources, () -> Set.of(ResourceId.parse("minecraft:chests/simple_dungeon")), LOOT_SEED, ModuleLogs.discarding());
|
||||
}
|
||||
|
||||
private Loot.Table table(String key) {
|
||||
|
||||
@@ -1,58 +1,72 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.objects.ObjectBuilder;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost.Declaration;
|
||||
import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.RETURNS_MOCKS;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** Object placing builds its placements' noise and its procedural objects' variants before generation asks. */
|
||||
public class ObjectWarmUpTest {
|
||||
private static final ResourceId REGION = new ResourceId("test", "region");
|
||||
private static final ResourceId BIOME = new ResourceId("test", "biome");
|
||||
|
||||
@Test
|
||||
public void everyPlacementAndProceduralObjectOfBiomesAndRegionsIsBuilt() {
|
||||
ObjectHost host = mock(ObjectHost.class);
|
||||
IrisSeeds seeds = seed -> seed == IrisSeed.COMPONENT ? 1337L : 0L;
|
||||
PackWorld world = mock(PackWorld.class);
|
||||
when(world.extension(ObjectHost.class)).thenReturn(Optional.of(host));
|
||||
when(world.extension(IrisSeeds.class)).thenReturn(Optional.of(seeds));
|
||||
when(host.builder()).thenReturn(mock(ObjectBuilder.class, RETURNS_MOCKS));
|
||||
PackWorld world = worldWithStates(host);
|
||||
ObjectPlacement biomePlacement = placement();
|
||||
ObjectPlacement regionPlacement = placement();
|
||||
ProceduralObjectSettings biomeProceduralSettings = new ProceduralObjectSettings();
|
||||
ProceduralObjectSettings regionProceduralSettings = new ProceduralObjectSettings();
|
||||
ProceduralPlacement biomeTree = mock(ProceduralPlacement.class);
|
||||
ProceduralPlacement regionTree = mock(ProceduralPlacement.class);
|
||||
when(host.procedural(eq(biomeProceduralSettings), any())).thenReturn(List.of(biomeTree));
|
||||
when(host.procedural(eq(regionProceduralSettings), any())).thenReturn(List.of(regionTree));
|
||||
when(host.declarations(ObjectSettings.class)).thenReturn(List.of(
|
||||
new Declaration<>(Level.REGION, "region", objects(regionPlacement)),
|
||||
new Declaration<>(Level.BIOME, "biome", objects(biomePlacement))));
|
||||
new Declaration<>(Level.REGION, REGION, objects(regionPlacement)),
|
||||
new Declaration<>(Level.BIOME, BIOME, objects(biomePlacement))));
|
||||
when(host.declarations(ProceduralObjectSettings.class)).thenReturn(List.of(
|
||||
new Declaration<>(Level.REGION, "region", regionProceduralSettings),
|
||||
new Declaration<>(Level.BIOME, "biome", biomeProceduralSettings)));
|
||||
new Declaration<>(Level.REGION, REGION, oneTree("region-oak")),
|
||||
new Declaration<>(Level.BIOME, BIOME, oneTree("biome-oak"))));
|
||||
|
||||
new ObjectWarmUp(world).warm();
|
||||
|
||||
verify(host).warm(eq(biomePlacement), any(RNG.class));
|
||||
verify(host).warm(eq(regionPlacement), any(RNG.class));
|
||||
verify(biomeTree).variant(any(RNG.class));
|
||||
verify(regionTree).variant(any(RNG.class));
|
||||
verify(host, times(2)).builder();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static PackWorld worldWithStates(ObjectHost host) {
|
||||
PackWorld world = mock(PackWorld.class);
|
||||
Map<Class<?>, Object> states = new HashMap<>();
|
||||
when(world.extension(ObjectHost.class)).thenReturn(Optional.of(host));
|
||||
when(world.seed(IrisSeedPurposes.COMPONENT)).thenReturn(1337L);
|
||||
when(world.state(any(), any())).thenAnswer(invocation -> states.computeIfAbsent(invocation.getArgument(0),
|
||||
ignored -> invocation.<Function<PackWorld, Object>>getArgument(1).apply(world)));
|
||||
return world;
|
||||
}
|
||||
|
||||
private static ProceduralObjectSettings oneTree(String name) {
|
||||
return TestSettings.of(ProceduralObjectSettings.class, "{\"trees\":[{\"name\":\"" + name + "\"}]}");
|
||||
}
|
||||
|
||||
private static ObjectPlacement placement() {
|
||||
|
||||
@@ -5,7 +5,6 @@ import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ObjectSize;
|
||||
import art.arcane.iris.builtin.objects.PlaceableObject;
|
||||
import art.arcane.iris.builtin.objects.ProceduralObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.ProceduralPlacement;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
@@ -38,7 +37,6 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -77,11 +75,8 @@ public class PlacementReachTest {
|
||||
"{\"xAxis\":{\"enabled\":true,\"min\":90,\"max\":90,\"interval\":90},\"yAxis\":{\"enabled\":false}}"));
|
||||
when(procedural.translate()).thenReturn(TestSettings.of(ObjectTranslate.class, "{\"x\":3,\"y\":4}"));
|
||||
when(procedural.vacuumSettings()).thenReturn(Optional.empty());
|
||||
ObjectHost host = mock(ObjectHost.class);
|
||||
ProceduralObjectSettings settings = new ProceduralObjectSettings();
|
||||
when(host.procedural(eq(settings), any())).thenReturn(List.of(procedural));
|
||||
|
||||
assertEquals(53, new PlacementReach(host, ModuleLogs.discarding()).ofPack(declaring(ProceduralObjectSettings.class, settings)));
|
||||
assertEquals(53, PlacementReach.of(new ObjectSize(variant.width(), variant.height(), variant.depth()), procedural));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,14 +23,17 @@ import art.arcane.iris.builtin.objects.ObjectPlacement;
|
||||
import art.arcane.iris.builtin.objects.ObjectSettings;
|
||||
import art.arcane.iris.builtin.objects.TreeGrowthSettings;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.config.SettingsStack;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.SaplingGrowth;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -38,6 +41,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -51,19 +55,23 @@ public class TreeGrowingTest {
|
||||
new BlockPosition(10, 70, 20), new BlockPosition(10, 70, 20), ResourceId.ofPlatformKey("TREE"));
|
||||
private static final ResourceId SOURCE = ResourceId.parse("test:dimension/overworld");
|
||||
private static final ResourceId BIOME = ResourceId.parse("test:plains");
|
||||
private static final ResourceId REGION = ResourceId.parse("test:overworld");
|
||||
private static final BlockBox WORLD = new BlockBox(-1000, 0, -1000, 1000, 384, 1000);
|
||||
|
||||
private ObjectHost host;
|
||||
private FeatureSettings settings;
|
||||
private TerrainSampler layout;
|
||||
private PackWorld world;
|
||||
|
||||
@Before
|
||||
public void buildWorld() {
|
||||
host = mock(ObjectHost.class);
|
||||
settings = mock(FeatureSettings.class);
|
||||
when(host.columnSettings()).thenReturn(settings);
|
||||
layout = mock(TerrainSampler.class);
|
||||
when(layout.bounds()).thenReturn(WORLD);
|
||||
RunningWorld running = mock(RunningWorld.class);
|
||||
when(running.settings()).thenReturn(settings);
|
||||
when(running.layout()).thenReturn(layout);
|
||||
world = mock(PackWorld.class);
|
||||
when(world.extension(ObjectHost.class)).thenReturn(Optional.of(host));
|
||||
when(world.extension(ObjectHost.class)).thenReturn(Optional.of(mock(ObjectHost.class)));
|
||||
when(world.running()).thenReturn(Optional.of(running));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,7 +81,7 @@ public class TreeGrowingTest {
|
||||
Optional<SaplingGrowth.Growth> growth = new TreeGrowing().grow(world, OAK_SAPLING, mock(SaplingGrowth.Surroundings.class));
|
||||
|
||||
assertTrue(growth.isEmpty());
|
||||
verify(host, never()).biomeAt(anyInt(), anyInt(), anyInt());
|
||||
verify(layout, never()).surfaceBiome(anyInt(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,13 +90,13 @@ public class TreeGrowingTest {
|
||||
when(settings.at(TreeGrowthSettings.class, 10, 20)).thenReturn(SettingsStack.of(List.of(new Entry<>(Level.DIMENSION, SOURCE, enabled))));
|
||||
ObjectSettings objects = TestSettings.with(new ObjectSettings(), "objects",
|
||||
List.of(TestSettings.of(ObjectPlacement.class, "{\"place\":[\"a\"]}")));
|
||||
when(host.biomeAt(10, 70, 20)).thenReturn(BIOME);
|
||||
when(host.regionAt(10, 20)).thenReturn(REGION);
|
||||
when(host.biomeDeclaration(eq(BIOME), eq(ObjectSettings.class))).thenReturn(Optional.of(objects));
|
||||
when(host.regionDeclaration(eq(REGION), eq(ObjectSettings.class))).thenReturn(Optional.empty());
|
||||
when(layout.surfaceBiome(10, 20)).thenReturn(BIOME);
|
||||
when(settings.declaredBy(eq(BIOME), eq(ObjectSettings.class))).thenReturn(Optional.of(objects));
|
||||
when(settings.at(eq(ObjectSettings.class), anyInt(), anyInt())).thenReturn(SettingsStack.empty());
|
||||
|
||||
Optional<SaplingGrowth.Growth> growth = new TreeGrowing().grow(world, OAK_SAPLING, mock(SaplingGrowth.Surroundings.class));
|
||||
|
||||
assertTrue(growth.isEmpty());
|
||||
verify(settings).declaredBy(eq(BIOME), any());
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import com.volmit.noise.NoiseSampler;
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.floating.FloatingHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.builtin.post.PostProcessingSlabsSettings;
|
||||
@@ -80,6 +80,7 @@ import com.volmit.stage.Pipeline;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.BiomeSample;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import com.volmit.world.TerrainSample;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import com.volmit.world.UpperDimension;
|
||||
@@ -98,6 +99,7 @@ import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* One chunk as IrisApi shows it to a chunk stage, held in memory, so the ported built-ins are tested through the surface
|
||||
@@ -109,6 +111,10 @@ public final class ApiChunk implements GenerationContext {
|
||||
public static final int WIDTH = 16;
|
||||
public static final BlockState AIR = new BlockState("minecraft:air");
|
||||
private static final long SEED = 1337L;
|
||||
private static final List<ResourceId> IRIS_SEED_PURPOSES = List.of(IrisSeedPurposes.BIOME, IrisSeedPurposes.CARVE,
|
||||
IrisSeedPurposes.COMPLEX, IrisSeedPurposes.COMPONENT, IrisSeedPurposes.DECORATOR, IrisSeedPurposes.DEPOSIT,
|
||||
IrisSeedPurposes.ENTITY, IrisSeedPurposes.LOOT, IrisSeedPurposes.MANTLE, IrisSeedPurposes.POST,
|
||||
IrisSeedPurposes.TERRAIN);
|
||||
private static final String FLOATING_ID = "iris:floating";
|
||||
/** What every noise of the fixture's pack samples, everywhere. */
|
||||
private static final double HALF = 0.5;
|
||||
@@ -541,19 +547,26 @@ public final class ApiChunk implements GenerationContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* A world of the chunk: its pack's blocks, a state store and Iris's seeds, each the world seed plus its place. It has
|
||||
* no floating islands: its floating host answers no surface biome, so no column has an island.
|
||||
* A world of the chunk: its pack's blocks, a state store and Iris's seeds, each the world seed plus its place among Iris's purposes. It has
|
||||
* no floating islands: its running layout answers no surface biome and its biomes declare nothing, so no column has an island.
|
||||
*/
|
||||
private final class World implements PackWorld {
|
||||
private final Resources resources = new Resources();
|
||||
private final Map<Class<?>, Object> states = new HashMap<>();
|
||||
private final IrisSeeds seeds = seed -> SEED + seed.ordinal();
|
||||
private final FloatingHost floating = mock(FloatingHost.class);
|
||||
private final ObjectHost objects = mock(ObjectHost.class);
|
||||
private final RunningWorld running = mock(RunningWorld.class);
|
||||
|
||||
World() {
|
||||
TerrainSampler noSurfaceBiomes = mock(TerrainSampler.class);
|
||||
FeatureSettings nothingDeclared = mock(FeatureSettings.class);
|
||||
when(running.layout()).thenReturn(noSurfaceBiomes);
|
||||
when(running.settings()).thenReturn(nothingDeclared);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> extension(Class<T> type) {
|
||||
Object offered = type == IrisSeeds.class ? seeds : type == FloatingHost.class ? floating : type == ObjectHost.class ? objects : null;
|
||||
Object offered = type == FloatingHost.class ? floating : type == ObjectHost.class ? objects : null;
|
||||
return Optional.ofNullable(offered).map(type::cast);
|
||||
}
|
||||
|
||||
@@ -562,6 +575,16 @@ public final class ApiChunk implements GenerationContext {
|
||||
return SEED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long seed(ResourceId purpose) {
|
||||
return SEED + IRIS_SEED_PURPOSES.indexOf(purpose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RunningWorld> running() {
|
||||
return Optional.of(running);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources resources() {
|
||||
return resources;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.floating.FloatingHost;
|
||||
import art.arcane.iris.builtin.objects.ObjectHost;
|
||||
import art.arcane.iris.engine.decorator.BiomeDecorators;
|
||||
@@ -14,6 +13,8 @@ import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -22,6 +23,7 @@ import java.util.function.Function;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -35,9 +37,9 @@ public class FloatingIslandsTest {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void columnsWithoutFloatingChildBiomesAreLeftAlone() {
|
||||
FloatingHost host = mock(FloatingHost.class);
|
||||
when(host.surfaceBiome(anyInt(), anyInt())).thenReturn(PLAIN_BIOME);
|
||||
PackWorld world = world(host);
|
||||
TerrainSampler layout = mock(TerrainSampler.class);
|
||||
when(layout.surfaceBiome(anyInt(), anyInt())).thenReturn(PLAIN_BIOME);
|
||||
PackWorld world = world(layout);
|
||||
Hunk<BlockState> output = mock(Hunk.class);
|
||||
when(output.height()).thenReturn(64);
|
||||
ChunkStageContext context = mock(ChunkStageContext.class, RETURNS_DEEP_STUBS);
|
||||
@@ -54,16 +56,21 @@ public class FloatingIslandsTest {
|
||||
islands.fillSolids(context);
|
||||
islands.decorateColumns(context);
|
||||
|
||||
verify(host, org.mockito.Mockito.atLeastOnce()).surfaceBiome(CHUNK_ORIGIN + 15, CHUNK_ORIGIN + 15);
|
||||
verify(layout, atLeastOnce()).surfaceBiome(CHUNK_ORIGIN + 15, CHUNK_ORIGIN + 15);
|
||||
verify(output, never()).set(anyInt(), anyInt(), anyInt(), any());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static PackWorld world(FloatingHost host) {
|
||||
private static PackWorld world(TerrainSampler layout) {
|
||||
RunningWorld running = mock(RunningWorld.class);
|
||||
when(running.layout()).thenReturn(layout);
|
||||
FeatureSettings nothingDeclaredByBiomes = mock(FeatureSettings.class);
|
||||
when(nothingDeclaredByBiomes.declaredBy(any(), any())).thenReturn(Optional.empty());
|
||||
when(running.settings()).thenReturn(nothingDeclaredByBiomes);
|
||||
PackWorld world = mock(PackWorld.class);
|
||||
when(world.extension(FloatingHost.class)).thenReturn(Optional.of(host));
|
||||
when(world.running()).thenReturn(Optional.of(running));
|
||||
when(world.extension(FloatingHost.class)).thenReturn(Optional.of(mock(FloatingHost.class)));
|
||||
when(world.extension(ObjectHost.class)).thenReturn(Optional.of(mock(ObjectHost.class)));
|
||||
when(world.extension(IrisSeeds.class)).thenReturn(Optional.of(seed -> 0L));
|
||||
when(world.resources()).thenReturn(mock(PackResources.class));
|
||||
PackSettings nothingDeclared = mock(PackSettings.class);
|
||||
when(nothingDeclared.declared(any())).thenAnswer(invocation -> SettingsStack.empty());
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
package art.arcane.iris.engine.object.terrain.carving;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeed;
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.builtin.IrisSeedPurposes;
|
||||
import art.arcane.iris.builtin.carve.CarvingEntry;
|
||||
import art.arcane.iris.builtin.carve.CarvingSettings;
|
||||
import art.arcane.iris.core.modules.CarveTestWorld;
|
||||
@@ -262,7 +261,7 @@ public class CarvingResolverParityTest {
|
||||
return parent;
|
||||
}
|
||||
|
||||
long seed = world.extension(IrisSeeds.class).orElseThrow().seed(IrisSeed.CARVE) ^ CHILD_SEED_SALT;
|
||||
long seed = world.seed(IrisSeedPurposes.CARVE) ^ CHILD_SEED_SALT;
|
||||
LegacyCarvingChoice selected = legacyChildrenGenerator(parent, seed).fitRarity(options, worldX, worldZ);
|
||||
if (selected == null || selected.entry == null) {
|
||||
return parent;
|
||||
|
||||
+1
-1
@@ -637,7 +637,7 @@ public class FloatingIslandBoundarySamplerTest {
|
||||
FloatingWorld world = mock(FloatingWorld.class);
|
||||
when(world.merges(parent)).thenReturn(merges);
|
||||
when(world.baseSeed()).thenReturn(baseSeed);
|
||||
when(world.minHeight()).thenReturn(0);
|
||||
when(world.minWorldY()).thenReturn(0);
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
+13
-3
@@ -5,7 +5,9 @@ import art.arcane.iris.builtin.floating.FloatingChildBiome;
|
||||
import art.arcane.iris.builtin.floating.FloatingHost;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackBiome;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
@@ -13,11 +15,15 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class ResolvedFloatingChildCarvingResolutionTest {
|
||||
private static final String NAMESPACE = "ns";
|
||||
|
||||
@Test
|
||||
public void carvingBiome_loadsBiomeKeyWhenEntryIdMissing() {
|
||||
ResourceId biome = ResourceId.parse("ns:carving/mushroom");
|
||||
@@ -41,8 +47,12 @@ public class ResolvedFloatingChildCarvingResolutionTest {
|
||||
}
|
||||
|
||||
private static FloatingWorld world(List<CarvingEntry> dimensionCarving, Map<String, ResourceId> biomes) {
|
||||
FloatingHost host = mock(FloatingHost.class);
|
||||
when(host.biome(anyString())).thenAnswer(invocation -> Optional.ofNullable(biomes.get(invocation.getArgument(0, String.class))));
|
||||
return new FloatingWorld(host, null, null, 0L, 0L, 0, dimensionCarving);
|
||||
PackResources resources = mock(PackResources.class);
|
||||
when(resources.idOf(anyString())).thenAnswer(invocation -> ResourceId.ofPackKey(NAMESPACE, invocation.getArgument(0, String.class)));
|
||||
when(resources.find(eq(PackResources.BIOMES), any())).thenAnswer(invocation -> {
|
||||
ResourceId id = invocation.getArgument(1);
|
||||
return biomes.containsValue(id) ? Optional.of(new PackBiome(id, id.path(), id, 1, List.of())) : Optional.empty();
|
||||
});
|
||||
return new FloatingWorld(mock(FloatingHost.class), null, resources, null, 0L, 0L, 0, dimensionCarving);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.BuiltInPack;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
@@ -46,6 +47,8 @@ import static org.mockito.Mockito.when;
|
||||
/** The ambient effects due around a player: the region's, then the biome's, each when its interval and chance allow, fully decided. */
|
||||
public class AmbientEffectingTest {
|
||||
private static final BlockPosition AT = new BlockPosition(10, 70, -20);
|
||||
private static final int SURFACE_HEIGHT = 64;
|
||||
private static final int WORLD_HEIGHT = 256;
|
||||
private static final String SOUND_AND_POTION = """
|
||||
{"effects": [{"sound": "ambient.cave", "soundDistance": 4, "minPitch": 0.5, "maxPitch": 0.5, "volume": 2,
|
||||
"potionEffect": "luck", "potionStrength": 1, "potionTicksMin": 100, "potionTicksMax": 100,
|
||||
@@ -66,17 +69,25 @@ public class AmbientEffectingTest {
|
||||
@Before
|
||||
public void buildWorld() {
|
||||
engine = mock(Engine.class);
|
||||
when(engine.getData()).thenReturn(mock(IrisData.class));
|
||||
IrisData data = mock(IrisData.class);
|
||||
ModuleResourceFixture fixture = ModuleResourceFixture.serve(data);
|
||||
ModuleResourceFixture.serveColumnSettings(data);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
IrisWorld engineWorld = mock(IrisWorld.class);
|
||||
PlatformWorld platformWorld = mock(PlatformWorld.class);
|
||||
when(engineWorld.platformWorld()).thenReturn(platformWorld);
|
||||
when(engine.getWorld()).thenReturn(engineWorld);
|
||||
region = mock(IrisRegion.class);
|
||||
biome = mock(IrisBiome.class);
|
||||
when(region.getLoadKey()).thenReturn("region");
|
||||
when(biome.getLoadKey()).thenReturn("surface");
|
||||
when(region.getModuleSettings()).thenReturn(ModuleSettingsOf.none());
|
||||
when(biome.getModuleSettings()).thenReturn(ModuleSettingsOf.none());
|
||||
fixture.biome(biome);
|
||||
when(engine.getRegion(10, -20)).thenReturn(region);
|
||||
when(engine.getBiome(10, 70, -20)).thenReturn(biome);
|
||||
when(engine.getSurfaceBiome(10, -20)).thenReturn(biome);
|
||||
when(engine.getHeight(10, -20, true)).thenReturn(SURFACE_HEIGHT);
|
||||
when(engine.getHeight()).thenReturn(WORLD_HEIGHT);
|
||||
world = new EngineGeneration(engine).world();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.engine.loot.LootItems;
|
||||
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||
import art.arcane.iris.builtin.LiveWorld.Sky;
|
||||
import com.volmit.world.RunningWorld.Sky;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.ModuleLog;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||
import art.arcane.iris.engine.UsableBlockPlatform;
|
||||
@@ -40,6 +39,7 @@ import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.EntitySpawns;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -92,10 +92,10 @@ public class EntitySpawningTest {
|
||||
|
||||
@Test
|
||||
public void aCaveWithoutFloorMarkersHasNowhereToSpawn() {
|
||||
LiveWorld live = mock(LiveWorld.class);
|
||||
when(live.caveFloors(2, 3)).thenReturn(List.of());
|
||||
RunningWorld running = mock(RunningWorld.class);
|
||||
when(running.caveFloors(2, 3)).thenReturn(List.of());
|
||||
|
||||
assertNull(EntitySpawning.caveSpawnPosition(live, 2, 3));
|
||||
assertNull(EntitySpawning.caveSpawnPosition(running, 2, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.spawn;
|
||||
|
||||
import art.arcane.iris.builtin.LiveWorld;
|
||||
import art.arcane.iris.builtin.LiveWorld.BiomeKind;
|
||||
import art.arcane.iris.builtin.LiveWorld.Sky;
|
||||
import art.arcane.iris.builtin.spawn.Spawner;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
@@ -29,6 +26,8 @@ import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.engine.object.runtime.IrisEngineData;
|
||||
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||
import art.arcane.iris.spi.PlatformWorld;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.RunningWorld.Sky;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -39,7 +38,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
/** Whether a spawner may fire: the biome kind its group wants, the world's time and weather, and its rates in the engine's data. */
|
||||
public class SpawnerGateTest {
|
||||
private LiveWorld live;
|
||||
private SpawnerGate gate;
|
||||
|
||||
@Before
|
||||
public void buildEngine() {
|
||||
@@ -51,7 +50,7 @@ public class SpawnerGateTest {
|
||||
when(engine.getWorld()).thenReturn(engineWorld);
|
||||
when(engine.getData()).thenReturn(mock(IrisData.class));
|
||||
when(engine.getEngineData()).thenReturn(new IrisEngineData());
|
||||
live = new EngineGeneration(engine).world().extension(LiveWorld.class).orElseThrow();
|
||||
gate = SpawnerGate.of(new EngineGeneration(engine).world());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,21 +81,21 @@ public class SpawnerGateTest {
|
||||
public void aSpawnerWithoutRatesAlwaysMayFire() {
|
||||
Spawner free = spawner("{}");
|
||||
|
||||
SpawnerGate.spawned("free", free, live, 3, 4);
|
||||
gate.spawned("free", free, 3, 4);
|
||||
|
||||
assertTrue(SpawnerGate.canSpawn("free", free, live, 3, 4));
|
||||
assertTrue(gate.canSpawn("free", free, 3, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRateHoldsTheSpawnerBackForItsIntervalPerWorldAndPerChunk() {
|
||||
Spawner limited = spawner("{\"maximumRate\": {\"amount\": 1, \"per\": {\"minutes\": 10}}, \"maximumRatePerChunk\": {\"amount\": 1, \"per\": {\"minutes\": 10}}}");
|
||||
|
||||
assertTrue(SpawnerGate.canSpawn("limited", limited, live, 3, 4));
|
||||
SpawnerGate.spawned("limited", limited, live, 3, 4);
|
||||
assertTrue(gate.canSpawn("limited", limited, 3, 4));
|
||||
gate.spawned("limited", limited, 3, 4);
|
||||
|
||||
assertFalse(SpawnerGate.canSpawn("limited", limited, live, 3, 4));
|
||||
assertFalse(SpawnerGate.canSpawn("limited", limited, live, 9, 9));
|
||||
assertTrue(SpawnerGate.canSpawn("other", limited, live, 9, 9));
|
||||
assertFalse(gate.canSpawn("limited", limited, 3, 4));
|
||||
assertFalse(gate.canSpawn("limited", limited, 9, 9));
|
||||
assertTrue(gate.canSpawn("other", limited, 9, 9));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,7 +104,7 @@ public class SpawnerGateTest {
|
||||
when(engine.getData()).thenReturn(mock(IrisData.class));
|
||||
when(engine.getWorld()).thenReturn(mock(IrisWorld.class));
|
||||
|
||||
assertFalse(SpawnerGate.canSpawn("any", spawner("{}"), new EngineGeneration(engine).world().extension(LiveWorld.class).orElseThrow(), 0, 0));
|
||||
assertFalse(SpawnerGate.of(new EngineGeneration(engine).world()).canSpawn("any", spawner("{}"), 0, 0));
|
||||
}
|
||||
|
||||
private static Spawner spawner(String json) {
|
||||
|
||||
@@ -24,10 +24,13 @@ import com.volmit.ModuleLog;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -51,6 +54,16 @@ public final class TestLayerBlocks {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long seed(ResourceId purpose) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RunningWorld> running() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackSettings settings() {
|
||||
throw new UnsupportedOperationException("Only the pack's resources here");
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.terrain;
|
||||
|
||||
import art.arcane.iris.builtin.IrisSeeds;
|
||||
import art.arcane.iris.core.modules.ModuleSettings;
|
||||
import com.volmit.config.Level;
|
||||
import com.volmit.IrisFeature;
|
||||
@@ -31,6 +30,7 @@ import com.volmit.host.ModuleLogs;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
import com.volmit.world.RunningWorld;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -113,9 +113,18 @@ public final class TestPackWorld implements PackWorld {
|
||||
return ModuleLogs.discarding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long seed(ResourceId purpose) {
|
||||
return seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RunningWorld> running() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> extension(Class<T> type) {
|
||||
IrisSeeds everySeedIsTheWorlds = which -> seed;
|
||||
return type == IrisSeeds.class ? Optional.of(type.cast(everySeedIsTheWorlds)) : Optional.empty();
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user