Gate pool and inlet leaks

- Count sea inlet added leaks as leak cells present only with inlets on
- Fail the cave pool gate on pool cells that are not still sources of their fluid
- Compare pool sources against the fluid each cell resolves to
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-01 20:42:33 -05:00
1 parent 1ae68646b4
commit 75d28d16b2
4 files changed
+90 -25

No files matched your search

@@ -1,12 +1,16 @@
package art.arcane.iris.probe;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import org.junit.Test;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class CavePoolChecksTest {
@Test
@@ -28,6 +32,30 @@ public class CavePoolChecksTest {
assertTrue(failing.line(), failing.line().startsWith("CAVE_POOL_GATE status=FAIL failures=37 "));
}
@Test
public void poolCellsThatDidNotStayStillSourcesOfTheirFluidFail() {
CavePoolProbe.Counts replaced = new CavePoolProbe.Counts(1, 1, 1, 1, Map.of(), List.of(), List.of(), Map.of(), 0, 0, 0, 0, 0, 0, 0, 0,
Map.of("water->minecraft:stone", 2, "lava->null", 1), List.of());
assertEquals(3L, replaced.failures());
assertEquals(3L, new CavePoolProbe.Gate(replaced, 0).failures());
}
@Test
public void poolSourcesMatchTheFluidTheCellResolvesTo() {
NativeBlockState water = fluid("minecraft:water", true);
NativeBlockState lava = fluid("minecraft:lava", false);
assertTrue(CavePoolProbe.source(fluid("minecraft:water", true), water));
assertTrue(CavePoolProbe.source(fluid("minecraft:water[level=0]", true), water));
assertFalse("flowing water is not a pool source", CavePoolProbe.source(fluid("minecraft:water[level=1]", true), water));
assertFalse("lava is not a water pool source", CavePoolProbe.source(fluid("minecraft:lava", false), water));
assertTrue(CavePoolProbe.source(fluid("minecraft:lava[level=0]", false), lava));
assertFalse(CavePoolProbe.source(fluid("minecraft:water", true), lava));
assertFalse(CavePoolProbe.source(null, water));
NativeBlockState stone = mock(NativeBlockState.class);
when(stone.key()).thenReturn("minecraft:stone");
assertFalse(CavePoolProbe.source(stone, water));
}
@Test
public void orderMismatchesCountChunksWhoseHashesDiffer() {
assertEquals(0, CavePoolProbe.compare(Map.of(1L, 10L, 2L, 20L), Map.of(2L, 20L, 1L, 10L)));
@@ -40,4 +68,12 @@ public class CavePoolChecksTest {
return new CavePoolProbe.Counts(1, 1, 1, 1, Map.of(), List.of(), List.of(), Map.of(), air, open, sky, foreign, waterlogged, gravity,
fluidAbove, gravityCeilings, Map.of(), List.of());
}
private static NativeBlockState fluid(String key, boolean water) {
NativeBlockState state = mock(NativeBlockState.class);
when(state.key()).thenReturn(key);
when(state.isFluid()).thenReturn(true);
when(state.isWater()).thenReturn(water);
return state;
}
}
@@ -4,6 +4,7 @@ import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import org.junit.Test;
import java.util.List;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -29,19 +30,32 @@ public class SeaInletChecksTest {
@Test
public void theGateFailsOnEveryCheckIncludingOrderSeaLevelAndAddedLeaks() {
SeaInletProbe.Checks clean = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 952L, List.of());
SeaInletProbe.Gate passing = new SeaInletProbe.Gate(clean, 0, 0, 7, 7);
SeaInletProbe.Gate passing = new SeaInletProbe.Gate(clean, 0, 0, 0);
assertEquals(0L, passing.failures());
assertTrue(passing.line(), passing.line().startsWith("SEA_INLET_GATE status=PASS failures=0 "));
assertEquals("inlets that remove natural leaks do not fail", 0L, new SeaInletProbe.Gate(clean, 0, 0, 5, 7).failures());
assertEquals(2L, new SeaInletProbe.Gate(clean, 0, 0, 9, 7).failures());
assertEquals(1L, new SeaInletProbe.Gate(clean, 1, 0, 7, 7).failures());
assertEquals(1L, new SeaInletProbe.Gate(clean, 0, 1, 7, 7).failures());
assertEquals(2L, new SeaInletProbe.Gate(clean, 0, 0, 2).failures());
assertEquals(1L, new SeaInletProbe.Gate(clean, 1, 0, 0).failures());
assertEquals(1L, new SeaInletProbe.Gate(clean, 0, 1, 0).failures());
SeaInletProbe.Checks breached = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 0L, 0L, List.of());
SeaInletProbe.Gate failing = new SeaInletProbe.Gate(breached, 0, 0, 0, 0);
SeaInletProbe.Gate failing = new SeaInletProbe.Gate(breached, 0, 0, 0);
assertEquals(4L, failing.failures());
assertTrue(failing.line(), failing.line().startsWith("SEA_INLET_GATE status=FAIL failures=4 "));
}
@Test
public void addedLeaksAreTheLeaksMissingWithoutInlets() {
long kept = SeaInletProbe.cellKey(10, 300, -20);
long removed = SeaInletProbe.cellKey(11, 300, -20);
long added = SeaInletProbe.cellKey(10, 301, -20);
assertEquals(0, SeaInletProbe.addedLeaks(Set.of(kept), Set.of(kept)));
assertEquals("inlets that remove natural leaks do not fail", 0, SeaInletProbe.addedLeaks(Set.of(kept), Set.of(kept, removed)));
assertEquals("a leak the inlets move counts although the totals match", 1, SeaInletProbe.addedLeaks(Set.of(kept, added),
Set.of(kept, removed)));
assertEquals(2, SeaInletProbe.addedLeaks(Set.of(added, removed), Set.of()));
assertNotEquals(SeaInletProbe.cellKey(-1, 300, 0), SeaInletProbe.cellKey(0, 300, -1));
assertNotEquals(SeaInletProbe.cellKey(5, 0, 5), SeaInletProbe.cellKey(5, 4095, 5));
}
@Test
public void inletCellsAreClassifiedAgainstTheDimensionSeaFluid() {
assertEquals(SeaInletProbe.classify(state("minecraft:water"), "minecraft:water"), SeaInletProbe.classify(state("minecraft:lava"),