mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 01:34:04 +00:00
Fall and estuary check fixes
- missingSurface: a sea-floor head under sea layers or sea decoration holds its cover or its own planned fluid, so a wrong fluid at a frozen estuary or inlet head fails again (R76). - Column parity test mirrors the open-water-under-a-fall rule with a random 4-neighbour of its own head and role, guarding the actuator against drift from the mantle fall rule. - An inlet mouth under a fall keeps open sea water, and one without a fall keeps its sea layers. - bermOverCap still counts an over-cap wall beside a lake's outlet, which is never held.
This commit is contained in:
1 parent
6f3b96cfb3
commit
a21e59f53b
5 files changed
+86
-13
No files matched your search
+21
-4
@@ -116,6 +116,10 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
private final Map<String, NativeBlockState> palettes = new HashMap<>();
|
||||
private final int he;
|
||||
private final int surfaceFluid;
|
||||
private final int fallX;
|
||||
private final int fallZ;
|
||||
private final int fallHead;
|
||||
private final WaterRole fallRole;
|
||||
private final KList<IrisOreGenerator> biomeSurface = new KList<>();
|
||||
private final KList<IrisOreGenerator> biomeUnderground = new KList<>();
|
||||
private final KList<IrisOreGenerator> regionSurface = new KList<>();
|
||||
@@ -158,6 +162,12 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
dimensionOres.addAll(dimensionUnderground);
|
||||
dimension = new IrisDimension().setBedrock(bedrock).setHideOresForHiddenOre(false);
|
||||
dimension.setOres(dimensionOres);
|
||||
Random fall = new Random(31L * trial + 7L);
|
||||
int side = fall.nextInt(4);
|
||||
fallX = X + (side == 0 ? 1 : side == 1 ? -1 : 0);
|
||||
fallZ = Z + (side == 2 ? 1 : side == 3 ? -1 : 0);
|
||||
fallHead = surfaceFluid - 1 + fall.nextInt(5);
|
||||
fallRole = WaterRole.values()[fall.nextInt(WaterRole.values().length)];
|
||||
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
@@ -166,8 +176,9 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
IrisImageMapRuntime imageMap = mock(IrisImageMapRuntime.class);
|
||||
when(imageMap.sampleSurfaceBlock(anyDouble(), anyDouble())).thenReturn(mapped);
|
||||
when(complex.getImageMapRuntime()).thenReturn(imageMap);
|
||||
when(complex.getWaterHeadStream()).thenReturn(ProceduralStream.ofDouble((x, z) -> (double) surfaceFluid));
|
||||
when(complex.getWaterRoleStream()).thenReturn(ProceduralStream.of((x, z) -> role, Interpolated.of(value -> 0D, value -> role)));
|
||||
when(complex.getWaterHeadStream()).thenReturn(ProceduralStream.ofDouble((x, z) -> fallColumn(x, z) ? fallHead : (double) surfaceFluid));
|
||||
when(complex.getWaterRoleStream()).thenReturn(ProceduralStream.of((x, z) -> fallColumn(x, z) ? fallRole : role,
|
||||
Interpolated.of(value -> 0D, value -> role)));
|
||||
when(complex.resolveWaterMaterials(X, Z)).thenReturn(materials);
|
||||
when(complex.resolveWaterFluid(X, Z)).thenReturn(waterFluid);
|
||||
when(complex.naturalTrueHeight(X, Z)).thenReturn(he + 5);
|
||||
@@ -191,7 +202,12 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
when(biome.getSurfaceOreBands()).thenReturn(IrisOreBands.of(biomeSurface));
|
||||
when(biome.getUndergroundOreBands()).thenReturn(IrisOreBands.of(biomeUnderground));
|
||||
description = "he=" + he + " fluid=" + surfaceFluid + " bedrock=" + bedrock + " mapped=" + (mapped != null)
|
||||
+ " layers=" + layerCount + " column=" + terrainColumn + " role=" + role + " materials=" + materials;
|
||||
+ " layers=" + layerCount + " column=" + terrainColumn + " role=" + role + " materials=" + materials
|
||||
+ " neighbour=" + fallX + "," + fallZ + " " + fallRole + "@" + fallHead;
|
||||
}
|
||||
|
||||
private boolean fallColumn(double x, double z) {
|
||||
return (int) Math.floor(x) == fallX && (int) Math.floor(z) == fallZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -209,6 +225,7 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
NativeBlockState airState = B.getState("AIR");
|
||||
boolean wet = role.wet();
|
||||
boolean seaFloor = !wet || role == WaterRole.INLET || role == WaterRole.MOUTH;
|
||||
boolean openUnderFall = wet && seaFloor && fallRole.wet() && fallHead > surfaceFluid;
|
||||
IrisHydrologyMaterials materials = role == WaterRole.INLET ? null : this.materials;
|
||||
int he = Math.min(chunkHeight, this.he);
|
||||
int surfaceFluidHeight = Math.min(chunkHeight, this.surfaceFluid);
|
||||
@@ -279,7 +296,7 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
if (seaFloor && fblocks == null) {
|
||||
fblocks = biome.generateSeaLayers(realX, realZ, rng, hf - he, data);
|
||||
}
|
||||
h.setRaw(xf, i, zf, HydrologyFluidLayerSelector.select(fblocks, fdepth, columnFluid, !seaFloor));
|
||||
h.setRaw(xf, i, zf, HydrologyFluidLayerSelector.select(fblocks, fdepth, columnFluid, !seaFloor || openUnderFall));
|
||||
continue;
|
||||
}
|
||||
if (i <= he) {
|
||||
|
||||
+18
-5
@@ -191,24 +191,37 @@ public class IrisTerrainNormalActuatorHydrologyTest {
|
||||
|
||||
@Test
|
||||
public void aFallIntoAFrozenMouthLandsInOpenWater() {
|
||||
Painter fall = frozenMouth();
|
||||
Painter fall = frozenSeaFloor(WaterRole.MOUTH);
|
||||
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();
|
||||
Painter level = frozenSeaFloor(WaterRole.MOUTH);
|
||||
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();
|
||||
Painter dry = frozenSeaFloor(WaterRole.MOUTH);
|
||||
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);
|
||||
@Test
|
||||
public void aFallIntoAFrozenInletMouthLandsInOpenWater() {
|
||||
Painter fall = frozenSeaFloor(WaterRole.INLET);
|
||||
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 still = frozenSeaFloor(WaterRole.INLET);
|
||||
assertSame("an inlet mouth with no fall keeps its sea layers", still.ice, still.paint().get(0, HEAD, 0));
|
||||
}
|
||||
|
||||
private static Painter frozenSeaFloor(WaterRole role) {
|
||||
Painter painter = new Painter(role, HEAD);
|
||||
when(painter.complex.resolveWaterFluid(11, -4)).thenReturn(painter.sea);
|
||||
when(painter.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND);
|
||||
painter.thickSeaLayers();
|
||||
|
||||
@@ -27,6 +27,7 @@ final class HydrologyVoxels {
|
||||
static final byte CANE = 2;
|
||||
static final byte WATER = 16;
|
||||
static final byte LAVA = 32;
|
||||
static final byte SEA_COVER = 64;
|
||||
static final int NO_WATER = Integer.MIN_VALUE;
|
||||
static final int COLUMNS = 256;
|
||||
private static final int FLUID_LEVELS = 16;
|
||||
@@ -131,7 +132,14 @@ final class HydrologyVoxels {
|
||||
}
|
||||
|
||||
static byte plannedSurface(WaterRole role, boolean solidObject, boolean seaLayers, boolean seaDecoration, byte fluid) {
|
||||
return solidObject || seaFloor(role) && (seaLayers || seaDecoration) ? SOLID : fluid;
|
||||
if (solidObject) {
|
||||
return SOLID;
|
||||
}
|
||||
return seaFloor(role) && (seaLayers || seaDecoration) ? seaCover(fluid) : fluid;
|
||||
}
|
||||
|
||||
static byte seaCover(byte fluid) {
|
||||
return (byte) (SEA_COVER | fluid);
|
||||
}
|
||||
|
||||
static boolean decoratedBy(IrisBiome biome, NativeBlockState state, IrisData data) {
|
||||
@@ -247,7 +255,13 @@ final class HydrologyVoxels {
|
||||
}
|
||||
|
||||
private static boolean holdsSurface(byte planned, byte voxel) {
|
||||
return planned == SOLID ? voxel == SOLID || fluid(voxel) : sameFluid(planned, voxel);
|
||||
if (planned == SOLID) {
|
||||
return voxel == SOLID || fluid(voxel);
|
||||
}
|
||||
if ((planned & SEA_COVER) != 0) {
|
||||
return voxel == SOLID || sameFluid((byte) (planned & ~SEA_COVER), voxel);
|
||||
}
|
||||
return sameFluid(planned, voxel);
|
||||
}
|
||||
|
||||
private boolean opensSideways(Volume volume, int x, int y, int z) {
|
||||
|
||||
@@ -182,6 +182,9 @@ public class HydrologyMetricsTest {
|
||||
assertEquals(0L, berms(List.of(outlet), List.of(held), rasters, low));
|
||||
assertEquals(1L, berms(List.of(outlet), List.of(pond(10L, 51, square(0, 0, 2), 0L, 4, 4)), rasters(columns), low));
|
||||
assertEquals(1L, berms(List.of(outlet), List.of(pond(10L, 55, square(0, 0, 2), 3L, 4, 4)), rasters(columns), low));
|
||||
Pond lake = new Pond(10L, PondKind.LAKE, 51, 47, 4, 4, 52f, square(0, 0, 2), 3L, 0, "minecraft:water", 4, 4);
|
||||
assertEquals("a lake's outlet is never held, so its over-cap wall still counts", 1L,
|
||||
berms(List.of(outlet), List.of(lake), rasters(columns), low));
|
||||
columns.put(HydrologyVoxels.columnKey(10, 5), new Column(WaterRole.BANK, HydrologyVoxels.NO_WATER, head + 1, 3L));
|
||||
assertEquals(1L, berms(List.of(outlet), List.of(held), rasters(columns), low));
|
||||
}
|
||||
|
||||
@@ -176,9 +176,11 @@ public class HydrologyVoxelsTest {
|
||||
@Test
|
||||
public void seaFloorHeadsMayHoldTheSeaLayersOrTheDecorationOfTheSeaTheyJoin() {
|
||||
for (WaterRole role : new WaterRole[]{WaterRole.INLET, WaterRole.MOUTH}) {
|
||||
assertEquals(role.name(), HydrologyVoxels.SOLID, HydrologyVoxels.plannedSurface(role, false, true, false, HydrologyVoxels.WATER));
|
||||
assertEquals(role.name(), HydrologyVoxels.SOLID, HydrologyVoxels.plannedSurface(role, false, false, true, HydrologyVoxels.WATER));
|
||||
byte cover = HydrologyVoxels.seaCover(HydrologyVoxels.WATER);
|
||||
assertEquals(role.name(), cover, HydrologyVoxels.plannedSurface(role, false, true, false, HydrologyVoxels.WATER));
|
||||
assertEquals(role.name(), cover, HydrologyVoxels.plannedSurface(role, false, false, true, HydrologyVoxels.WATER));
|
||||
assertEquals(role.name(), HydrologyVoxels.WATER, HydrologyVoxels.plannedSurface(role, false, false, false, HydrologyVoxels.WATER));
|
||||
assertEquals(role.name(), HydrologyVoxels.SOLID, HydrologyVoxels.plannedSurface(role, true, true, false, HydrologyVoxels.WATER));
|
||||
}
|
||||
for (WaterRole role : new WaterRole[]{WaterRole.CHANNEL, WaterRole.POND, WaterRole.CASCADE, WaterRole.WATERFALL}) {
|
||||
assertEquals(role.name(), HydrologyVoxels.WATER, HydrologyVoxels.plannedSurface(role, false, true, true, HydrologyVoxels.WATER));
|
||||
@@ -187,6 +189,30 @@ public class HydrologyVoxelsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void seaFloorHeadsHoldTheirCoverOrTheirOwnFluid() {
|
||||
HydrologyVoxels.ChunkBlocks chunk = pond(10);
|
||||
for (int z = 3; z <= 5; z++) {
|
||||
for (int x = 3; x <= 5; x++) {
|
||||
chunk.heads()[(z << 4) | x] = 10;
|
||||
}
|
||||
}
|
||||
for (WaterRole role : new WaterRole[]{WaterRole.INLET, WaterRole.MOUTH}) {
|
||||
for (boolean layers : new boolean[]{true, false}) {
|
||||
String cover = role + (layers ? " under sea layers" : " under the sea's decoration");
|
||||
chunk.surfaces()[(4 << 4) | 4] = HydrologyVoxels.plannedSurface(role, false, layers, !layers, HydrologyVoxels.WATER);
|
||||
chunk.set(4, 10, 4, HydrologyVoxels.WATER);
|
||||
assertEquals("open water at the head of a " + cover, 0L, scan(volume(chunk)).missingSurfaces);
|
||||
chunk.set(4, 10, 4, HydrologyVoxels.SOLID);
|
||||
assertEquals("the cover at the head of a " + cover, 0L, scan(volume(chunk)).missingSurfaces);
|
||||
chunk.set(4, 10, 4, HydrologyVoxels.LAVA);
|
||||
HydrologyVoxels.WaterScan scan = scan(volume(chunk));
|
||||
assertEquals("the wrong fluid at the head of a " + cover, 1L, scan.missingSurfaces);
|
||||
assertEquals("missing planned surface at 4,10,4", scan.examples.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onlyBlocksTheBiomeDecoratesWithAreItsDecoration() {
|
||||
IrisData data = mock(IrisData.class);
|
||||
|
||||
Reference in new issue
Block a user