mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 09:15:27 +00:00
Seamed lava falls
- Add FluidSeams.fallingFluid: a fluid with a seam falls as its seam where it lands on a different fluid - Take the falling fluid in MantleHydrologyComponent from that rule, so lava stepping into its estuary or a water river falls as its seam - Cover the rule, the mantle falls onto sea, water and lava, and a lava reach dropping into its estuary
This commit is contained in:
1 parent
b17ad570ca
commit
904c889c2f
5 files changed
+110
-8
No files matched your search
+52
-5
@@ -1154,17 +1154,64 @@ public class ChunkWaterRasterTest {
|
||||
|
||||
@Test
|
||||
public void lavaMouthMeetsTheSeaThroughTheSeam() {
|
||||
HydrologySettings settings = settings(lavaAndCrust());
|
||||
IntBinaryOperator coast = (x, z) -> x < 40 ? 44 : SEA_LEVEL - 3;
|
||||
Reach river = mouthed(line(131L, lavaTier(), 0L, -20f, 8f, 56f, 8f, (x, z) -> x < 40f ? 42 : SEA_LEVEL), 40f);
|
||||
assertLavaSealedFromTheSea(new Scene(settings, coast).reach(river), settings, coast);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lavaFallingIntoItsEstuaryFallsAsTheSeam() {
|
||||
HydrologySettings settings = settings(lavaAndCrust());
|
||||
IntBinaryOperator coast = (x, z) -> x < 40 ? 46 : SEA_LEVEL - 3;
|
||||
Reach river = mouthed(line(132L, lavaTier(), 0L, -20f, 8f, 56f, 8f, (x, z) -> x < 40f ? SEA_LEVEL + 4 : SEA_LEVEL), 40f);
|
||||
Scene scene = new Scene(settings, coast).reach(river);
|
||||
assertLavaSealedFromTheSea(scene, settings, coast);
|
||||
int[][] sides = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
int ontoTheSea = 0;
|
||||
for (int x = -16; x <= 52; x++) {
|
||||
for (int z = -8; z <= 24; z++) {
|
||||
if (!scene.water(x, z)) {
|
||||
continue;
|
||||
}
|
||||
int head = scene.head(x, z);
|
||||
int[] source = null;
|
||||
for (int[] side : sides) {
|
||||
if (scene.water(x + side[0], z + side[1]) && scene.head(x + side[0], z + side[1]) > head) {
|
||||
head = scene.head(x + side[0], z + side[1]);
|
||||
source = side;
|
||||
}
|
||||
}
|
||||
if (source == null) {
|
||||
continue;
|
||||
}
|
||||
String landing = scene.fluid(x, z);
|
||||
String falling = FluidSeams.fallingFluid(settings.seams(), scene.fluid(x + source[0], z + source[1]), landing);
|
||||
if (HydrologyCaveCell.SEA_FLUID.equals(landing)) {
|
||||
ontoTheSea++;
|
||||
assertEquals("lava falls into the estuary at " + x + "," + z + " as its seam", "crust", falling);
|
||||
}
|
||||
assertTrue("raw lava falls onto " + landing + " at " + x + "," + z, !falling.equals("lava") || landing.equals("lava"));
|
||||
}
|
||||
}
|
||||
assertTrue("falls into the estuary " + ontoTheSea, ontoTheSea > 0);
|
||||
}
|
||||
|
||||
private static IrisHydrology lavaAndCrust() {
|
||||
IrisHydrology config = new IrisHydrology();
|
||||
config.getFluids().add(new IrisFluidProfile().setName("lava").setSeam("crust")
|
||||
.setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava")));
|
||||
config.getFluids().add(new IrisFluidProfile().setName("crust")
|
||||
.setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:obsidian")));
|
||||
HydrologySettings settings = settings(config);
|
||||
HydrologyTier lava = new HydrologyTier("lava", 0f, 1.5f, 1.5f, 0f, 0.5f, 1, true, 6, 8, IrisBankStyle.SMOOTH,
|
||||
return config;
|
||||
}
|
||||
|
||||
private static HydrologyTier lavaTier() {
|
||||
return new HydrologyTier("lava", 0f, 1.5f, 1.5f, 0f, 0.5f, 1, true, 6, 8, IrisBankStyle.SMOOTH,
|
||||
new HydrologyTier.Estuary(48, 2.5f), new IrisHydrologyMaterials(), "lava", List.of());
|
||||
IntBinaryOperator coast = (x, z) -> x < 40 ? 44 : SEA_LEVEL - 3;
|
||||
Reach river = mouthed(line(131L, lava, 0L, -20f, 8f, 56f, 8f, (x, z) -> x < 40f ? 42 : SEA_LEVEL), 40f);
|
||||
Scene scene = new Scene(settings, coast).reach(river);
|
||||
}
|
||||
|
||||
private static void assertLavaSealedFromTheSea(Scene scene, HydrologySettings settings, IntBinaryOperator coast) {
|
||||
FluidSeams.Columns columns = new FluidSeams.Columns() {
|
||||
@Override
|
||||
public String fluid(int x, int z) {
|
||||
|
||||
@@ -71,6 +71,16 @@ public class FluidSeamsTest {
|
||||
assertNull(FluidSeams.seal(LAVA_CRUST, SEED, 6, 0, columns(x -> x < 100 ? "lava" : "crust", x -> false)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fallingFluidTakesItsSeamWhereItLandsOnAnotherFluid() {
|
||||
assertEquals("crust", FluidSeams.fallingFluid(LAVA_CRUST, "lava", "@sea"));
|
||||
assertEquals("crust", FluidSeams.fallingFluid(LAVA_CRUST, "lava", "water"));
|
||||
assertEquals("lava", FluidSeams.fallingFluid(LAVA_CRUST, "lava", "lava"));
|
||||
assertEquals("lava", FluidSeams.fallingFluid(LAVA_CRUST, "lava", "crust"));
|
||||
assertEquals("water", FluidSeams.fallingFluid(LAVA_CRUST, "water", "lava"));
|
||||
assertEquals("lava", FluidSeams.fallingFluid(Map.of(), "lava", "@sea"));
|
||||
}
|
||||
|
||||
private static FluidSeams.Columns columns(IntFunction<String> fluid, IntPredicate sea) {
|
||||
return new FluidSeams.Columns() {
|
||||
@Override
|
||||
|
||||
+34
@@ -3,8 +3,10 @@ package art.arcane.iris.generation.mantle;
|
||||
import art.arcane.iris.generation.context.ChunkContext;
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveAction;
|
||||
import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisFluidProfile;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
@@ -13,6 +15,7 @@ import art.arcane.iris.generation.subterrain.SubterrainCell;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainPlan;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainPlanner;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.world.IrisWorld;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.mantle.flag.ReservedFlag;
|
||||
@@ -189,6 +192,36 @@ public class MantleHydrologyComponentTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lavaFallingOntoOtherWaterFallsAsItsSeam() {
|
||||
IrisHydrology lavaAndCrust = new IrisHydrology();
|
||||
lavaAndCrust.getFluids().add(new IrisFluidProfile().setName("lava").setSeam("crust")
|
||||
.setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava")));
|
||||
lavaAndCrust.getFluids().add(new IrisFluidProfile().setName("crust")
|
||||
.setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:obsidian")));
|
||||
HydrologySettings settings = HydrologySettings.compile(lavaAndCrust, 1L, 62, 0, WORLD_HEIGHT);
|
||||
for (String landing : List.of(HydrologyCaveCell.SEA_FLUID, "water", "lava")) {
|
||||
NativeBlockState lava = mock(NativeBlockState.class);
|
||||
NativeBlockState crust = mock(NativeBlockState.class);
|
||||
ChunkWaterRaster raster = wetRaster();
|
||||
when(raster.fluid(anyInt(), anyInt())).thenAnswer(call -> call.<Integer>getArgument(0) < 6 ? "lava" : landing);
|
||||
Fixture fixture = new Fixture(raster, channel((x, z) -> x < 6 ? 99 : 79));
|
||||
when(fixture.runtime.settings()).thenReturn(settings);
|
||||
when(fixture.complex.resolveWaterFluid(eq("lava"), anyInt(), anyInt())).thenReturn(lava);
|
||||
when(fixture.complex.resolveWaterFluid(eq("crust"), anyInt(), anyInt())).thenReturn(crust);
|
||||
|
||||
fixture.generate();
|
||||
|
||||
NativeBlockState expected = landing.equals("lava") ? lava : crust;
|
||||
for (int z = 4; z <= 7; z++) {
|
||||
for (int y = 80; y <= 99; y++) {
|
||||
verify(fixture.writer).setData(6, y, z, expected);
|
||||
}
|
||||
}
|
||||
verify(fixture.writer, times(4 * 20)).setData(anyInt(), anyInt(), anyInt(), any(NativeBlockState.class));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void chunksWithoutWaterNeverReadTheirNeighbours() {
|
||||
Fixture empty = new Fixture(ChunkWaterRaster.EMPTY, (x, z) -> 99);
|
||||
@@ -333,6 +366,7 @@ public class MantleHydrologyComponentTest {
|
||||
when(complex.allowsMantleChunkWrite(0, 0)).thenReturn(true);
|
||||
when(complex.getHydrologyRuntime()).thenReturn(runtime);
|
||||
when(runtime.raster(anyInt(), anyInt())).thenReturn(raster);
|
||||
when(runtime.settings()).thenReturn(HydrologySettings.compile(new IrisHydrology(), 1L, 62, 0, WORLD_HEIGHT));
|
||||
when(complex.resolveWaterFluid(anyString(), anyInt(), anyInt())).thenReturn(mock(NativeBlockState.class));
|
||||
doAnswer(call -> {
|
||||
int[] target = call.getArgument(3);
|
||||
|
||||
Reference in new issue
Block a user