mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +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
@@ -58,6 +58,14 @@ public final class FluidSeams {
|
||||
return sealed;
|
||||
}
|
||||
|
||||
public static String fallingFluid(Map<String, String> seams, String source, String landing) {
|
||||
String seam = source == null ? null : seams.get(source);
|
||||
if (seam == null || source.equals(landing) || seam.equals(landing)) {
|
||||
return source;
|
||||
}
|
||||
return seam;
|
||||
}
|
||||
|
||||
private static boolean touchesOther(int cell, String[] fluid, Map<String, String> seams, byte[] sea, Columns columns,
|
||||
int originX, int originZ) {
|
||||
String own = fluid[cell];
|
||||
|
||||
@@ -7,6 +7,7 @@ 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.raster.FluidSeams;
|
||||
import art.arcane.iris.generation.hydrology.underground.CavePoolFiller;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInlet;
|
||||
import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
|
||||
@@ -21,6 +22,7 @@ import art.arcane.volmlib.util.matter.slices.UpdateMatter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ComponentFlag(ReservedFlag.RIVER_HYDROLOGY)
|
||||
public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
@@ -119,7 +121,7 @@ public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
complex.effectiveWaterHeads(chunkX, chunkZ, around, heads);
|
||||
Falls falls = plan(chunkX, chunkZ, writer.getMantle().getWorldHeight(), heads);
|
||||
if (falls != null) {
|
||||
publish(writer, complex, around, falls);
|
||||
publish(writer, complex, runtime.settings().seams(), around, falls);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +165,7 @@ public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
return bottom == null ? null : new Falls(chunkX, chunkZ, bottom, top, source);
|
||||
}
|
||||
|
||||
private static void publish(MantleWriter writer, IrisComplex complex, ChunkWaterRaster[] around, Falls falls) {
|
||||
private static void publish(MantleWriter writer, IrisComplex complex, Map<String, String> seams, ChunkWaterRaster[] around, Falls falls) {
|
||||
SubterrainPlanner planner = complex.getSubterrainPlanner();
|
||||
boolean features = planner != null && !planner.isEmpty();
|
||||
int minimumY = features ? writer.getEngine().getWorld().minHeight() : 0;
|
||||
@@ -176,7 +178,8 @@ public final class MantleHydrologyComponent extends IrisMantleComponent {
|
||||
int sourceX = falls.sourceX(index);
|
||||
int sourceZ = falls.sourceZ(index);
|
||||
ChunkWaterRaster sourceRaster = around[((sourceZ >> 4) - falls.chunkZ() + 1) * 3 + (sourceX >> 4) - falls.chunkX() + 1];
|
||||
NativeBlockState falling = fallingFluidState(complex.resolveWaterFluid(sourceRaster.fluid(sourceX & 15, sourceZ & 15), sourceX, sourceZ));
|
||||
String profile = FluidSeams.fallingFluid(seams, sourceRaster.fluid(sourceX & 15, sourceZ & 15), around[4].fluid(x & 15, z & 15));
|
||||
NativeBlockState falling = fallingFluidState(complex.resolveWaterFluid(profile, sourceX, sourceZ));
|
||||
for (int y = falls.bottom()[index]; y <= falls.top()[index]; y++) {
|
||||
if (features && planner.sample(x, y + minimumY, z).owned()) {
|
||||
continue;
|
||||
|
||||
+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