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

@@ -11,10 +11,10 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@Description("Flooded passages that open in coastal cliffs and run inland, up the valleys where the drainage allows and onward under higher ground, with the water held at sea level the whole way, ending in a pool chamber. An inlet, its chamber and its seal stay within 512 blocks of the coast.")
@Description("Tidal arms of the sea: winding water courses open to the sky, flat at sea level and filled with sea water, wide at the coast and narrowing inland between shaped banks. They form on low coasts and keep clear of rivers, ponds and lakes.")
@Data
public class IrisSeaInlets {
@Description("Cuts sea inlets into coastal cliffs.")
@Description("Cuts sea inlets into low coasts.")
private boolean enabled = true;
@MinNumber(32)
@@ -22,33 +22,47 @@ public class IrisSeaInlets {
@Description("Size in blocks of the square cells of the site grid. Each cell holds at most one inlet; inlets in neighbouring cells can lie closer than this.")
private int spacing = 192;
@MinNumber(1)
@MaxNumber(128)
@Description("Height in blocks the coastal land must rise above sea level to be a site. The passage also needs ground at least headroom min + roofClearance + 2 blocks above sea level within about 16 blocks of the coast, so gentle coasts hold no inlets.")
private int minimumCliffHeight = 8;
@ArrayType(type = Integer.class, min = 2)
@Description("Length of an inlet in blocks, written as [min, max]. The max plus 12, plus the larger of halfWidth max and chamberRadius max, plus 3 must not exceed 512.")
@Description("Length of an inlet in blocks along its centre line, written as [min, max]. An arm that cannot reach the min is left out. The max, plus the meander, plus mouthHalfWidth max, plus bankBand must not exceed 512.")
private KList<Integer> length = new KList<>(64, 256);
@MinNumber(2)
@MaxNumber(128)
@Description("Highest ground in blocks above sea level an inlet may cut through. An arm stops where its banks would pass this height, so lower values keep inlets out of hills.")
private int maximumBankHeight = 28;
@ArrayType(type = Double.class, min = 2)
@Description("Half-width of the passage in blocks, written as [min, max], each from 1 to 16. The passage narrows toward its inland end.")
private KList<Double> halfWidth = new KList<>(2D, 5D);
@Description("Half-width of the water at the sea in blocks, written as [min, max], each from 2 to 32. The min must not be below headHalfWidth max.")
private KList<Double> mouthHalfWidth = new KList<>(10D, 14D);
@ArrayType(type = Integer.class, min = 2)
@Description("Water depth below sea level in blocks, written as [min, max], each from 2 to 16. Two blocks keep liquid water under an open slot's top sea layer.")
private KList<Integer> depth = new KList<>(2, 5);
@ArrayType(type = Double.class, min = 2)
@Description("Half-width of the water at the inland end in blocks, written as [min, max], each from 1 to 8.")
private KList<Double> headHalfWidth = new KList<>(2D, 3D);
@ArrayType(type = Integer.class, min = 2)
@Description("Air space above the water in blocks, written as [min, max], each from 0 to 32. It varies smoothly along the passage and shrinks where the ground above is thin.")
private KList<Integer> headroom = new KList<>(4, 10);
@MinNumber(0.5)
@MaxNumber(4)
@Description("How the width falls from mouth to head. 1 narrows evenly; above 1 stays narrow further from the head and widens late near the sea; below 1 widens early.")
private double taper = 1.8D;
@MinNumber(0)
@MaxNumber(0.5)
@Description("Slow change in width along the arm, as a fraction of the width at that point.")
private double widthVariation = 0.18D;
@MinNumber(1)
@MaxNumber(64)
@Description("Least solid ground in blocks kept between the passage roof and the surface.")
private int roofClearance = 6;
@MaxNumber(16)
@Description("Half-width in blocks that sets the size of the bends, as a river of that half-width would meander. Larger values give longer, wider bends.")
private double meanderWidth = 4D;
@ArrayType(type = Integer.class, min = 2)
@Description("Radius in blocks of the pool chamber at the inland end, written as [min, max], each from 1 to 32.")
private KList<Integer> chamberRadius = new KList<>(6, 12);
@Description("Water depth at the middle of the arm in blocks, written as [min, max], each from 2 to 16. The depth runs from min at the head to max toward the sea, and shoals to 1 at both ends.")
private KList<Integer> depth = new KList<>(2, 5);
@MinNumber(4)
@MaxNumber(64)
@Description("Width in blocks of the band of ground beside the water that is shaped into banks.")
private int bankBand = 24;
@Description("Profile of the banks across bankBand.")
private IrisBankStyle bankStyle = IrisBankStyle.SMOOTH;
}
@@ -21,9 +21,8 @@ import art.arcane.iris.generation.hydrology.config.IrisPondDams;
import art.arcane.iris.generation.hydrology.config.IrisPondNatural;
import art.arcane.iris.generation.hydrology.config.IrisPondSeeded;
import art.arcane.iris.generation.hydrology.config.IrisPondShore;
import art.arcane.iris.generation.hydrology.config.IrisBankStyle;
import art.arcane.iris.generation.hydrology.config.IrisSeaInlets;
import art.arcane.iris.generation.hydrology.underground.SeaInletPlanner;
import art.arcane.iris.generation.hydrology.underground.SeaInletRasterizer;
import art.arcane.iris.generation.hydrology.raster.WaterHeads;
import art.arcane.iris.generation.hydrology.water.HydrologyTier;
import art.arcane.iris.generation.hydrology.water.LakeCandidate;
@@ -52,14 +51,24 @@ public final class HydrologySettings {
private static final int MAX_DELTA_LENGTH = 384;
public static final float MAX_HALF_WIDTH = 64f;
public static final int DELTA_STEP = 2;
private static final double MIN_INLET_HALF_WIDTH = 1D;
private static final double MAX_INLET_HALF_WIDTH = 16D;
private static final double MIN_INLET_MOUTH = 2D;
private static final double MAX_INLET_MOUTH = 32D;
private static final double MIN_INLET_HEAD = 1D;
private static final double MAX_INLET_HEAD = 8D;
private static final int MIN_INLET_DEPTH = 2;
private static final int MAX_INLET_DEPTH = 16;
private static final int MAX_INLET_HEADROOM = 32;
private static final int MAX_INLET_CHAMBER = 32;
private static final int MIN_INLET_BANK_HEIGHT = 2;
private static final int MAX_INLET_BANK_HEIGHT = 128;
private static final double MIN_INLET_TAPER = 0.5D;
private static final double MAX_INLET_TAPER = 4D;
private static final double MAX_INLET_WIDTH_VARIATION = 0.5D;
private static final double MIN_INLET_MEANDER_WIDTH = 1D;
private static final double MAX_INLET_MEANDER_WIDTH = 16D;
private static final int MIN_INLET_BANK_BAND = 4;
private static final int MAX_INLET_BANK_BAND = 64;
private static final int INLET_LAST_STEP = (int) Math.ceil(WindowPlanner.CELL * Math.sqrt(2D));
private static final int INLET_SHELL = SeaInletRasterizer.SHELL;
private static final double INLET_MEANDER_SCALE = 2.5D;
private static final double INLET_MEANDER_MAX = 16D;
public static final int MAX_CAVE_POOL_RADIUS = 15;
private static final int CAVE_POOL_SPAN = 2 * MAX_CAVE_POOL_RADIUS + 1;
private static final int MAX_CAVE_POOL_AREA = CAVE_POOL_SPAN * CAVE_POOL_SPAN;
@@ -365,39 +374,49 @@ public final class HydrologySettings {
}
private SeaInlets seaInlets(IrisSeaInlets config) {
SeaInlets inlets = new SeaInlets(config.isEnabled(), config.getSpacing(), config.getMinimumCliffHeight(),
SeaInlets inlets = new SeaInlets(config.isEnabled(), config.getSpacing(),
intRange(config.getLength(), "underground.seaInlets.length", RangeFloor.POSITIVE),
floatRange(config.getHalfWidth(), "underground.seaInlets.halfWidth", RangeFloor.POSITIVE),
config.getMaximumBankHeight(),
floatRange(config.getMouthHalfWidth(), "underground.seaInlets.mouthHalfWidth", RangeFloor.POSITIVE),
floatRange(config.getHeadHalfWidth(), "underground.seaInlets.headHalfWidth", RangeFloor.POSITIVE),
(float) config.getTaper(), (float) config.getWidthVariation(), (float) config.getMeanderWidth(),
intRange(config.getDepth(), "underground.seaInlets.depth", RangeFloor.POSITIVE),
intRange(config.getHeadroom(), "underground.seaInlets.headroom", RangeFloor.NON_NEGATIVE),
config.getRoofClearance(),
intRange(config.getChamberRadius(), "underground.seaInlets.chamberRadius", RangeFloor.POSITIVE));
requireWithin(inlets.halfWidth().min(), MIN_INLET_HALF_WIDTH, MAX_INLET_HALF_WIDTH, "underground.seaInlets.halfWidth", config.getHalfWidth());
requireWithin(inlets.halfWidth().max(), MIN_INLET_HALF_WIDTH, MAX_INLET_HALF_WIDTH, "underground.seaInlets.halfWidth", config.getHalfWidth());
config.getBankBand(), Objects.requireNonNull(config.getBankStyle(), "Hydrology underground.seaInlets.bankStyle is missing"));
requireWithin(inlets.mouthHalfWidth().min(), MIN_INLET_MOUTH, MAX_INLET_MOUTH, "underground.seaInlets.mouthHalfWidth", config.getMouthHalfWidth());
requireWithin(inlets.mouthHalfWidth().max(), MIN_INLET_MOUTH, MAX_INLET_MOUTH, "underground.seaInlets.mouthHalfWidth", config.getMouthHalfWidth());
requireWithin(inlets.headHalfWidth().min(), MIN_INLET_HEAD, MAX_INLET_HEAD, "underground.seaInlets.headHalfWidth", config.getHeadHalfWidth());
requireWithin(inlets.headHalfWidth().max(), MIN_INLET_HEAD, MAX_INLET_HEAD, "underground.seaInlets.headHalfWidth", config.getHeadHalfWidth());
requireWithin(inlets.depth().min(), MIN_INLET_DEPTH, MAX_INLET_DEPTH, "underground.seaInlets.depth", config.getDepth());
requireWithin(inlets.depth().max(), MIN_INLET_DEPTH, MAX_INLET_DEPTH, "underground.seaInlets.depth", config.getDepth());
requireWithin(inlets.headroom().max(), 0, MAX_INLET_HEADROOM, "underground.seaInlets.headroom", config.getHeadroom());
requireWithin(inlets.chamberRadius().max(), 1, MAX_INLET_CHAMBER, "underground.seaInlets.chamberRadius", config.getChamberRadius());
if (inlets.enabled() && seaLevel > minY && seaLevel - inlets.depth().max() - INLET_SHELL - 1 <= minY) {
throw new IllegalArgumentException("Hydrology underground.seaInlets.depth max " + inlets.depth().max()
+ " puts the inlet floor and its seal below the world bottom " + minY + " (sea level " + seaLevel + ")");
requireWithin(inlets.maximumBankHeight(), MIN_INLET_BANK_HEIGHT, MAX_INLET_BANK_HEIGHT, "underground.seaInlets.maximumBankHeight");
requireScalarWithin(config.getTaper(), MIN_INLET_TAPER, MAX_INLET_TAPER, "underground.seaInlets.taper");
requireScalarWithin(config.getWidthVariation(), 0D, MAX_INLET_WIDTH_VARIATION, "underground.seaInlets.widthVariation");
requireScalarWithin(config.getMeanderWidth(), MIN_INLET_MEANDER_WIDTH, MAX_INLET_MEANDER_WIDTH, "underground.seaInlets.meanderWidth");
requireWithin(inlets.bankBand(), MIN_INLET_BANK_BAND, MAX_INLET_BANK_BAND, "underground.seaInlets.bankBand");
if (inlets.mouthHalfWidth().min() < inlets.headHalfWidth().max()) {
throw new IllegalArgumentException("Hydrology underground.seaInlets.mouthHalfWidth min " + inlets.mouthHalfWidth().min()
+ " must not be below headHalfWidth max " + inlets.headHalfWidth().max() + ": an inlet narrows inland");
}
long extent = (long) inlets.length().max() + INLET_LAST_STEP + Math.max((long) Math.ceil(inlets.halfWidth().max()),
inlets.chamberRadius().max()) + 1L + INLET_SHELL;
if (inlets.enabled() && seaLevel > minY && seaLevel - inlets.depth().max() - 1 <= minY) {
throw new IllegalArgumentException("Hydrology underground.seaInlets.depth max " + inlets.depth().max()
+ " puts the inlet floor below the world bottom " + minY + " (sea level " + seaLevel + ")");
}
long meander = (long) Math.ceil(Math.min(INLET_MEANDER_MAX, INLET_MEANDER_SCALE * (inlets.meanderWidth() + 1f)));
long extent = (long) inlets.length().max() + INLET_LAST_STEP + meander + (long) Math.ceil(inlets.mouthHalfWidth().max()) + inlets.bankBand();
if (extent > WindowKey.SIZE) {
throw new IllegalArgumentException("Hydrology underground.seaInlets reach " + extent + " blocks from the coast (length max "
+ inlets.length().max() + " + " + INLET_LAST_STEP + " for the last step + the wider of halfWidth max and chamberRadius max"
+ " + " + (1 + INLET_SHELL) + " for the seal); an inlet must stay within " + WindowKey.SIZE + " blocks");
}
long lookups = SeaInletPlanner.lookupReach(inlets.length().max(), inlets.chamberRadius().max());
if (lookups > WindowKey.SIZE) {
throw new IllegalArgumentException("Hydrology underground.seaInlets planning looks " + lookups
+ " blocks from the coast (length max " + inlets.length().max() + ", chamberRadius max " + inlets.chamberRadius().max()
+ "); it must stay within " + WindowKey.SIZE + " blocks");
+ inlets.length().max() + " + " + INLET_LAST_STEP + " for the last step + " + meander + " for the meander + mouthHalfWidth max "
+ inlets.mouthHalfWidth().max() + " + bankBand " + inlets.bankBand() + "); an inlet must stay within " + WindowKey.SIZE + " blocks");
}
return inlets;
}
private static void requireScalarWithin(double value, double min, double max, String field) {
if (!Double.isFinite(value) || value < min || value > max) {
throw new IllegalArgumentException("Hydrology " + field + " must stay within " + min + ".." + max + ", got " + value);
}
}
private static void requireWithin(double value, double min, double max, String field, List<? extends Number> written) {
if (value < min || value > max) {
throw new IllegalArgumentException("Hydrology range " + field + " must stay within " + min + ".." + max + ", got " + written);
@@ -761,9 +780,9 @@ public final class HydrologySettings {
SeaInlets inlets = underground.seaInlets();
CavePools pools = underground.cavePools();
CaveSprings springs = underground.caveSprings();
hash.add(inlets.enabled()).add(inlets.spacing()).add(inlets.minimumCliffHeight()).add(inlets.length())
.add(inlets.halfWidth()).add(inlets.depth()).add(inlets.headroom()).add(inlets.roofClearance())
.add(inlets.chamberRadius())
hash.add(inlets.enabled()).add(inlets.spacing()).add(inlets.length()).add(inlets.maximumBankHeight())
.add(inlets.mouthHalfWidth()).add(inlets.headHalfWidth()).add(inlets.taper()).add(inlets.widthVariation())
.add(inlets.meanderWidth()).add(inlets.depth()).add(inlets.bankBand()).add(inlets.bankStyle())
.add(pools.enabled()).add(pools.density()).add(pools.minArea()).add(pools.maxArea())
.add(pools.maxDepth()).add(pools.radius()).add(pools.freeboard()).add(pools.fluid())
.add(pools.deepFluid()).add(pools.deepFluidMaxY())
@@ -828,8 +847,9 @@ public final class HydrologySettings {
public record Deformation(int maxFill, float bankSlope, float bankSteepFactor, float bankNoise, boolean caveMask) {
}
public record SeaInlets(boolean enabled, int spacing, int minimumCliffHeight, IntRange length, FloatRange halfWidth,
IntRange depth, IntRange headroom, int roofClearance, IntRange chamberRadius) {
public record SeaInlets(boolean enabled, int spacing, IntRange length, int maximumBankHeight, FloatRange mouthHalfWidth,
FloatRange headHalfWidth, float taper, float widthVariation, float meanderWidth, IntRange depth, int bankBand,
IrisBankStyle bankStyle) {
}
public record CavePools(boolean enabled, float density, int minArea, int maxArea, int maxDepth, int radius,
@@ -36,6 +36,14 @@ public final class SeaInletPlanner {
private static final long SALT_DEPTH = 0x53454144455054L;
private static final long SALT_DENSITY = 0x53454144454e53L;
private static final double SQUARED_MARGIN = 1e-9D;
private static final int MINIMUM_CLIFF_HEIGHT = 8;
private static final float HALF_WIDTH_MIN = 2f;
private static final float HALF_WIDTH_MAX = 5f;
private static final int HEADROOM_MIN = 4;
private static final int HEADROOM_MAX = 10;
static final int ROOF_CLEARANCE = 6;
private static final int CHAMBER_MIN = 6;
private static final int CHAMBER_MAX = 12;
private final HydrologySettings settings;
@@ -100,7 +108,7 @@ public final class SeaInletPlanner {
private Map<Long, List<Integer>> sites(Terrain terrain, HydrologySettings.SeaInlets config) {
Map<Long, List<Integer>> sites = new TreeMap<>();
DemGrid grid = terrain.grid;
float cliff = settings.seaLevel() + config.minimumCliffHeight();
float cliff = settings.seaLevel() + MINIMUM_CLIFF_HEIGHT;
for (int j = 1; j < grid.depth() - 1; j++) {
for (int i = 1; i < grid.width() - 1; i++) {
int cell = grid.index(i, j);
@@ -193,10 +201,10 @@ public final class SeaInletPlanner {
int water = settings.seaLevel();
float chamberCapacity = Float.NaN;
int radius = 0;
int preferred = Math.round(lerp(config.chamberRadius().min(), config.chamberRadius().max(), unit(terrain, SALT_RADIUS, end)));
for (int candidate : new int[]{preferred, config.chamberRadius().min()}) {
int preferred = Math.round(lerp(CHAMBER_MIN, CHAMBER_MAX, unit(terrain, SALT_RADIUS, end)));
for (int candidate : new int[]{preferred, CHAMBER_MIN}) {
float capacity = capacity(terrain, config, end, chamberRing(candidate, grid.cell()));
if (capacity - water >= config.headroom().min()) {
if (capacity - water >= HEADROOM_MIN) {
radius = candidate;
chamberCapacity = capacity;
break;
@@ -217,7 +225,6 @@ public final class SeaInletPlanner {
int[] floor = new int[stations];
int[] ceiling = new int[stations];
float travelled = 0f;
HydrologySettings.FloatRange widths = config.halfWidth();
for (int station = 0; station < stations; station++) {
int cell = path.get(station);
if (station > 0) {
@@ -225,7 +232,7 @@ public final class SeaInletPlanner {
}
xs[station] = grid.blockX(cell);
zs[station] = grid.blockZ(cell);
halfWidth[station] = widths.max() - (widths.max() - widths.min()) * (travelled / total);
halfWidth[station] = HALF_WIDTH_MAX - (HALF_WIDTH_MAX - HALF_WIDTH_MIN) * (travelled / total);
floor[station] = water - Math.round(lerp(config.depth().min(), config.depth().max(), smooth(terrain, SALT_DEPTH, land, travelled)));
if (open.get(station)) {
ceiling[station] = SeaInlet.OPEN;
@@ -238,7 +245,7 @@ public final class SeaInletPlanner {
if (station + 1 < stations) {
room = Math.min(room, capacity[station + 1]);
}
float headroom = lerp(config.headroom().min(), config.headroom().max(), smooth(terrain, SALT_HEADROOM, land, travelled));
float headroom = lerp(HEADROOM_MIN, HEADROOM_MAX, smooth(terrain, SALT_HEADROOM, land, travelled));
ceiling[station] = water + (int) Math.floor(Math.min(headroom, room - water));
}
long id = CellHash.mix(CellHash.mix(terrain.seed, SALT_ID, grid.blockX(mouth), grid.blockZ(mouth)), SALT_ID, grid.blockX(land),
@@ -258,7 +265,7 @@ public final class SeaInletPlanner {
}
private boolean canCover(Terrain terrain, HydrologySettings.SeaInlets config, int cell) {
return capacity(terrain, config, cell, 1) - settings.seaLevel() >= config.headroom().min();
return capacity(terrain, config, cell, 1) - settings.seaLevel() >= HEADROOM_MIN;
}
private static float capacity(Terrain terrain, HydrologySettings.SeaInlets config, int cell, int ring) {
@@ -286,7 +293,7 @@ public final class SeaInletPlanner {
terrain.clipped = true;
return Float.NEGATIVE_INFINITY;
}
return lowest - config.roofClearance() - ROOF_MARGIN;
return lowest - ROOF_CLEARANCE - ROOF_MARGIN;
}
private static boolean openable(Terrain terrain, int cell) {
@@ -467,7 +474,7 @@ public final class SeaInletPlanner {
if (columns.first() < 0L || rows.first() < 0L || columns.last() > lastColumn || rows.last() > lastRow) {
return true;
}
float cliff = settings.seaLevel() + config.minimumCliffHeight();
float cliff = settings.seaLevel() + MINIMUM_CLIFF_HEIGHT;
for (int i = (int) columns.first(); i <= columns.last(); i++) {
if (rows.first() == 0L && cliffLand(terrain, i, 0, cliff) || rows.last() == lastRow && cliffLand(terrain, i, lastRow, cliff)) {
return true;
@@ -64,7 +64,7 @@ public final class CaveCeilingMask {
if (inlets.isEmpty()) {
return null;
}
int roofClearance = runtime.settings().underground().seaInlets().roofClearance();
int roofClearance = 6;
return fillHeadroom(chunkX, chunkZ, inlets, roofClearance, bands) ? bands : null;
}
@@ -40,15 +40,14 @@ final class PackHydrologyValidator {
new RangeField("ponds.seeded.depth", Floor.POSITIVE, true),
new RangeField("ponds.seeded.channelSpacing", Floor.POSITIVE, true),
new RangeField("underground.seaInlets.length", Floor.POSITIVE, true),
new RangeField("underground.seaInlets.halfWidth", Floor.POSITIVE, false),
new RangeField("underground.seaInlets.mouthHalfWidth", Floor.POSITIVE, false),
new RangeField("underground.seaInlets.headHalfWidth", Floor.POSITIVE, false),
new RangeField("underground.seaInlets.depth", Floor.POSITIVE, true),
new RangeField("underground.seaInlets.headroom", Floor.NON_NEGATIVE, true),
new RangeField("underground.seaInlets.chamberRadius", Floor.POSITIVE, true),
new RangeField("underground.cavePools.freeboard", Floor.NON_NEGATIVE, true)
);
private static final List<String> FLUID_REFERENCES = List.of("ponds.fluid", "underground.cavePools.fluid");
private static final IrisHydrologyTier DEFAULT_TIER = new IrisHydrologyTier();
private static final String MANTLE_WATER = "the falling water at waterfalls and cascades, sea inlets and cave pools";
private static final String MANTLE_WATER = "the falling water at waterfalls and cascades and cave pools";
private PackHydrologyValidator() {
}
@@ -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,
@@ -250,8 +250,7 @@ public final class SeaInletProbe {
throw new IllegalStateException(label + " reported " + reports.size() + " generation errors");
}
run.sea = sea;
run.roofClearance = engine.getDimension().getHydrology() == null ? 0
: engine.getDimension().getHydrology().getUnderground().getSeaInlets().getRoofClearance();
run.roofClearance = 6;
}
return run;
}
@@ -283,8 +282,7 @@ public final class SeaInletProbe {
}
Run run = new Run("hydrology");
run.sea = engine.getDimension().getFluidHeight();
run.roofClearance = engine.getDimension().getHydrology() == null ? 0
: engine.getDimension().getHydrology().getUnderground().getSeaInlets().getRoofClearance();
run.roofClearance = 6;
int height = engine.getTarget().getHeight();
Set<Long> chunks = new TreeSet<>();
for (SeaInlet inlet : inlets) {