Open water under falls

- Estuary and inlet columns that a higher neighbouring water column falls into skip the sea layers, so falling water lands in open sea water instead of spreading over sea ice
- Fall check compares the unclamped water head with the 4-neighbour wet heads, the rule the mantle uses to place falls
- IrisTerrainNormalActuatorHydrologyTest.aFallIntoAFrozenMouthLandsInOpenWater pins the open plunge and keeps ice beside level water and dry banks
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-02 06:30:26 -05:00
1 parent 2ddc9f1106
commit 2ed13f9b7f
2 files changed
+51 -5

No files matched your search

@@ -215,10 +215,8 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
IrisBiome biome = biomeCache.get(xf, zf);
IrisRegion region = regionCache.get(xf, zf);
int he = Math.min(chunkHeight, context.getRoundedHeight(xf, zf));
int surfaceFluidHeight = Math.min(
chunkHeight,
(int) Math.round(waterHeadStream.getDouble(realX, realZ))
);
int waterHead = (int) Math.round(waterHeadStream.getDouble(realX, realZ));
int surfaceFluidHeight = Math.min(chunkHeight, waterHead);
int hf = Math.max(surfaceFluidHeight, he);
if (hf < 0) {
return;
@@ -229,6 +227,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
boolean wet = role.wet();
boolean submerged = wet && he < surfaceFluidHeight;
boolean seaFloor = !wet || role == WaterRole.INLET || role == WaterRole.MOUTH;
boolean openUnderFall = wet && seaFloor && receivesFall(realX, realZ, waterHead);
IrisHydrologyMaterials materials = role == WaterRole.NONE || role == WaterRole.INLET ? null
: complex.resolveWaterMaterials(realX, realZ);
Terrain3DColumn terrainColumn = complex.terrainColumn(realX, realZ);
@@ -298,7 +297,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
fblocks,
fdepth,
fluid,
!seaFloor
!seaFloor || openUnderFall
));
continue;
}
@@ -364,6 +363,15 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
}
}
private boolean receivesFall(int realX, int realZ, int head) {
return fallsFrom(realX + 1, realZ, head) || fallsFrom(realX - 1, realZ, head)
|| fallsFrom(realX, realZ + 1, head) || fallsFrom(realX, realZ - 1, head);
}
private boolean fallsFrom(int realX, int realZ, int head) {
return waterRoleStream.get(realX, realZ).wet() && Math.round(waterHeadStream.getDouble(realX, realZ)) > head;
}
/**
* Paints the solid run from {@code top} down to {@code floor}, which lies below every biome
* layer, river material, mapped surface and cave ceiling of its span: only ores or rock land there.
@@ -189,6 +189,32 @@ public class IrisTerrainNormalActuatorHydrologyTest {
assertSame(frozenMouth.ice, frozenEstuary.get(0, HEAD, 0));
}
@Test
public void aFallIntoAFrozenMouthLandsInOpenWater() {
Painter fall = frozenMouth();
fall.neighbour(12, -4, WaterRole.CHANNEL, HEAD + 1);
Hunk<NativeBlockState> plunge = fall.paint();
for (int y = GROUND + 1; y <= HEAD; y++) {
assertSame("the fall lands in open sea water at y " + y, fall.sea, plunge.get(0, y, 0));
}
Painter level = frozenMouth();
level.neighbour(11, -3, WaterRole.CHANNEL, HEAD);
assertSame("water beside the mouth at its own level is no fall", level.ice, level.paint().get(0, HEAD, 0));
Painter dry = frozenMouth();
dry.neighbour(10, -4, WaterRole.BANK, HEAD + 4);
assertSame("a higher dry bank is no fall", dry.ice, dry.paint().get(0, HEAD, 0));
}
private static Painter frozenMouth() {
Painter painter = new Painter(WaterRole.MOUTH, HEAD);
when(painter.complex.resolveWaterFluid(11, -4)).thenReturn(painter.sea);
when(painter.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND);
painter.thickSeaLayers();
return painter;
}
@Test
public void dryColumnsBelowTheSeaKeepTheSeaFillAndItsLayers() {
for (WaterRole role : List.of(WaterRole.NONE, WaterRole.BANK, WaterRole.SHORE)) {
@@ -368,8 +394,12 @@ public class IrisTerrainNormalActuatorHydrologyTest {
private final NativeBlockState bed = state("minecraft:gravel_bed");
private final NativeBlockState shore = state("minecraft:clay");
private final NativeBlockState bank = state("minecraft:coarse_dirt");
private final WaterRole role;
private final int head;
private Painter(WaterRole role, int head) {
this.role = role;
this.head = head;
when(engine.getDimension()).thenReturn(dimension);
when(engine.getComplex()).thenReturn(complex);
when(engine.getData()).thenReturn(data);
@@ -392,6 +422,14 @@ public class IrisTerrainNormalActuatorHydrologyTest {
layers(grass, dirt);
}
private void neighbour(int neighbourX, int neighbourZ, WaterRole neighbourRole, int neighbourHead) {
when(complex.getWaterHeadStream()).thenReturn(ProceduralStream.ofDouble((x, z) ->
(int) Math.floor(x) == neighbourX && (int) Math.floor(z) == neighbourZ ? neighbourHead : (double) head));
when(complex.getWaterRoleStream()).thenReturn(ProceduralStream.of((x, z) ->
(int) Math.floor(x) == neighbourX && (int) Math.floor(z) == neighbourZ ? neighbourRole : role,
Interpolated.of(value -> 0D, value -> role)));
}
private void thickSeaLayers() {
when(biome.generateSeaLayers(anyDouble(), anyDouble(), any(RNG.class), anyInt(), eq(data))).thenAnswer(invocation -> {
KList<NativeBlockState> layers = new KList<>();