mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-12 03:24:14 +00:00
Fixed cave biome identity
- Missing cave biome identities use the column surface biome - Capture tests cover omitted caves, configured caves, and invalid surface keys - Runtime scope tests retain keyed cave biome fixtures
This commit is contained in:
@@ -331,7 +331,8 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
|||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
default IrisBiome getCaveBiome(int x, int z) {
|
default IrisBiome getCaveBiome(int x, int z) {
|
||||||
return getComplex().getCaveBiomeStream().get(x, z);
|
IrisBiome biome = getComplex().getCaveBiomeStream().get(x, z);
|
||||||
|
return biome == null || biome.getLoadKey() == null ? getSurfaceBiome(x, z) : biome;
|
||||||
}
|
}
|
||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ public class IrisEngineGenerationRuntimeScopeTest {
|
|||||||
when(context.getComplex()).thenReturn(selected.complex);
|
when(context.getComplex()).thenReturn(selected.complex);
|
||||||
when(context.isNaturalTerrain()).thenReturn(true);
|
when(context.isNaturalTerrain()).thenReturn(true);
|
||||||
IrisBiome cave = mock(IrisBiome.class);
|
IrisBiome cave = mock(IrisBiome.class);
|
||||||
|
when(cave.getLoadKey()).thenReturn("cave");
|
||||||
IrisBiome surface = mock(IrisBiome.class);
|
IrisBiome surface = mock(IrisBiome.class);
|
||||||
ProceduralStream<IrisBiome> caves = mock(ProceduralStream.class);
|
ProceduralStream<IrisBiome> caves = mock(ProceduralStream.class);
|
||||||
ProceduralStream<IrisBiome> surfaces = mock(ProceduralStream.class);
|
ProceduralStream<IrisBiome> surfaces = mock(ProceduralStream.class);
|
||||||
@@ -139,6 +140,9 @@ public class IrisEngineGenerationRuntimeScopeTest {
|
|||||||
when(router.biomes()).thenReturn(mock(SavedBiomeRuntime.class));
|
when(router.biomes()).thenReturn(mock(SavedBiomeRuntime.class));
|
||||||
setField(engine, "generationHistoryRuntimeRouter", router);
|
setField(engine, "generationHistoryRuntimeRouter", router);
|
||||||
ProceduralStream<IrisBiome> caves = mock(ProceduralStream.class);
|
ProceduralStream<IrisBiome> caves = mock(ProceduralStream.class);
|
||||||
|
IrisBiome cave = mock(IrisBiome.class);
|
||||||
|
when(cave.getLoadKey()).thenReturn("cave");
|
||||||
|
when(caves.get(19D, -3D)).thenReturn(cave);
|
||||||
when(active.complex.getCaveBiomeStream()).thenReturn(caves);
|
when(active.complex.getCaveBiomeStream()).thenReturn(caves);
|
||||||
when(selected.complex.getCaveBiomeStream()).thenReturn(caves);
|
when(selected.complex.getCaveBiomeStream()).thenReturn(caves);
|
||||||
doCallRealMethod().when(active.complex).isNaturalTerrainContext();
|
doCallRealMethod().when(active.complex).isNaturalTerrainContext();
|
||||||
@@ -175,6 +179,7 @@ public class IrisEngineGenerationRuntimeScopeTest {
|
|||||||
when(context.getComplex()).thenReturn(active.complex);
|
when(context.getComplex()).thenReturn(active.complex);
|
||||||
when(context.isNaturalTerrain()).thenReturn(false);
|
when(context.isNaturalTerrain()).thenReturn(false);
|
||||||
IrisBiome cave = mock(IrisBiome.class);
|
IrisBiome cave = mock(IrisBiome.class);
|
||||||
|
when(cave.getLoadKey()).thenReturn("cave");
|
||||||
IrisBiome surface = mock(IrisBiome.class);
|
IrisBiome surface = mock(IrisBiome.class);
|
||||||
IrisRegion region = mock(IrisRegion.class);
|
IrisRegion region = mock(IrisRegion.class);
|
||||||
ProceduralStream<IrisBiome> caves = mock(ProceduralStream.class);
|
ProceduralStream<IrisBiome> caves = mock(ProceduralStream.class);
|
||||||
|
|||||||
@@ -1,18 +1,77 @@
|
|||||||
package art.arcane.iris.engine.history;
|
package art.arcane.iris.engine.history;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.engine.object.InferredType;
|
||||||
import art.arcane.iris.engine.object.IrisBiome;
|
import art.arcane.iris.engine.object.IrisBiome;
|
||||||
import art.arcane.iris.engine.object.IrisRegion;
|
import art.arcane.iris.engine.object.IrisRegion;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||||
|
import static org.mockito.Mockito.doCallRealMethod;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verifyNoInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class SavedBiomeCaptureTest {
|
public class SavedBiomeCaptureTest {
|
||||||
|
@Test
|
||||||
|
public void capturesSurfaceIdentityAtEveryHeightWhenCaveBiomesAreOmitted() throws Exception {
|
||||||
|
IrisBiome surface = biome("flat");
|
||||||
|
IrisBiome emptyCave = new IrisBiome().setInferredType(InferredType.CAVE);
|
||||||
|
Engine engine = caveCaptureEngine(surface, emptyCave);
|
||||||
|
SavedBiomeRuntime historical = mock(SavedBiomeRuntime.class);
|
||||||
|
|
||||||
|
SavedBiomeChunk chunk = SavedBiomeCapture.capture(engine, stage(), historical, null);
|
||||||
|
|
||||||
|
SavedBiomeChunk.Cell expected = new SavedBiomeChunk.Cell(1L, "flat", "flat-region");
|
||||||
|
assertEquals(new SavedBiomeChunk.Header(-1, 2, 1L, -64, 16), chunk.header());
|
||||||
|
for (int x = 0; x < 16; x++) {
|
||||||
|
for (int z = 0; z < 16; z++) {
|
||||||
|
assertEquals(expected, chunk.surfaceAt(x, z));
|
||||||
|
assertEquals(expected, chunk.caveBaseAt(x, z));
|
||||||
|
assertEquals(1, chunk.column(x, z).vertical().size());
|
||||||
|
for (int y = -64; y < -48; y++) {
|
||||||
|
assertEquals(expected, chunk.biomeAt(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertSame(emptyCave, engine.getComplex().getCaveBiomeStream().get(-16D, 32D));
|
||||||
|
assertNull(emptyCave.getLoadKey());
|
||||||
|
assertTrue(emptyCave.getDecorators().isEmpty());
|
||||||
|
assertTrue(emptyCave.getStructures().isEmpty());
|
||||||
|
verifyNoInteractions(historical);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void retainsConfiguredCaveIdentityThroughTheEngineLookup() throws Exception {
|
||||||
|
IrisBiome surface = biome("flat");
|
||||||
|
IrisBiome cave = biome("configured-cave").setInferredType(InferredType.CAVE);
|
||||||
|
Engine engine = caveCaptureEngine(surface, cave);
|
||||||
|
|
||||||
|
SavedBiomeChunk chunk = SavedBiomeCapture.capture(engine, stage(), mock(SavedBiomeRuntime.class), null);
|
||||||
|
|
||||||
|
assertSame(cave, engine.getCaveBiome(-16, 32));
|
||||||
|
assertEquals("configured-cave", chunk.caveBaseAt(0, 0).biomeKey());
|
||||||
|
assertEquals("configured-cave", chunk.biomeAt(0, -64, 0).biomeKey());
|
||||||
|
assertEquals("configured-cave", chunk.biomeAt(0, -57, 0).biomeKey());
|
||||||
|
assertEquals("flat", chunk.biomeAt(0, -56, 0).biomeKey());
|
||||||
|
assertEquals("flat", chunk.surfaceAt(0, 0).biomeKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void stillRejectsAnUnkeyedSurfaceBiome() {
|
||||||
|
Engine engine = caveCaptureEngine(new IrisBiome(), new IrisBiome().setInferredType(InferredType.CAVE));
|
||||||
|
|
||||||
|
assertThrows(IllegalArgumentException.class,
|
||||||
|
() -> SavedBiomeCapture.capture(engine, stage(), mock(SavedBiomeRuntime.class), null));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void retainsFloatingChildIdentityWhenItSharesTheHostDerivative() throws Exception {
|
public void retainsFloatingChildIdentityWhenItSharesTheHostDerivative() throws Exception {
|
||||||
Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
||||||
@@ -92,6 +151,33 @@ public class SavedBiomeCaptureTest {
|
|||||||
verifyNoInteractions(historical);
|
verifyNoInteractions(historical);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Engine caveCaptureEngine(IrisBiome surface, IrisBiome cave) {
|
||||||
|
Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
||||||
|
IrisRegion region = region("flat-region");
|
||||||
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
|
when(engine.getHeight()).thenReturn(16);
|
||||||
|
when(engine.getHeight(anyInt(), anyInt())).thenReturn(8);
|
||||||
|
when(engine.getDimensionStackContext()).thenReturn(null);
|
||||||
|
when(engine.getComplex().getTransitionGenerationPlan()).thenReturn(null);
|
||||||
|
when(engine.getComplex().getCaveBiomeStream().get(anyDouble(), anyDouble())).thenReturn(cave);
|
||||||
|
when(engine.getRegion(anyInt(), anyInt())).thenReturn(region);
|
||||||
|
when(engine.getRegion(anyInt(), anyInt(), anyInt())).thenReturn(region);
|
||||||
|
when(engine.getSurfaceBiome(anyInt(), anyInt())).thenReturn(surface);
|
||||||
|
doCallRealMethod().when(engine).getCaveBiome(anyInt(), anyInt());
|
||||||
|
doCallRealMethod().when(engine).getBiomeOrMantle(anyInt(), anyInt(), anyInt());
|
||||||
|
when(engine.getCaveOrMantleBiome(anyInt(), anyInt(), anyInt()))
|
||||||
|
.thenAnswer(call -> engine.getCaveBiome(call.getArgument(0), call.getArgument(2)));
|
||||||
|
return engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GenerationHistory.GenerationStage stage() {
|
||||||
|
GenerationHistory.GenerationStage stage = mock(GenerationHistory.GenerationStage.class);
|
||||||
|
when(stage.chunkX()).thenReturn(-1);
|
||||||
|
when(stage.chunkZ()).thenReturn(2);
|
||||||
|
when(stage.activation()).thenReturn(GenerationActivation.initial("a".repeat(64), 1L));
|
||||||
|
return stage;
|
||||||
|
}
|
||||||
|
|
||||||
private static IrisBiome biome(String key) {
|
private static IrisBiome biome(String key) {
|
||||||
IrisBiome biome = new IrisBiome();
|
IrisBiome biome = new IrisBiome();
|
||||||
biome.setLoadKey(key);
|
biome.setLoadKey(key);
|
||||||
|
|||||||
Reference in New Issue
Block a user