mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 17:54:56 +00:00
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:
1 parent
c0ed5ed81e
commit
7471f9fc42
15 files changed
+215
-89
No files matched your search
@@ -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);
|
||||
|
||||
+1
-3
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -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);
|
||||
|
||||
+1
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
+40
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user