Batch 7 stage 4a: host biome height, sky biome and platform biome writes

IrisTerrainSampler answers biomeHeight and skyBiome the way IrisFloatingHost
did; IrisModuleMantle stores setPlatformBiome as the custom biome inject the
biome pass reads. IrisFloatingHost is deleted. A new test pins that sky and
custom biome picks ignore the random when an engine is given, which is why
the api takes none.
This commit is contained in:
piexel committed 2026-10-28 01:58:50 +01:00
1 parent c0ed5ed81e
commit 7471f9fc42
15 files changed
+215 -89

No files matched your search

@@ -1,64 +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.floating.FloatingHost;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.matter.MatterBiomeInject;
import art.arcane.volmlib.util.matter.slices.BiomeInjectMatter;
import com.volmit.resource.ResourceId;
/** Iris's answers to {@code iris:floating}: a biome's terrain height by its generators, and sky biomes into the engine's mantle. */
final class IrisFloatingHost implements FloatingHost {
private final Engine engine;
IrisFloatingHost(Engine engine) {
this.engine = engine;
}
@Override
public double biomeHeight(ResourceId biome, int worldX, int worldZ, long seed) {
return irisBiome(biome).getHeight(engine, worldX, worldZ, seed);
}
@Override
public void paintSkyBiome(ResourceId biome, int worldX, int worldZ, int[] ys, RNG random) {
MatterBiomeInject matter = skyBiomeMatter(irisBiome(biome), worldX, worldZ, random);
for (int y : ys) {
engine.getMantle().getMantle().set(worldX, y, worldZ, matter);
}
}
private MatterBiomeInject skyBiomeMatter(IrisBiome target, int worldX, int worldZ, RNG random) {
if (target.isCustom()) {
IrisBiomeCustom custom = target.getCustomBiome(random, engine, worldX, 0, worldZ);
return BiomeInjectMatter.get(IrisPlatforms.get().biomeWriter().biomeIdFor(engine.getDimension().getLoadKey() + ":" + custom.getId()));
}
return BiomeInjectMatter.get(IrisPlatforms.get().biomeWriter().biomeIdFor(target.getSkyBiomeKey(random, engine, worldX, 0, worldZ)));
}
private IrisBiome irisBiome(ResourceId biome) {
return ((IrisPackResources) engine.getData().getPackResources()).irisBiome(biome)
.orElseThrow(() -> new IllegalArgumentException("The pack has no biome " + biome));
}
}
@@ -20,8 +20,12 @@ package art.arcane.iris.core.modules;
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.MatterBiomeInject;
import art.arcane.volmlib.util.matter.MatterSlice;
import art.arcane.volmlib.util.matter.slices.BiomeInjectMatter;
import art.arcane.iris.spi.IrisPlatforms;
import com.volmit.block.BlockState;
import com.volmit.resource.ResourceId;
import com.volmit.host.MantleRegistration;
import art.arcane.iris.builtin.MatterMantle;
import com.volmit.geometry.BlockBox;
@@ -116,6 +120,18 @@ final class IrisModuleMantle implements Mantle, MatterMantle {
return new MantleCaverns(bounds, chunks).isCarved(x, y, z);
}
/** Stored as the biome pass reads it: the platform's id for the biome, as a custom biome inject. */
@Override
public void setPlatformBiome(int x, int y, int z, ResourceId biome) {
Objects.requireNonNull(biome, "biome");
requireNoOpenEdit();
MatterBiomeInject inject = BiomeInjectMatter.get(IrisPlatforms.get().biomeWriter().biomeIdFor(biome.toString()));
MantleChunk<Matter> chunk = chunkAt(x, y, z);
synchronized (chunk) {
chunk.getOrCreate(y >> SECTION_SHIFT).slice(MatterBiomeInject.class).set(x & LOCAL_MASK, y & LOCAL_MASK, z & LOCAL_MASK, inject);
}
}
@Override
public MantleEdit edit() {
if (openEdit != null) {
@@ -272,6 +288,11 @@ final class IrisModuleMantle implements Mantle, MatterMantle {
throw new UnsupportedOperationException("Mantle edits cannot be nested; write through this edit");
}
@Override
public void setPlatformBiome(int x, int y, int z, ResourceId biome) {
throw new UnsupportedOperationException("An edit buffers module layers only; set platform biomes on the mantle itself");
}
/** Publishes every change, or none when a chunk it touches is missing; the edit then only closes. */
@Override
public void commit() {
@@ -18,7 +18,6 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.builtin.floating.FloatingHost;
import art.arcane.iris.builtin.LegacyStreams;
import art.arcane.iris.builtin.spawn.SpawnCooldowns;
import art.arcane.iris.builtin.structure.StructureHost;
@@ -38,7 +37,7 @@ import java.util.function.Function;
* state modules keep for it. {@link ModuleWorlds} makes one when the runtime is built and a new one whenever the
* pack's resources reload under it. Iris's built-in modules reach what they need of Iris through its
* {@linkplain #extension extensions}: the spawners' cooldowns Iris saves with the world, Iris's legacy random streams,
* and the floating and structure hosts.
* and the structure host.
*/
public final class IrisPackWorld implements PackWorld {
private final Engine engine;
@@ -49,7 +48,6 @@ public final class IrisPackWorld implements PackWorld {
private volatile RunningWorld running;
private final LegacyStreams legacyStreams;
private final Placements placements;
private volatile IrisFloatingHost floatingHost;
private volatile IrisStructureHost structureHost;
IrisPackWorld(Engine engine) {
@@ -133,24 +131,12 @@ public final class IrisPackWorld implements PackWorld {
if (type == LegacyStreams.class) {
return legacyStreams;
}
if (type == FloatingHost.class) {
return floating();
}
if (type == StructureHost.class) {
return structures();
}
return null;
}
private FloatingHost floating() {
IrisFloatingHost host = floatingHost;
if (host == null) {
host = new IrisFloatingHost(engine);
floatingHost = host;
}
return host;
}
private StructureHost structures() {
IrisStructureHost host = structureHost;
if (host == null) {
@@ -25,6 +25,7 @@ import com.volmit.config.FeatureSettings;
import com.volmit.geometry.BlockBox;
import com.volmit.object.ObjectTransformer;
import com.volmit.placement.PlacementContext;
import com.volmit.resource.ResourceId;
import com.volmit.world.BiomeKind;
import com.volmit.world.BiomeSample;
import com.volmit.world.BlockView;
@@ -129,6 +130,16 @@ final class IrisPlacementInputs implements PlacementContext {
public Optional<UpperDimension> upperDimension() {
throw withoutEngine();
}
@Override
public double biomeHeight(ResourceId biome, int worldX, int worldZ, long seed) {
throw withoutEngine();
}
@Override
public Optional<ResourceId> skyBiome(ResourceId biome, int worldX, int worldZ) {
throw withoutEngine();
}
};
}
@@ -24,6 +24,7 @@ import art.arcane.iris.engine.object.world.biome.InferredType;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.data.B;
import art.arcane.volmlib.util.math.RNG;
import com.volmit.block.BlockState;
import com.volmit.geometry.BlockBox;
import com.volmit.resource.ResourceId;
@@ -44,6 +45,8 @@ import java.util.OptionalInt;
*/
final class IrisTerrainSampler implements TerrainSampler {
private static final int CHUNK_WIDTH_BLOCKS = 16;
/** Passed where Iris's biome picks take a random they ignore when given the engine. */
private static final RNG UNUSED_RANDOM = new RNG(0L);
private final Engine engine;
private final PackResourceIds ids;
@@ -160,6 +163,31 @@ final class IrisTerrainSampler implements TerrainSampler {
return Optional.ofNullable(engine.getComplex().getImageMapRuntime().sampleSurfaceBlock(worldX, worldZ)).map(states::toApi);
}
@Override
public double biomeHeight(ResourceId biome, int worldX, int worldZ, long seed) {
requireInside(worldX, bounds.minY(), worldZ);
return irisBiome(biome).getHeight(engine, worldX, worldZ, seed);
}
/**
* The biome generator Iris picks custom and sky biomes with is seeded from the world's biome seed whenever there is an
* engine, so these picks need no random of their own.
*/
@Override
public Optional<ResourceId> skyBiome(ResourceId biome, int worldX, int worldZ) {
requireInside(worldX, bounds.minY(), worldZ);
IrisBiome target = irisBiome(biome);
String key = target.isCustom()
? engine.getDimension().getLoadKey() + ":" + target.getCustomBiome(UNUSED_RANDOM, engine, worldX, 0, worldZ).getId()
: target.getSkyBiomeKey(UNUSED_RANDOM, engine, worldX, 0, worldZ);
return Optional.ofNullable(key).map(ResourceId::ofPlatformKey);
}
private IrisBiome irisBiome(ResourceId biome) {
return ((IrisPackResources) engine.getData().getPackResources()).irisBiome(biome)
.orElseThrow(() -> new IllegalArgumentException("The pack has no biome " + biome));
}
@Override
public int minWorldY() {
return engine.getMinHeight();
@@ -28,6 +28,7 @@ import com.volmit.mantle.MantleEdit;
import com.volmit.mantle.MantleKey;
import com.volmit.mantle.MantleLayer;
import com.volmit.mantle.MantleVisitor;
import com.volmit.resource.ResourceId;
import java.util.Collection;
import java.util.Objects;
@@ -83,6 +84,11 @@ final class PlacementMantle implements Mantle, AutoCloseable {
throw new UnsupportedOperationException("The placement owns the mantle edit; write through layer()");
}
@Override
public void setPlatformBiome(int x, int y, int z, ResourceId biome) {
throw new UnsupportedOperationException("A placement writes blocks and module layers; stages set platform biomes");
}
/** Publishes everything the placement wrote, or nothing when a mantle chunk it touches is missing. */
void commit() {
try {
@@ -126,6 +126,16 @@ public final class CarveTestTerrain implements TerrainSampler {
return Optional.empty();
}
@Override
public double biomeHeight(ResourceId biome, int worldX, int worldZ, long seed) {
throw new UnsupportedOperationException();
}
@Override
public Optional<ResourceId> skyBiome(ResourceId biome, int worldX, int worldZ) {
throw new UnsupportedOperationException();
}
private void require(int worldX, int y, int worldZ) {
if (!bounds().contains(worldX, y, worldZ)) {
throw new IndexOutOfBoundsException(worldX + ", " + y + ", " + worldZ + " is outside " + bounds());
@@ -25,6 +25,9 @@ import art.arcane.iris.engine.framework.SeedManager;
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;
import art.arcane.iris.spi.IrisPlatform;
import art.arcane.iris.spi.IrisPlatforms;
import art.arcane.iris.spi.PlatformBiomeWriter;
import art.arcane.iris.util.project.matter.IrisMatterSupport;
import art.arcane.volmlib.util.function.Consumer4;
import art.arcane.volmlib.util.io.CountingDataInputStream;
@@ -33,7 +36,9 @@ import art.arcane.volmlib.util.mantle.runtime.MantleDataAdapter;
import art.arcane.volmlib.util.mantle.runtime.MantleHooks;
import art.arcane.volmlib.util.matter.IrisMatter;
import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.MatterBiomeInject;
import art.arcane.volmlib.util.matter.MatterSlice;
import com.volmit.resource.ResourceId;
import com.volmit.block.BlockState;
import com.volmit.IrisModule;
import com.volmit.ModuleInfo;
@@ -115,6 +120,33 @@ public class IrisModuleMantleTest {
return new IrisModuleMantle(bounds, this::chunk, LAYERS, PlannedBlocks.none(bounds));
}
/** The form the floating islands' sky biomes always had: the platform's id for the biome, as a custom inject, at the height above the bottom. */
@Test
public void aPlatformBiomeIsStoredAsTheBiomePassReadsIt() {
PlatformBiomeWriter biomeWriter = mock(PlatformBiomeWriter.class);
when(biomeWriter.biomeIdFor("minecraft:cherry_grove")).thenReturn(42);
IrisPlatform platform = mock(IrisPlatform.class);
when(platform.biomeWriter()).thenReturn(biomeWriter);
IrisPlatform previous = IrisPlatforms.isBound() ? IrisPlatforms.get() : null;
IrisPlatforms.unbind();
IrisPlatforms.bind(platform);
try {
IrisModuleMantle mantle = mantle(new BlockBox(0, 0, 0, 16, HEIGHT, 16));
mantle.setPlatformBiome(5, 37, 9, ResourceId.parse("minecraft:cherry_grove"));
assertEquals(new MatterBiomeInject(true, 42, null), chunk(0, 0).get(5, 37, 9, MatterBiomeInject.class));
assertNull(chunk(0, 0).get(5, 36, 9, MatterBiomeInject.class));
assertThrows(IndexOutOfBoundsException.class,
() -> mantle.setPlatformBiome(16, 37, 9, ResourceId.parse("minecraft:cherry_grove")));
} finally {
IrisPlatforms.unbind();
if (previous != null) {
IrisPlatforms.bind(previous);
}
}
}
@Test
public void theMatterSideGivesTheMantleChunksTheInvocationReachesAndNoOthers() {
IrisModuleMantle mantle = mantle(new BlockBox(0, 0, 0, 16, HEIGHT, 16));
@@ -18,15 +18,25 @@
package art.arcane.iris.core.modules;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.biome.custom.IrisBiomeCustom;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
import art.arcane.iris.util.project.stream.ProceduralStream;
import art.arcane.volmlib.util.collection.KList;
import com.volmit.resource.ResourceId;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -64,6 +74,34 @@ public class IrisTerrainSamplerTest {
assertEquals(64D, terrain.surfaceY(1, 3), 0D);
}
@Test
public void aSkyBiomeIsTheBiomesCustomBiomeUnderTheDimensionOrItsSkyScatterPick() {
IrisBiome custom = new IrisBiome();
custom.setCustomDerivitives(new KList<>(List.of(new IrisBiomeCustom().setId("glow"))));
IrisBiome scattered = new IrisBiome();
scattered.setBiomeSkyScatter(new KList<>(List.of("cherry_grove")));
ResourceId customId = ResourceId.parse("overworld:glowing");
ResourceId scatteredId = ResourceId.parse("overworld:orchard");
packBiomes(Map.of(customId, custom, scatteredId, scattered));
IrisDimension dimension = new IrisDimension();
dimension.setLoadKey("overworld");
when(engine.getDimension()).thenReturn(dimension);
IrisTerrainSampler terrain = new IrisTerrainSampler(engine, null, 0, 0, CHUNK_REACH);
assertEquals(Optional.of(ResourceId.parse("overworld:glow")), terrain.skyBiome(customId, 3, 4));
assertEquals(Optional.of(ResourceId.parse("minecraft:cherry_grove")), terrain.skyBiome(scatteredId, 3, 4));
assertThrows(IllegalArgumentException.class, () -> terrain.skyBiome(ResourceId.parse("overworld:missing"), 3, 4));
assertThrows(IndexOutOfBoundsException.class, () -> terrain.skyBiome(customId, 32, 0));
}
private void packBiomes(Map<ResourceId, IrisBiome> biomes) {
IrisPackResources resources = mock(IrisPackResources.class);
when(resources.irisBiome(any())).thenAnswer(invocation -> Optional.ofNullable(biomes.get(invocation.getArgument(0, ResourceId.class))));
IrisData data = mock(IrisData.class);
when(data.getPackResources()).thenReturn(resources);
when(engine.getData()).thenReturn(data);
}
@Test
public void aColumnsSurfaceOutsideTheSampledAreaIsRefusedLikeTheColumn() {
IrisTerrainSampler terrain = new IrisTerrainSampler(engine, null, 0, 0, CHUNK_REACH);
@@ -20,7 +20,6 @@ package art.arcane.iris.engine.mantle.components;
import art.arcane.iris.builtin.floating.FloatingChildBiome;
import art.arcane.iris.modules.floating.FloatingChildSettings;
import art.arcane.iris.builtin.floating.FloatingHost;
import art.arcane.iris.builtin.objects.ObjectPlacement;
import art.arcane.iris.engine.object.TestSettings;
import com.volmit.geometry.BlockBox;
@@ -60,7 +59,6 @@ public class FloatingObjectPlacingBoundaryRadiusTest {
}
private static PackSettings pack(FloatingChildSettings declared, PackResources resources) {
FloatingHost floating = mock(FloatingHost.class);
return new PackSettings() {
@Override
@SuppressWarnings("unchecked")
@@ -71,7 +69,7 @@ public class FloatingObjectPlacingBoundaryRadiusTest {
@Override
public <T> Optional<T> extension(Class<T> type) {
return type == FloatingHost.class ? Optional.of(type.cast(floating)) : Optional.empty();
return Optional.empty();
}
@Override
@@ -24,7 +24,6 @@ import art.arcane.volmlib.util.matter.Matter;
import com.volmit.noise.NoiseSampler;
import art.arcane.iris.builtin.IrisStages;
import art.arcane.iris.builtin.IrisSeedPurposes;
import art.arcane.iris.builtin.floating.FloatingHost;
import art.arcane.iris.builtin.LegacyStreams;
import com.volmit.block.BlockTurn;
import com.volmit.object.PackObjects;
@@ -497,6 +496,16 @@ public final class ApiChunk implements GenerationContext {
return fluidHeight;
}
@Override
public double biomeHeight(ResourceId biome, int worldX, int worldZ, long seed) {
throw new UnsupportedOperationException("This chunk has no floating islands to shape");
}
@Override
public Optional<ResourceId> skyBiome(ResourceId biome, int worldX, int worldZ) {
throw new UnsupportedOperationException("This chunk has no floating islands to paint sky biomes for");
}
@Override
public OptionalInt upperDimensionY(int worldX, int worldZ) {
requireInside(worldX, worldZ);
@@ -548,6 +557,11 @@ public final class ApiChunk implements GenerationContext {
public MantleEdit edit() {
throw new UnsupportedOperationException("Chunk stages do not edit the mantle");
}
@Override
public void setPlatformBiome(int x, int y, int z, ResourceId biome) {
throw new UnsupportedOperationException("This chunk has no floating islands to paint sky biomes for");
}
}
private final class PlannedLayer implements MantleLayer<BlockState> {
@@ -593,7 +607,6 @@ public final class ApiChunk implements GenerationContext {
private final class World implements PackWorld {
private final Resources resources = new Resources();
private final Map<Class<?>, Object> states = new HashMap<>();
private final FloatingHost floating = mock(FloatingHost.class);
private final LegacyStreams streams = mock(LegacyStreams.class);
private final Placements placements = mock(Placements.class);
private final RunningWorld running = mock(RunningWorld.class);
@@ -607,7 +620,7 @@ public final class ApiChunk implements GenerationContext {
@Override
public <T> Optional<T> extension(Class<T> type) {
Object offered = type == FloatingHost.class ? floating : type == LegacyStreams.class ? streams : null;
Object offered = type == LegacyStreams.class ? streams : null;
return Optional.ofNullable(offered).map(type::cast);
}
@@ -160,5 +160,15 @@ public class CaveApplyingBoundarySupportTest {
public Optional<UpperDimension> upperDimension() {
throw new UnsupportedOperationException();
}
@Override
public double biomeHeight(ResourceId biome, int worldX, int worldZ, long seed) {
throw new UnsupportedOperationException();
}
@Override
public Optional<ResourceId> skyBiome(ResourceId biome, int worldX, int worldZ) {
throw new UnsupportedOperationException();
}
}
}
@@ -1,6 +1,5 @@
package art.arcane.iris.engine.modifier;
import art.arcane.iris.builtin.floating.FloatingHost;
import art.arcane.iris.builtin.LegacyStreams;
import art.arcane.iris.engine.decorator.BiomeDecorators;
import com.volmit.block.BlockState;
@@ -69,7 +68,6 @@ public class FloatingIslandsTest {
when(running.settings()).thenReturn(nothingDeclaredByBiomes);
PackWorld world = mock(PackWorld.class);
when(world.running()).thenReturn(Optional.of(running));
when(world.extension(FloatingHost.class)).thenReturn(Optional.of(mock(FloatingHost.class)));
when(world.extension(LegacyStreams.class)).thenReturn(Optional.of(mock(LegacyStreams.class)));
when(world.resources()).thenReturn(mock(PackResources.class));
PackSettings nothingDeclared = mock(PackSettings.class);
@@ -2,7 +2,6 @@ package art.arcane.iris.engine.object.terrain.floating;
import art.arcane.iris.builtin.carve.CarvingEntry;
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;
@@ -53,6 +52,6 @@ public class ResolvedFloatingChildCarvingResolutionTest {
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), resources, null, 0L, 0L, 0, dimensionCarving);
return new FloatingWorld(resources, null, 0L, 0L, 0, dimensionCarving);
}
}
@@ -4,10 +4,15 @@ import art.arcane.iris.engine.object.world.biome.IrisBiome;
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.biome.custom.IrisBiomeCustom;
import art.arcane.iris.util.project.noise.CNG;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.math.RNG;
import org.junit.Test;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -18,6 +23,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -97,6 +103,40 @@ public class IrisBiomeGeneratorSeedIsolationTest {
}
}
/** The floating islands' sky biome painting relies on this: with an engine, the random a caller passes never changes the pick. */
@Test
public void skyAndCustomBiomePicksIgnoreTheRandomWhenAnEngineIsGiven() {
Engine engine = engine(1337L);
IrisBiome first = scatteredBiome();
IrisBiome second = scatteredBiome();
Set<String> skyPicks = new HashSet<>();
Set<String> customPicks = new HashSet<>();
for (int x = -400; x <= 400; x += 40) {
for (int z = -400; z <= 400; z += 40) {
String sky = first.getSkyBiomeKey(new RNG(8457289L), engine, x, 0, z);
assertEquals(sky, second.getSkyBiomeKey(new RNG(-991245L), engine, x, 0, z));
String custom = first.getCustomBiome(new RNG(11L), engine, x, 0, z).getId();
assertEquals(custom, second.getCustomBiome(new RNG(99L), engine, x, 0, z).getId());
skyPicks.add(sky);
customPicks.add(custom);
}
}
assertTrue("the grid must reach more than one sky pick", skyPicks.size() > 1);
assertTrue("the grid must reach more than one custom pick", customPicks.size() > 1);
}
private IrisBiome scatteredBiome() {
IrisBiome biome = biome(null);
biome.setBiomeSkyScatter(new KList<>(List.of("plains", "desert", "taiga", "jungle")));
biome.setCustomDerivitives(new KList<>(List.of(
new IrisBiomeCustom().setId("first"),
new IrisBiomeCustom().setId("second"),
new IrisBiomeCustom().setId("third"))));
return biome;
}
@Test
public void biomeGeneratorCacheEvictsOldSeeds() {
IrisBiome biome = biome(null);