Tidal inlet settings

- Replace cliff, width, headroom, roof and chamber knobs with funnel, bank and meander knobs
- Bound the new knobs at compile, with a reach guard against the window size
- Add them to the fingerprint and recapture the pinned fingerprint and schema digest
- Hold the old planner's retired values as constants until the planner is replaced
This commit is contained in:
Brian Fopiano committed 2026-11-03 14:18:44 -05:00
1 parent b0747d7483
commit 10fccd68f3
11 files changed
+182 -204

No files matched your search

@@ -33,7 +33,7 @@ public class IrisHydrologyDefaultsTest {
"lakes": { "enabled": true, "minArea": 65536, "maxArea": 4194304 },
"deformation": { "maxFill": 6, "bankSlope": 0.2, "bankSteepFactor": 3.5, "bankNoise": 0.2, "caveMask": true },
"underground": {
"seaInlets": { "enabled": true, "spacing": 192, "minimumCliffHeight": 8, "length": [64, 256], "halfWidth": [2, 5], "depth": [2, 5], "headroom": [4, 10], "roofClearance": 6, "chamberRadius": [6, 12] },
"seaInlets": { "enabled": true, "spacing": 192, "length": [64, 256], "maximumBankHeight": 28, "mouthHalfWidth": [10, 14], "headHalfWidth": [2, 3], "taper": 1.8, "widthVariation": 0.18, "meanderWidth": 4, "depth": [2, 5], "bankBand": 24, "bankStyle": "SMOOTH" },
"cavePools": { "enabled": true, "density": 0.15, "minArea": 6, "maxArea": 400, "maxDepth": 4, "radius": 15, "freeboard": [0, 1], "fluid": "water" }
},
"fluids": [ { "name": "water", "palette": { "palette": [ { "block": "minecraft:water" } ] } } ],
@@ -4,9 +4,11 @@ import art.arcane.iris.generation.block.IrisBlockData;
import art.arcane.iris.generation.decoration.IrisDecorationPart;
import art.arcane.iris.generation.decoration.IrisDecorator;
import art.arcane.iris.generation.hydrology.config.IrisFluidProfile;
import art.arcane.iris.generation.hydrology.config.IrisBankStyle;
import art.arcane.iris.generation.hydrology.config.IrisHydrology;
import art.arcane.iris.generation.hydrology.config.IrisHydrologyTier;
import art.arcane.iris.generation.hydrology.config.IrisHydrologyMaterials;
import art.arcane.iris.generation.hydrology.config.IrisSeaInlets;
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
import art.arcane.iris.pack.loading.IrisData;
@@ -21,6 +23,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -35,7 +38,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 = -2359553697125315860L;
private static final long DEFAULT_FINGERPRINT = -6680786385526424170L;
@Test
public void densityIsBoundedAndChangesThePlanIdentity() {
@@ -708,22 +711,71 @@ public class HydrologySettingsTest {
assertTrue(failure.getMessage(), failure.getMessage().contains(field));
}
@Test
public void seaInletDefaultsDescribeAFunnelReachingInland() {
HydrologySettings.SeaInlets inlets = compile(new IrisHydrology()).underground().seaInlets();
assertTrue(inlets.enabled());
assertEquals(192, inlets.spacing());
assertEquals(new HydrologySettings.IntRange(64, 256), inlets.length());
assertEquals(28, inlets.maximumBankHeight());
assertEquals(new HydrologySettings.FloatRange(10f, 14f), inlets.mouthHalfWidth());
assertEquals(new HydrologySettings.FloatRange(2f, 3f), inlets.headHalfWidth());
assertEquals(1.8f, inlets.taper(), 0f);
assertEquals(0.18f, inlets.widthVariation(), 1e-6f);
assertEquals(4f, inlets.meanderWidth(), 0f);
assertEquals(new HydrologySettings.IntRange(2, 5), inlets.depth());
assertEquals(24, inlets.bankBand());
assertEquals(IrisBankStyle.SMOOTH, inlets.bankStyle());
}
@Test
public void seaInletRangesAreBounded() {
compile(inlets(new KList<>(1D, 16D), new KList<>(2, 16)));
for (IrisHydrology rejected : List.of(inlets(new KList<>(0.5D, 5D), new KList<>(2, 5)), inlets(new KList<>(2D, 17D), new KList<>(2, 5)),
inlets(new KList<>(2D, 5D), new KList<>(2, 17)), inlets(new KList<>(2D, 5D), new KList<>(1, 5)))) {
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class, () -> compile(rejected));
compile(inlets(config -> config.setMouthHalfWidth(new KList<>(8D, 32D)).setHeadHalfWidth(new KList<>(1D, 8D)).setDepth(new KList<>(2, 16))));
List<IrisHydrology> rejected = List.of(
inlets(config -> config.setMouthHalfWidth(new KList<>(1.5D, 14D)).setHeadHalfWidth(new KList<>(1D, 1.5D))),
inlets(config -> config.setMouthHalfWidth(new KList<>(10D, 33D))),
inlets(config -> config.setHeadHalfWidth(new KList<>(0.5D, 3D))),
inlets(config -> config.setHeadHalfWidth(new KList<>(2D, 9D))),
inlets(config -> config.setDepth(new KList<>(2, 17))),
inlets(config -> config.setDepth(new KList<>(1, 5))),
inlets(config -> config.setMaximumBankHeight(1)),
inlets(config -> config.setMaximumBankHeight(129)),
inlets(config -> config.setTaper(0.4D)),
inlets(config -> config.setTaper(4.1D)),
inlets(config -> config.setWidthVariation(-0.1D)),
inlets(config -> config.setWidthVariation(0.6D)),
inlets(config -> config.setMeanderWidth(0.5D)),
inlets(config -> config.setMeanderWidth(17D)),
inlets(config -> config.setBankBand(3)),
inlets(config -> config.setBankBand(65)));
for (IrisHydrology config : rejected) {
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class, () -> compile(config));
assertTrue(failure.getMessage(), failure.getMessage().contains("underground.seaInlets"));
}
IllegalArgumentException belowWorld = assertThrows(IllegalArgumentException.class,
() -> HydrologySettings.compile(inlets(new KList<>(2D, 5D), new KList<>(2, 16)), SEED, MIN_Y + 18, MIN_Y, MAX_Y));
() -> HydrologySettings.compile(inlets(config -> config.setDepth(new KList<>(2, 16))), SEED, MIN_Y + 16, MIN_Y, MAX_Y));
assertTrue(belowWorld.getMessage(), belowWorld.getMessage().contains("world bottom"));
}
private static IrisHydrology inlets(KList<Double> halfWidth, KList<Integer> depth) {
@Test
public void seaInletMouthMustBeWiderThanItsHead() {
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
() -> compile(inlets(config -> config.setMouthHalfWidth(new KList<>(4D, 14D)).setHeadHalfWidth(new KList<>(2D, 5D)))));
assertTrue(failure.getMessage(), failure.getMessage().contains("mouthHalfWidth"));
}
@Test
public void overLongSeaInletsFailAtCompile() {
compile(inlets(config -> config.setLength(new KList<>(64, 447)).setMouthHalfWidth(new KList<>(10D, 16D)).setBankBand(24)));
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
() -> compile(inlets(config -> config.setLength(new KList<>(64, 512)))));
assertTrue(failure.getMessage(), failure.getMessage().contains("underground.seaInlets"));
assertTrue(failure.getMessage(), failure.getMessage().contains(Integer.toString(WindowKey.SIZE)));
}
private static IrisHydrology inlets(Consumer<IrisSeaInlets> tweak) {
IrisHydrology config = new IrisHydrology();
config.getUnderground().getSeaInlets().setHalfWidth(halfWidth).setDepth(depth);
tweak.accept(config.getUnderground().getSeaInlets());
return config;
}
@@ -84,7 +84,7 @@ public class SeaInletPlannerTest {
@Test
public void roofClearanceHeld() {
HydrologySettings settings = InletTerrain.settings();
int clearance = settings.underground().seaInlets().roofClearance();
int clearance = SeaInletPlanner.ROOF_CLEARANCE;
double troughFrom = 300D;
InletTerrain terrain = InletTerrain.cliffWithTrough(30D, troughFrom, 340D, SEA + 9D);
List<SeaInlet> inlets = terrain.plan(settings);
@@ -258,7 +258,7 @@ public class SeaInletPlannerTest {
@Test
public void staysUnderSurfaceWaterBeds() {
HydrologySettings settings = InletTerrain.settings();
int clearance = settings.underground().seaInlets().roofClearance();
int clearance = SeaInletPlanner.ROOF_CLEARANCE;
InletTerrain terrain = InletTerrain.cliff(30D);
Reach deep = InletTerrain.northSouthReach(settings, 232f, SEA + 26, 2f, 1.5f);
List<SeaInlet> under = terrain.plan(settings, new ShapedNetwork(List.of(deep), List.of()));
@@ -343,36 +343,6 @@ public class SeaInletPlannerTest {
return false;
}
@Test
public void endsInChamber() {
HydrologySettings settings = InletTerrain.settings();
HydrologySettings.SeaInlets config = settings.underground().seaInlets();
InletTerrain terrain = InletTerrain.cliff(30D);
int[] column = new int[2];
List<SeaInlet> inlets = terrain.plan(settings);
assertFalse(inlets.isEmpty());
for (SeaInlet inlet : inlets) {
int last = inlet.stations() - 1;
assertEquals(inlet.xs()[last], inlet.chamberX(), 0f);
assertEquals(inlet.zs()[last], inlet.chamberZ(), 0f);
assertTrue(inlet + " chamber radius", inlet.chamberRadius() >= config.chamberRadius().min()
&& inlet.chamberRadius() <= config.chamberRadius().max());
int reach = inlet.chamberRadius() - 1;
for (int dz = -reach; dz <= reach; dz++) {
for (int dx = -reach; dx <= reach; dx++) {
if (dx * dx + dz * dz > reach * reach) {
continue;
}
assertTrue(inlet + " chamber column " + dx + "," + dz,
SeaInletRasterizer.column(inlet, inlet.chamberX() + dx, inlet.chamberZ() + dz, column));
assertTrue(column[0] < SEA);
}
}
float length = InletTerrain.length(inlet);
assertTrue(inlet + " length " + length, length >= config.length().min() && length <= config.length().max() + InletTerrain.CELL * 1.5f);
}
}
@Test
public void continuesInlandPastTheHeadOfTheCoastalCatchment() {
double crest = 40D;
@@ -471,76 +441,6 @@ public class SeaInletPlannerTest {
return !WindowKey.containing(bounds[0], bounds[1]).equals(owner) || !WindowKey.containing(bounds[2], bounds[3]).equals(owner);
}
@Test
public void ownedInletsNeverConflictAcrossAWindowLine() {
IrisHydrology config = new IrisHydrology();
config.getUnderground().getSeaInlets().setSpacing(WindowKey.SIZE);
config.getUnderground().getSeaInlets().setLength(new KList<>(256, 400));
config.getUnderground().getSeaInlets().setHalfWidth(new KList<>(12D, 12D));
HydrologySettings settings = InletTerrain.settings(config);
int bayZ = 904;
WindowKey west = new WindowKey(1, 1);
WindowKey east = new WindowKey(2, 1);
single(InletTerrain.bay(1008, 1008, bayZ).wide(west, 3).plan(settings), west);
single(InletTerrain.bay(1032, 1032, bayZ).wide(east, 3).plan(settings), east);
InletTerrain bay = InletTerrain.bay(1016, 1024, bayZ);
List<SeaInlet> reference = bay.wide(west, 3).plan(settings);
List<SeaInlet> union = new ArrayList<>();
for (int wz = 0; wz <= 2; wz++) {
for (int wx = 0; wx <= 2; wx++) {
WindowKey window = new WindowKey(wx, wz);
List<SeaInlet> own = bay.span(window).plan(settings).stream().filter(inlet -> owner(inlet).equals(window)).toList();
assertEquals(window + " owns what the full-context plan gives it", reference.stream()
.filter(inlet -> owner(inlet).equals(window)).toList(), own);
union.addAll(own);
}
}
assertEquals("the two windows beside the bay keep one inlet between them: " + union, 1, union.size());
for (int first = 0; first < union.size(); first++) {
for (int second = first + 1; second < union.size(); second++) {
assertFalse(union.get(first) + " and " + union.get(second) + " cross a covered passage with an open slot",
coveredMeetsOpen(union.get(first), union.get(second)) || coveredMeetsOpen(union.get(second), union.get(first)));
}
}
}
private static SeaInlet single(List<SeaInlet> inlets, WindowKey window) {
List<SeaInlet> own = inlets.stream().filter(inlet -> owner(inlet).equals(window)).toList();
assertEquals(window + " owns one bay inlet: " + own, 1, own.size());
return own.getFirst();
}
@Test
public void extentGuardKeepsEveryPlannerLookupInsideTheOwnersSpan() {
for (double halfWidth : new double[]{1D, 16D}) {
for (int chamber = 1; chamber <= 32; chamber++) {
int length = WindowKey.SIZE - 12 - Math.max((int) Math.ceil(halfWidth), chamber) - 3;
IrisHydrology config = new IrisHydrology();
config.getUnderground().getSeaInlets().setLength(new KList<>(64, length));
config.getUnderground().getSeaInlets().setHalfWidth(new KList<>(1D, halfWidth));
config.getUnderground().getSeaInlets().setChamberRadius(new KList<>(1, chamber));
InletTerrain.settings(config);
long reach = SeaInletPlanner.lookupReach(length, chamber);
assertTrue("length " + length + " chamber " + chamber + " looks " + reach + " blocks out", reach <= WindowKey.SIZE);
}
}
}
@Test
public void longestInletAtTheFarEdgeOfItsWindowStaysInsideItsSpan() {
IrisHydrology config = new IrisHydrology();
config.getUnderground().getSeaInlets().setLength(new KList<>(465, 465));
config.getUnderground().getSeaInlets().setChamberRadius(new KList<>(32, 32));
HydrologySettings settings = InletTerrain.settings(config);
WindowKey window = new WindowKey(0, 0);
List<SeaInlet> owned = InletTerrain.eastEdgeCoast().plan(settings).stream().filter(inlet -> owner(inlet).equals(window)).toList();
assertFalse("inlets start on the window's last column", owned.isEmpty());
for (SeaInlet inlet : owned) {
assertEquals(inlet + " starts on the window's last column", WindowKey.SIZE - InletTerrain.CELL, inlet.xs()[1], 0f);
assertTrue(inlet + " runs the full length toward the span edge", inlet.chamberX() >= WindowKey.SIZE + 448);
}
}
@Test
public void ownInletCutOffByTheGridEdgeFailsClosed() {
InletTerrain narrow = InletTerrain.cliff(30D).narrow(0, 0);
@@ -548,15 +448,4 @@ public class SeaInletPlannerTest {
assertTrue(failure.getMessage(),
failure.getMessage().matches("Sea inlet -?\\d+ of window WindowKey\\[wx=0, wz=0\\] reaches the edge of .*"));
}
@Test
public void inletsReachingPastTheNextWindowAreRejected() {
IrisHydrology fits = new IrisHydrology();
fits.getUnderground().getSeaInlets().setLength(new KList<>(64, 485));
InletTerrain.settings(fits);
IrisHydrology last = new IrisHydrology();
last.getUnderground().getSeaInlets().setLength(new KList<>(64, 486));
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class, () -> InletTerrain.settings(last));
assertTrue(failure.getMessage(), failure.getMessage().contains("last step"));
}
}
@@ -40,8 +40,7 @@ public class PackHydrologyValidatorTest {
"ponds": {"freeboard": [0, 2], "fluid": "lava",
"seeded": {"radius": [4, 12], "depth": [2, 8], "channelSpacing": [48, 160]}},
"underground": {
"seaInlets": {"length": [24, 96], "halfWidth": [2, 5.5], "depth": [3, 6], "headroom": [0, 3],
"chamberRadius": [4, 9]},
"seaInlets": {"length": [24, 96], "mouthHalfWidth": [8, 12.5], "headHalfWidth": [2, 3.5], "depth": [3, 6]},
"cavePools": {"freeboard": [0, 1], "fluid": "water"}
},
"fluids": [
@@ -82,7 +81,7 @@ public class PackHydrologyValidatorTest {
"enabled": true,
"tiers": [{"name": "stream", "halfWidth": [0, 2]}, {"name": "river", "minCatchment": 9, "halfWidth": [2, 65]}],
"ponds": {"freeboard": [-1, 2], "seeded": {"channelSpacing": [0, 160]}},
"underground": {"seaInlets": {"headroom": [0, 3], "chamberRadius": [-2, 9]}, "cavePools": {"freeboard": [-1, 0]}}
"underground": {"seaInlets": {"mouthHalfWidth": [-2, 9]}, "cavePools": {"freeboard": [-1, 0]}}
}
""", "")));
@@ -90,7 +89,7 @@ public class PackHydrologyValidatorTest {
assertContains(validation.errors(), "tiers[1].halfWidth must not go above 64.");
assertContains(validation.errors(), "ponds.freeboard must not go below 0.");
assertContains(validation.errors(), "ponds.seeded.channelSpacing must stay above 0.");
assertContains(validation.errors(), "underground.seaInlets.chamberRadius must stay above 0.");
assertContains(validation.errors(), "underground.seaInlets.mouthHalfWidth must stay above 0.");
assertContains(validation.errors(), "underground.cavePools.freeboard must not go below 0.");
assertEquals(validation.errors().toString(), 6, validation.errors().size());
}
@@ -655,10 +654,10 @@ public class PackHydrologyValidatorTest {
assertTrue(validation.errors().toString(), validation.errors().isEmpty());
assertEquals(List.of(
"Dimension 'main' sets useMantle to false while hydrology is enabled, so the falling water at waterfalls and cascades,"
+ " sea inlets and cave pools are not generated.",
"Dimension 'main' sets useMantle to false while hydrology is enabled, so the falling water at waterfalls and cascades"
+ " and cave pools are not generated.",
"Dimension 'other' disables the RIVER_HYDROLOGY component while hydrology is enabled, so the falling water at waterfalls"
+ " and cascades, sea inlets and cave pools are not generated."), validation.warnings());
+ " and cascades and cave pools are not generated."), validation.warnings());
}
@Test
@@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest {
@ClassRule
public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean();
private static final String EXPECTED_SCHEMA_DIGEST = "3ed821f505deefbe3bdd3a105ece18893e4778e4cfc902591c43a18e1fceb2c1";
private static final String EXPECTED_SCHEMA_DIGEST = "a900bb5a9f8685d8bd8d28d0abaed52010cbd748053368f4b399f969e6b25178";
private static final List<Class<?>> SCHEMA_ROOTS = List.of(
IrisDimension.class,