mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Deep cave pool fluid
- cavePools.deepFluid fills pools at or below cavePools.deepFluidMaxY, default world Y -128, unset by default - A cave policy fluid still wins over the deep fluid - The mixed-fluid check stops a pool rising past the line, so no pool straddles it - CavePoolFiller takes the world minimum Y to place the line, and throws when the line is outside the world - Settings reject an unknown or seam deepFluid, and both knobs join the fingerprint - Default fingerprint and schema digest recaptured
This commit is contained in:
9 files changed
+172
-20
No files matched your search
+38
-1
@@ -33,7 +33,7 @@ public class HydrologySettingsTest {
|
||||
private static final int SEA_LEVEL = 62;
|
||||
private static final int MIN_Y = -64;
|
||||
private static final int MAX_Y = 320;
|
||||
private static final long DEFAULT_FINGERPRINT = 7576271788988330967L;
|
||||
private static final long DEFAULT_FINGERPRINT = 3280677091802284252L;
|
||||
|
||||
@Test
|
||||
public void densityIsBoundedAndChangesThePlanIdentity() {
|
||||
@@ -48,6 +48,43 @@ public class HydrologySettingsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deepFluidIsOptionalChangesThePlanIdentityAndMustBeAFillingFluid() {
|
||||
HydrologySettings plain = compile(new IrisHydrology());
|
||||
assertNull(plain.underground().cavePools().deepFluid());
|
||||
assertEquals(-128, plain.underground().cavePools().deepFluidMaxY());
|
||||
|
||||
IrisHydrology blank = new IrisHydrology();
|
||||
blank.getUnderground().getCavePools().setDeepFluid(" ");
|
||||
assertNull(compile(blank).underground().cavePools().deepFluid());
|
||||
assertEquals(plain.fingerprint(), compile(blank).fingerprint());
|
||||
|
||||
IrisHydrology deep = withLava(new IrisHydrology());
|
||||
deep.getUnderground().getCavePools().setDeepFluid("lava");
|
||||
HydrologySettings lava = compile(deep);
|
||||
assertEquals("lava", lava.underground().cavePools().deepFluid());
|
||||
IrisHydrology moved = withLava(new IrisHydrology());
|
||||
moved.getUnderground().getCavePools().setDeepFluid("lava").setDeepFluidMaxY(-64);
|
||||
assertTrue(lava.fingerprint() != compile(moved).fingerprint());
|
||||
assertTrue(compile(withLava(new IrisHydrology())).fingerprint() != lava.fingerprint());
|
||||
|
||||
IrisHydrology unknown = new IrisHydrology();
|
||||
unknown.getUnderground().getCavePools().setDeepFluid("magma");
|
||||
assertRejected(unknown, "underground.cavePools.deepFluid");
|
||||
IrisHydrology seam = withLava(new IrisHydrology());
|
||||
seam.getFluids().getFirst().setSeam("lava");
|
||||
seam.getUnderground().getCavePools().setDeepFluid("lava");
|
||||
assertRejected(seam, "underground.cavePools.deepFluid");
|
||||
IrisHydrology wild = withLava(new IrisHydrology());
|
||||
wild.getUnderground().getCavePools().setDeepFluid("lava").setDeepFluidMaxY(4000);
|
||||
assertRejected(wild, "underground.cavePools.deepFluidMaxY");
|
||||
}
|
||||
|
||||
private static IrisHydrology withLava(IrisHydrology config) {
|
||||
config.getFluids().add(new IrisFluidProfile().setName("lava").setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava")));
|
||||
return config;
|
||||
}
|
||||
|
||||
@Rule
|
||||
public final TemporaryFolder temporary = new TemporaryFolder();
|
||||
|
||||
|
||||
+94
-10
@@ -35,12 +35,13 @@ import static org.mockito.Mockito.when;
|
||||
public class CavePoolFillerTest {
|
||||
private static final long SEED = 1337L;
|
||||
private static final int FLOOR = 50;
|
||||
private static final int WORLD_MIN = -256;
|
||||
|
||||
@Test
|
||||
public void globalDensityThinsCandidateColumnsBeforeSamplingCaves() {
|
||||
IrisHydrology config = new IrisHydrology().setDensity(0.5D);
|
||||
config.getUnderground().getCavePools().setDensity(8D);
|
||||
CavePoolFiller filler = new CavePoolFiller(HydrologySettings.compile(config, SEED, 63, 0, 384));
|
||||
CavePoolFiller filler = new CavePoolFiller(HydrologySettings.compile(config, SEED, 63, 0, 384), 0);
|
||||
CarvedTerrain carved = mock(CarvedTerrain.class);
|
||||
MantleWriter writer = mock(MantleWriter.class);
|
||||
Set<Long> columns = new HashSet<>();
|
||||
@@ -67,7 +68,7 @@ public class CavePoolFillerTest {
|
||||
public void chunksWithoutAPoolSiteNeverOpenTheirCaves() {
|
||||
IrisHydrology config = new IrisHydrology().setDensity(0.5D);
|
||||
config.getUnderground().getCavePools().setDensity(0.05D);
|
||||
CavePoolFiller filler = new CavePoolFiller(HydrologySettings.compile(config, SEED, 63, 0, 384));
|
||||
CavePoolFiller filler = new CavePoolFiller(HydrologySettings.compile(config, SEED, 63, 0, 384), 0);
|
||||
CarvedTerrain carved = mock(CarvedTerrain.class);
|
||||
MantleWriter writer = mock(MantleWriter.class);
|
||||
AtomicInteger opened = new AtomicInteger();
|
||||
@@ -86,7 +87,7 @@ public class CavePoolFillerTest {
|
||||
public void zeroGlobalDensityDoesNotReadCaves() {
|
||||
IrisHydrology config = new IrisHydrology().setDensity(0D);
|
||||
config.getUnderground().getCavePools().setDensity(8D);
|
||||
CavePoolFiller filler = new CavePoolFiller(HydrologySettings.compile(config, SEED, 63, 0, 384));
|
||||
CavePoolFiller filler = new CavePoolFiller(HydrologySettings.compile(config, SEED, 63, 0, 384), 0);
|
||||
CarvedTerrain carved = mock(CarvedTerrain.class);
|
||||
MantleWriter writer = mock(MantleWriter.class);
|
||||
filler.fill(0, 0, () -> carved, writer, SEED);
|
||||
@@ -163,10 +164,10 @@ public class CavePoolFillerTest {
|
||||
MantleWriter forwardWriter = writer(forward);
|
||||
MantleWriter reverseWriter = writer(reverse);
|
||||
for (int index = 0; index < 9; index++) {
|
||||
new CavePoolFiller(settings).fill(index % 3 - 1, index / 3 - 1, () -> world, forwardWriter, SEED);
|
||||
new CavePoolFiller(settings, 0).fill(index % 3 - 1, index / 3 - 1, () -> world, forwardWriter, SEED);
|
||||
}
|
||||
for (int index = 8; index >= 0; index--) {
|
||||
new CavePoolFiller(settings).fill(index % 3 - 1, index / 3 - 1, () -> world, reverseWriter, SEED);
|
||||
new CavePoolFiller(settings, 0).fill(index % 3 - 1, index / 3 - 1, () -> world, reverseWriter, SEED);
|
||||
}
|
||||
|
||||
assertFalse(forward.isEmpty());
|
||||
@@ -197,10 +198,10 @@ public class CavePoolFillerTest {
|
||||
|
||||
Map<Long, HydrologyCaveCell> forward = new HashMap<>();
|
||||
Map<Long, HydrologyCaveCell> reverse = new HashMap<>();
|
||||
new CavePoolFiller(settings).fill(0, 0, () -> world, writer(forward), SEED);
|
||||
new CavePoolFiller(settings).fill(1, 0, () -> world, writer(forward), SEED);
|
||||
new CavePoolFiller(settings).fill(1, 0, () -> world, writer(reverse), SEED);
|
||||
new CavePoolFiller(settings).fill(0, 0, () -> world, writer(reverse), SEED);
|
||||
new CavePoolFiller(settings, 0).fill(0, 0, () -> world, writer(forward), SEED);
|
||||
new CavePoolFiller(settings, 0).fill(1, 0, () -> world, writer(forward), SEED);
|
||||
new CavePoolFiller(settings, 0).fill(1, 0, () -> world, writer(reverse), SEED);
|
||||
new CavePoolFiller(settings, 0).fill(0, 0, () -> world, writer(reverse), SEED);
|
||||
|
||||
assertFalse(wetCells(forward, "water").isEmpty());
|
||||
assertFalse(wetCells(forward, "lava").isEmpty());
|
||||
@@ -269,6 +270,72 @@ public class CavePoolFillerTest {
|
||||
}), unknown, 0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deepFluidFillsPoolsAtOrBelowTheLineInWorldHeight() {
|
||||
HydrologySettings below = deepSettings(52 + WORLD_MIN);
|
||||
Map<Long, HydrologyCaveCell> deep = fillAt(below, room(0, 15, 0, 15, FLOOR, 52), 0, 0);
|
||||
assertEquals(roomCells(FLOOR, 52), wetCells(deep, "lava"));
|
||||
assertTrue(wetCells(deep, "water").isEmpty());
|
||||
|
||||
HydrologySettings above = deepSettings(FLOOR - 1 + WORLD_MIN);
|
||||
Map<Long, HydrologyCaveCell> shallow = fillAt(above, room(0, 15, 0, 15, FLOOR, 52), 0, 0);
|
||||
assertEquals(roomCells(FLOOR, 52), wetCells(shallow, "water"));
|
||||
assertTrue(wetCells(shallow, "lava").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void poolReachingTheLineStopsAtItAndNeverStraddles() {
|
||||
HydrologySettings settings = deepSettings(51 + WORLD_MIN);
|
||||
Map<Long, HydrologyCaveCell> written = fillAt(settings, roomWithSill(), 0, 0);
|
||||
assertEquals(roomCells(FLOOR, 51), wetCells(written, "lava"));
|
||||
assertTrue(wetCells(written, "water").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unsetDeepFluidKeepsThePoolFluidAtAnyDepth() {
|
||||
Map<Long, HydrologyCaveCell> written = fillAt(settings(pools -> pools.setFreeboard(new KList<>(0, 0)).setDeepFluidMaxY(300)),
|
||||
roomWithSill(), 0, 0);
|
||||
assertEquals(roomCells(FLOOR, 52), wetCells(written, "water"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cavePolicyWinsOverTheDeepFluid() {
|
||||
VoxelWorld world = roomWithSill();
|
||||
world.policyFluid(x -> "water");
|
||||
Map<Long, HydrologyCaveCell> written = fillAt(deepSettings(52 + WORLD_MIN), world, 0, 0);
|
||||
assertEquals(roomCells(FLOOR, 52), wetCells(written, "water"));
|
||||
assertTrue(wetCells(written, "lava").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deepAndShallowPoolsOverOneAnotherShareOnlyRockWhateverTheChunkOrder() {
|
||||
VoxelWorld world = room(0, 15, 0, 15, FLOOR, 52);
|
||||
world.carve(0, 15, 0, 15, 54, 57);
|
||||
world.carve(16, 16, 8, 8, 57, 58);
|
||||
HydrologySettings settings = HydrologySettings.compile(deepConfig(52 + WORLD_MIN, 8D), SEED, 63, 0, 512);
|
||||
Map<Long, HydrologyCaveCell> forward = new HashMap<>();
|
||||
Map<Long, HydrologyCaveCell> reverse = new HashMap<>();
|
||||
new CavePoolFiller(settings, WORLD_MIN).fill(0, 0, () -> world, writer(forward), SEED);
|
||||
new CavePoolFiller(settings, WORLD_MIN).fill(1, 0, () -> world, writer(forward), SEED);
|
||||
new CavePoolFiller(settings, WORLD_MIN).fill(1, 0, () -> world, writer(reverse), SEED);
|
||||
new CavePoolFiller(settings, WORLD_MIN).fill(0, 0, () -> world, writer(reverse), SEED);
|
||||
|
||||
assertFalse(wetCells(forward, "lava").isEmpty());
|
||||
assertFalse(wetCells(forward, "water").isEmpty());
|
||||
assertGuard(forward, 8, 53, 8);
|
||||
assertEquals(forward, reverse);
|
||||
assertNoMixedBodies(forward);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deepFluidLineOutsideTheWorldFailsClosed() {
|
||||
HydrologySettings below = deepSettings(WORLD_MIN - 1);
|
||||
assertThrows(IllegalStateException.class, () -> new CavePoolFiller(below, WORLD_MIN));
|
||||
HydrologySettings above = deepSettings(WORLD_MIN + 512);
|
||||
assertThrows(IllegalStateException.class, () -> new CavePoolFiller(above, WORLD_MIN));
|
||||
new CavePoolFiller(deepSettings(WORLD_MIN + 511), WORLD_MIN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foreignCellsAndDisabledPoolsWriteNothing() {
|
||||
VoxelWorld feature = roomWithSill();
|
||||
@@ -324,7 +391,7 @@ public class CavePoolFillerTest {
|
||||
|
||||
private static Map<Long, HydrologyCaveCell> fill(HydrologySettings settings, VoxelWorld world, int chunkX, int chunkZ) {
|
||||
Map<Long, HydrologyCaveCell> written = new HashMap<>();
|
||||
new CavePoolFiller(settings).fill(chunkX, chunkZ, () -> world, writer(written), SEED);
|
||||
new CavePoolFiller(settings, 0).fill(chunkX, chunkZ, () -> world, writer(written), SEED);
|
||||
return written;
|
||||
}
|
||||
|
||||
@@ -350,6 +417,23 @@ public class CavePoolFillerTest {
|
||||
return HydrologySettings.compile(config, SEED, 63, 0, 384);
|
||||
}
|
||||
|
||||
private static IrisHydrology deepConfig(int deepFluidMaxY, double density) {
|
||||
IrisHydrology config = new IrisHydrology().setEnabled(true);
|
||||
config.getFluids().add(new IrisFluidProfile().setName("lava").setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava")));
|
||||
config.getUnderground().getCavePools().setDensity(density).setFreeboard(new KList<>(0, 0)).setDeepFluid("lava").setDeepFluidMaxY(deepFluidMaxY);
|
||||
return config;
|
||||
}
|
||||
|
||||
private static HydrologySettings deepSettings(int deepFluidMaxY) {
|
||||
return HydrologySettings.compile(deepConfig(deepFluidMaxY, 1D), SEED, 63, 0, 512);
|
||||
}
|
||||
|
||||
private static Map<Long, HydrologyCaveCell> fillAt(HydrologySettings settings, VoxelWorld world, int chunkX, int chunkZ) {
|
||||
Map<Long, HydrologyCaveCell> written = new HashMap<>();
|
||||
new CavePoolFiller(settings, WORLD_MIN).fill(chunkX, chunkZ, () -> world, writer(written), SEED);
|
||||
return written;
|
||||
}
|
||||
|
||||
private static Set<Long> wetCells(Map<Long, HydrologyCaveCell> written, String fluid) {
|
||||
Set<Long> cells = new HashSet<>();
|
||||
for (Map.Entry<Long, HydrologyCaveCell> entry : written.entrySet()) {
|
||||
|
||||
@@ -456,7 +456,7 @@ public class MantleCarvedTerrainTest {
|
||||
rasterizer.write(inlet, 0, chunkZ, writer, HydrologyCaveCell.SEA_FLUID, SeaInletRasterizer.SubterrainFluid.NOWHERE,
|
||||
SeaInletRasterizer.HistoricalChunks.NONE);
|
||||
}
|
||||
new CavePoolFiller(settings).fill(0, chunkZ, () -> new MantleCarvedTerrain(writer, complex, engine, 0, chunkZ), writer, SEED);
|
||||
new CavePoolFiller(settings, 0).fill(0, chunkZ, () -> new MantleCarvedTerrain(writer, complex, engine, 0, chunkZ), writer, SEED);
|
||||
}
|
||||
return cells;
|
||||
}
|
||||
|
||||
+1
-1
@@ -306,7 +306,7 @@ public class IrisCarveModifierHydrologyTest {
|
||||
IrisHydrology config = new IrisHydrology().setEnabled(true);
|
||||
config.getUnderground().getCavePools().setDensity(1D).setFreeboard(new KList<>(0, 0));
|
||||
Map<Long, HydrologyCaveCell> written = new HashMap<>();
|
||||
new CavePoolFiller(HydrologySettings.compile(config, SEED, 63, 0, 384))
|
||||
new CavePoolFiller(HydrologySettings.compile(config, SEED, 63, 0, 384), 0)
|
||||
.fill(0, 0, SealedRoom::new, recordingWriter(written), SEED);
|
||||
Matter[] sections = new Matter[SECTIONS];
|
||||
Set<String> wallFluids = new HashSet<>();
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
|
||||
@ClassRule
|
||||
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
|
||||
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "c87139f807de29aa444923b6b0a1f85dc8de882ea8cf13ea3818fbdaeb352ae6";
|
||||
private static final String EXPECTED_SCHEMA_DIGEST = "f88d6e65ab17d253dbfb816c1d6e69fdcd600ff0318c6285ce08d7228ae6f51a";
|
||||
|
||||
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
|
||||
IrisDimension.class,
|
||||
|
||||
Reference in new issue
Block a user