From b17ad570ca653b40b76007e9a5e70b2a183db9ef Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Sun, 1 Nov 2026 22:52:35 -0500 Subject: [PATCH] Estuary review fixes - Taper estuary depth to the minimum depth at the mouth so the bed hands over to the natural seabed - Stop the estuary walk at an outlet's first point so lake outlets leave the lake at its level - Return a closed estuary opening for length 0 or a zero-length estuary instead of NaN widths - Record mouth river features with their reach's own fluid through HydrologyRuntime.channelFluid and the shared ChannelFluids.reachFluid - Pin the bank-height stop, the held pond lip, the lake outlet start and the degenerate opening - Use a neutral unknown tier key in the pack compatibility test - Recapture EXPECTED_SCHEMA_DIGEST for the flare description --- .../config/IrisHydrologyEstuary.java | 2 +- .../hydrology/engine/HydrologyRuntime.java | 22 ++++ .../hydrology/raster/ChannelFluids.java | 7 ++ .../hydrology/raster/RasterComposer.java | 5 +- .../hydrology/water/HydrologyTier.java | 2 +- .../hydrology/water/ReachGrader.java | 4 +- .../hydrology/water/ReachShaper.java | 39 +++--- .../history/GenerationSemanticCapture.java | 6 +- .../hydrology/water/ReachShaperTest.java | 119 +++++++++++++++++- .../iris/pack/PackHydrologyValidatorTest.java | 8 +- .../schema/SchemaBuilderIdentityTest.java | 2 +- .../GenerationSemanticCaptureTest.java | 24 ++++ 12 files changed, 208 insertions(+), 32 deletions(-) diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/config/IrisHydrologyEstuary.java b/core/src/main/java/art/arcane/iris/generation/hydrology/config/IrisHydrologyEstuary.java index 9f1897c38..27e124cec 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/config/IrisHydrologyEstuary.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/config/IrisHydrologyEstuary.java @@ -19,6 +19,6 @@ public class IrisHydrologyEstuary { @MinNumber(1) @MaxNumber(4) - @Description("Half-width at the mouth of a full-length estuary as a multiple of the channel's own half-width. The channel widens slowly at first and fastest near the mouth and keeps its own depth; an estuary cut short by higher banks widens less. The half-width never passes 64. 1 keeps the channel's width.") + @Description("Half-width at the mouth of a full-length estuary as a multiple of the channel's own half-width. The channel widens slowly at first and fastest near the mouth while its depth tapers to one block there; an estuary cut short by higher banks widens less. The half-width never passes 64. 1 keeps the channel's width.") private double flare = 2.5D; } diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/engine/HydrologyRuntime.java b/core/src/main/java/art/arcane/iris/generation/hydrology/engine/HydrologyRuntime.java index db235e1ed..54cde2c6e 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/engine/HydrologyRuntime.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/engine/HydrologyRuntime.java @@ -69,6 +69,7 @@ public final class HydrologyRuntime { private final HydrologySettings settings; private final HydrologyPlanCache cache; private final ChunkRasterizer rasterizer; + private final ChannelFluids channelFluids; private final NaturalHeights naturalHeight; private final BooleanSupplier mainThread; private final RasterLru rasters; @@ -93,6 +94,7 @@ public final class HydrologyRuntime { this.settings = null; this.cache = null; this.rasterizer = null; + this.channelFluids = null; this.naturalHeight = null; this.mainThread = null; this.rasters = null; @@ -120,6 +122,7 @@ public final class HydrologyRuntime { Function stores, boolean caveFluidPolicies) { this.settings = Objects.requireNonNull(settings, "settings"); this.cache = Objects.requireNonNull(cache, "cache"); + this.channelFluids = Objects.requireNonNull(channelFluids, "channelFluids"); this.rasterizer = new ChunkRasterizer(settings, channelFluids); this.naturalHeight = Objects.requireNonNull(naturalHeight, "naturalHeight"); this.mainThread = Objects.requireNonNull(mainThread, "mainThread"); @@ -463,6 +466,25 @@ public final class HydrologyRuntime { + " that none of its hydrology plans define."); } + public String channelFluid(int chunkX, int chunkZ, long reachId) { + if (cache == null) { + throw new IllegalStateException("Hydrology is disabled, so it has no channels."); + } + if (mainThread.getAsBoolean()) { + throw new IllegalStateException("Hydrology channel fluid was requested on the main thread."); + } + requireOpen(); + for (CompletableFuture window : plans(neighbourhood(chunkX, chunkZ), List.of(), PlanMode.DEMAND).windowFutures()) { + for (Reach reach : cache.awaitPlan(window).plan().reaches()) { + if (reach.id() == reachId) { + return channelFluids.reachFluid(reach); + } + } + } + throw new IllegalStateException("Chunk " + chunkX + "," + chunkZ + " holds channel water " + reachId + + " that none of its hydrology plans define."); + } + public synchronized void close() { if (cache == null) { return; diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/ChannelFluids.java b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/ChannelFluids.java index d2a887dbb..dfcb026f0 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/ChannelFluids.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/ChannelFluids.java @@ -1,8 +1,15 @@ package art.arcane.iris.generation.hydrology.raster; +import art.arcane.iris.generation.hydrology.water.Reach; + @FunctionalInterface public interface ChannelFluids { ChannelFluids TIER = (x, z) -> null; String channelFluid(int x, int z); + + default String reachFluid(Reach reach) { + String area = channelFluid((int) Math.floor(reach.xs()[0]), (int) Math.floor(reach.zs()[0])); + return area != null ? area : reach.tier().fluid(); + } } diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/RasterComposer.java b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/RasterComposer.java index a2614d268..e595c9477 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/RasterComposer.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/RasterComposer.java @@ -149,10 +149,7 @@ final class RasterComposer { } private String reachFluid(Reach reach) { - return reachFluids.computeIfAbsent(reach.id(), id -> { - String area = channelFluids.channelFluid((int) Math.floor(reach.xs()[0]), (int) Math.floor(reach.zs()[0])); - return area != null ? area : reach.tier().fluid(); - }); + return reachFluids.computeIfAbsent(reach.id(), id -> channelFluids.reachFluid(reach)); } private int deepestBed(int ownerHead, int surface, int ground, double variation, double detail) { diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/water/HydrologyTier.java b/core/src/main/java/art/arcane/iris/generation/hydrology/water/HydrologyTier.java index f0ba9dd9b..3bdec4fe4 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/water/HydrologyTier.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/water/HydrologyTier.java @@ -24,7 +24,7 @@ public record HydrologyTier( List decorators ) { private static final float CATCHMENT_SCALE = 2500f; - private static final float MINIMUM_DEPTH = 1f; + static final float MINIMUM_DEPTH = 1f; public float halfWidth(float catchment) { float grown = minHalfWidth + widthFactor * (float) Math.sqrt(Math.max(0f, catchment) / CATCHMENT_SCALE); diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/water/ReachGrader.java b/core/src/main/java/art/arcane/iris/generation/hydrology/water/ReachGrader.java index 7236b1292..bc2f58484 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/water/ReachGrader.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/water/ReachGrader.java @@ -88,8 +88,8 @@ final class ReachGrader { if (point < draft.xs.length - 1) { along += (float) Math.hypot(draft.xs[point + 1] - draft.xs[point], draft.zs[point + 1] - draft.zs[point]); } - boolean held = draft.held != null && draft.held[point]; - if (along > length || held || !draft.ocean[point] && draft.bank[point] > highestBank) { + boolean fixed = draft.held != null && draft.held[point] || point == 0 && draft.outlet; + if (along > length || fixed || !draft.ocean[point] && draft.bank[point] > highestBank) { return; } draft.ocean[point] = true; diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/water/ReachShaper.java b/core/src/main/java/art/arcane/iris/generation/hydrology/water/ReachShaper.java index c3a713de9..81345ca55 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/water/ReachShaper.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/water/ReachShaper.java @@ -492,7 +492,9 @@ public final class ReachShaper { boolean flare = draft.incoming.length > 0 && !draft.outlet; boolean taper = !flare && !draft.outlet; float[] distance = distances(draft.xs, draft.zs); - float[] estuary = estuaryFlare(draft, distance); + Opening estuary = draft.chain.end() == ReachTracer.End.OCEAN ? estuaryOpening(draft.tier.estuary(), draft.ocean, distance) + : Opening.closed(count); + float widening = (draft.tier.estuary().flare() - 1f) * estuary.share(); float running = upstream; draft.halfWidth = new float[count]; draft.depth = new float[count]; @@ -505,35 +507,36 @@ public final class ReachShaper { } float lip = draft.held != null && draft.held[point] ? LIP_HALF_WIDTH : 0f; float channel = Math.max(Math.max(law, WAIST * running), lip); - draft.halfWidth[point] = Math.min(HydrologySettings.MAX_HALF_WIDTH, channel * estuary[point]); + float progress = estuary.progress()[point]; + draft.halfWidth[point] = Math.min(HydrologySettings.MAX_HALF_WIDTH, channel * (1f + widening * progress)); running = Math.max(running, channel); - draft.depth[point] = draft.tier.depth(channel); + float depth = draft.tier.depth(channel); + draft.depth[point] = depth + (HydrologyTier.MINIMUM_DEPTH - depth) * progress; } draft.maxHalfWidth = running; } - private static float[] estuaryFlare(ReachDraft draft, float[] distance) { + static Opening estuaryOpening(HydrologyTier.Estuary estuary, boolean[] ocean, float[] distance) { int count = distance.length; - float[] scale = new float[count]; - Arrays.fill(scale, 1f); - if (draft.chain.end() != ReachTracer.End.OCEAN) { - return scale; + if (estuary.length() == 0) { + return Opening.closed(count); } - HydrologyTier.Estuary estuary = draft.tier.estuary(); float mouth = distance[count - 1]; int start = count - 1; - while (start > 0 && draft.ocean[start - 1] && mouth - distance[start - 1] <= estuary.length()) { + while (start > 0 && ocean[start - 1] && mouth - distance[start - 1] <= estuary.length()) { start--; } - if (start == count - 1) { - return scale; - } float first = towardMouth(mouth - distance[start], estuary.length()); + float share = 1f - first * first; + if (start == count - 1 || share <= 0f) { + return Opening.closed(count); + } + float[] progress = new float[count]; for (int point = start + 1; point < count; point++) { float toward = towardMouth(mouth - distance[point], estuary.length()); - scale[point] = 1f + (estuary.flare() - 1f) * (toward * toward - first * first); + progress[point] = (toward * toward - first * first) / share; } - return scale; + return new Opening(progress, share); } private static float towardMouth(float remaining, int length) { @@ -649,4 +652,10 @@ public final class ReachShaper { + " accumulation=" + accumulation.length + " channels=" + channels.length()); } } + + record Opening(float[] progress, float share) { + static Opening closed(int count) { + return new Opening(new float[count], 0f); + } + } } diff --git a/core/src/main/java/art/arcane/iris/world/history/GenerationSemanticCapture.java b/core/src/main/java/art/arcane/iris/world/history/GenerationSemanticCapture.java index b6ae00d61..6f77ef84d 100644 --- a/core/src/main/java/art/arcane/iris/world/history/GenerationSemanticCapture.java +++ b/core/src/main/java/art/arcane/iris/world/history/GenerationSemanticCapture.java @@ -165,6 +165,7 @@ public final class GenerationSemanticCapture { return; } Map> standing = new HashMap<>(); + Map reachFluids = new HashMap<>(); Set recorded = new HashSet<>(); for (int localX = 0; localX < CHUNK_SIZE; localX++) { int blockX = minimumX + localX; @@ -181,8 +182,9 @@ public final class GenerationSemanticCapture { Set types = role == WaterRole.POND ? standing.computeIfAbsent(id, feature -> runtime.standingWaterTypes(chunkX, chunkZ, feature)) : flowingTypes(runtime, role, raster.tier(localX, localZ)); - String fluid = Objects.requireNonNull(raster.fluid(localX, localZ), - "Water column " + blockX + "," + blockZ + " has no fluid profile"); + String fluid = role == WaterRole.MOUTH + ? reachFluids.computeIfAbsent(id, reach -> runtime.channelFluid(chunkX, chunkZ, reach)) + : Objects.requireNonNull(raster.fluid(localX, localZ), "Water column " + blockX + "," + blockZ + " has no fluid profile"); int y = Math.addExact((int) Math.round(complex.getWaterHeadStream().getDouble(blockX, blockZ)), minimumY); for (HydrologyFeatureType type : types) { if (recorded.add(new WaterFeature(type, id))) { diff --git a/core/src/test/java/art/arcane/iris/generation/hydrology/water/ReachShaperTest.java b/core/src/test/java/art/arcane/iris/generation/hydrology/water/ReachShaperTest.java index a985a8f0e..348659fc9 100644 --- a/core/src/test/java/art/arcane/iris/generation/hydrology/water/ReachShaperTest.java +++ b/core/src/test/java/art/arcane/iris/generation/hydrology/water/ReachShaperTest.java @@ -49,6 +49,7 @@ public class ReachShaperTest { private static final int STEP_X = 196; private static final int WINDOW_MIN_X = 140; private static final int WINDOW_MAX_X = 250; + private static final int OUTLET_POND_LEVEL = SEA_LEVEL + 3; private static final byte ALLOW_ALL = HydrologySampleBuffer.ALLOW_STREAMS | HydrologySampleBuffer.ALLOW_PONDS; @Test @@ -926,10 +927,12 @@ public class ReachShaperTest { boolean inside = point >= start; assertEquals(estuary + " is a mouth at " + point, inside, estuary.style()[point] == ReachStyle.MOUTH); assertTrue(estuary + " grade at " + point, inside ? estuary.grade()[point] == SEA_LEVEL : estuary.grade()[point] > SEA_LEVEL); - assertEquals("the estuary keeps the channel depth at " + point, unflared.depth()[point], estuary.depth()[point], 0f); + assertEquals("the flare leaves the depth alone at " + point, unflared.depth()[point], estuary.depth()[point], 0f); if (point <= start) { + assertEquals("full channel depth above the estuary at " + point, mouth.depth()[point], estuary.depth()[point], 0f); assertEquals("no flare above the estuary at " + point, unflared.halfWidth()[point], estuary.halfWidth()[point], 0f); } else { + assertTrue("the estuary shallows toward the mouth at " + point, estuary.depth()[point] <= mouth.depth()[point]); float ratio = estuary.halfWidth()[point] / unflared.halfWidth()[point]; float previous = estuary.halfWidth()[point - 1] / unflared.halfWidth()[point - 1]; assertTrue("flare grows toward the mouth at " + point + ": " + previous + " then " + ratio, ratio >= previous - 1e-6f); @@ -943,6 +946,9 @@ public class ReachShaperTest { middle++; } assertTrue("flare grows slowly at first", estuary.halfWidth()[middle] / unflared.halfWidth()[middle] < 1.75f); + assertTrue("the estuary shallows gradually", estuary.depth()[middle] > HydrologyTier.MINIMUM_DEPTH); + assertEquals("the estuary bed meets the seabed at the mouth", HydrologyTier.MINIMUM_DEPTH, estuary.depth()[last], 0f); + assertTrue("a plain mouth keeps the channel depth", mouth.depth()[last] > 2f * HydrologyTier.MINIMUM_DEPTH); assertTrue("length 0 ends in a plain mouth", mouth.xs()[last] - mouth.xs()[trailingMouth(mouth)] < 8f); assertTrue("length 0 keeps the channel width", Arrays.equals(unflared.halfWidth(), mouth.halfWidth())); @@ -954,6 +960,74 @@ public class ReachShaperTest { assertTrue("a channel that does not reach the sea keeps its width", Arrays.equals(inlandPlain.halfWidth(), inland.halfWidth())); } + @Test + public void estuaryStopsWhereTheBanksRise() { + HydrologySettings settings = settings(config -> { + }); + HydrologySettings plainMouth = settings(config -> config.getTiers().forEach(tier -> tier.getEstuary().setLength(0))); + double rise = 0.2D; + Reach estuary = coastalRun(settings, true, rise); + Reach mouth = coastalRun(plainMouth, true, rise); + int last = estuary.xs().length - 1; + int start = trailingMouth(estuary); + float span = estuary.xs()[last] - estuary.xs()[start]; + int highestBank = SEA_LEVEL + settings.deformation().maxFill(); + assertTrue("banks above " + highestBank + " stop the estuary " + span + " blocks up, short of its length", span >= 16f && span <= 30f); + for (int point = start; point <= last; point++) { + double bank = SEA_LEVEL + 1D + rise * (estuary.xs()[last] - estuary.xs()[point]); + assertTrue("estuary point " + point + " has a bank at " + bank, bank <= highestBank + 1D); + assertEquals(SEA_LEVEL, estuary.grade()[point]); + } + assertEquals("no flare where the estuary starts", mouth.halfWidth()[start], estuary.halfWidth()[start], 0f); + for (int point = start + 1; point <= last; point++) { + float ratio = estuary.halfWidth()[point] / mouth.halfWidth()[point]; + float previous = estuary.halfWidth()[point - 1] / mouth.halfWidth()[point - 1]; + assertTrue("flare grows toward the mouth at " + point + ": " + previous + " then " + ratio, ratio >= previous - 1e-6f); + } + float mouthFlare = estuary.halfWidth()[last] / mouth.halfWidth()[last]; + assertTrue("a short estuary opens less than flare: " + mouthFlare, mouthFlare > 1.5f && mouthFlare < 2.4f); + assertEquals("a short estuary still meets the seabed", HydrologyTier.MINIMUM_DEPTH, estuary.depth()[last], 0f); + } + + @Test + public void estuaryStopsAtAHeldPondLip() { + Reach outlet = coastalOutlet(PondKind.NATURAL); + PondMask pond = disk(128, 8, 7); + int lip = 0; + while (lip < outlet.xs().length && ReachShaper.nearLip(pond, outlet.xs()[lip], outlet.zs()[lip], outlet.halfWidth()[lip])) { + assertEquals("lip point " + lip + " holds the pond level", OUTLET_POND_LEVEL, outlet.grade()[lip]); + assertNotEquals("lip point " + lip, ReachStyle.MOUTH, outlet.style()[lip]); + lip++; + } + assertTrue("points along the lip " + lip, lip >= 4); + assertEstuaryInland(outlet); + } + + @Test + public void lakeOutletLeavesTheLakeAtItsLevelBesideAnEstuary() { + Reach outlet = coastalOutlet(PondKind.LAKE); + assertEquals("the outlet leaves the lake at its level", OUTLET_POND_LEVEL, outlet.grade()[0]); + assertNotEquals(ReachStyle.MOUTH, outlet.style()[0]); + assertEstuaryInland(outlet); + } + + @Test + public void estuaryOpeningStaysFiniteWithoutLengthOrDistance() { + boolean[] ocean = {false, true, true}; + float[] stacked = {0f, 10f, 10f}; + for (ReachShaper.Opening opening : List.of(ReachShaper.estuaryOpening(new HydrologyTier.Estuary(0, 2.5f), ocean, stacked), + ReachShaper.estuaryOpening(new HydrologyTier.Estuary(48, 2.5f), ocean, stacked))) { + assertEquals(0f, opening.share(), 0f); + for (float progress : opening.progress()) { + assertEquals(0f, progress, 0f); + } + } + ReachShaper.Opening half = ReachShaper.estuaryOpening(new HydrologyTier.Estuary(48, 2.5f), ocean, new float[]{0f, 24f, 48f}); + assertEquals(0.75f, half.share(), 1e-6f); + assertEquals(0f, half.progress()[1], 0f); + assertEquals(1f, half.progress()[2], 1e-6f); + } + @Test public void groundReadIsSymmetricAroundThePoint() { HydrologySettings settings = settings(config -> { @@ -1805,7 +1879,48 @@ public class ReachShaperTest { return found; } + private static Reach coastalOutlet(PondKind kind) { + HydrologySettings settings = settings(config -> { + }); + int width = 26; + DemGrid surface = new DemGrid(0, 0, CELL, width, 3); + Arrays.fill(surface.values(), 60f); + int[] receivers = new int[width * 3]; + Arrays.fill(receivers, -1); + float[] accumulation = new float[width * 3]; + BitSet channels = new BitSet(width * 3); + for (int i = 0; i < 21; i++) { + flow(surface, receivers, accumulation, channels, i, 1, i + 1, 1, 1600f + 10f * i); + } + surface.set(21, 1, 30f); + Pond pond = new Pond(73L, kind, OUTLET_POND_LEVEL, OUTLET_POND_LEVEL - 4, 136, 8, OUTLET_POND_LEVEL + 0.5f, disk(128, 8, 7), 0L, 0, + "water", 128, 8); + HeightLattice fine = new HeightLattice(new Terrain((x, z) -> x < 160D ? SEA_LEVEL + 4D : SEA_LEVEL - 5D), FINE, false, 1 << 16); + ShapedNetwork shaped = new ReachShaper(settings).shape(WINDOW, surface, receivers, accumulation, channels, List.of(pond), fine, SEED); + Pond shapedPond = shaped.ponds().get(0); + assertEquals(kind + " level", OUTLET_POND_LEVEL, shapedPond.level()); + Reach outlet = byId(shaped.reaches()).get(shapedPond.outletReachId()); + assertNotNull(kind + " outlet", outlet); + assertEquals(ReachStyle.MOUTH, outlet.style()[outlet.style().length - 1]); + return outlet; + } + + private static void assertEstuaryInland(Reach outlet) { + int inland = 0; + for (int point = 0; point < outlet.xs().length; point++) { + if (outlet.style()[point] == ReachStyle.MOUTH) { + assertEquals(outlet + " at " + point, SEA_LEVEL, outlet.grade()[point]); + inland += outlet.xs()[point] < 156f ? 1 : 0; + } + } + assertTrue("estuary points over the low land " + inland, inland > 0); + } + private static Reach coastalRun(HydrologySettings settings, boolean ocean) { + return coastalRun(settings, ocean, 0.08D); + } + + private static Reach coastalRun(HydrologySettings settings, boolean ocean, double rise) { int width = 24; DemGrid surface = new DemGrid(0, 0, CELL, width, 3); Arrays.fill(surface.values(), 60f); @@ -1825,7 +1940,7 @@ public class ReachShaperTest { surface.set(width - 1, 1, 30f); } float mouthX = (width - 1) * CELL; - HeightLattice fine = new HeightLattice(new Terrain((x, z) -> SEA_LEVEL + 1D + 0.08D * Math.max(0D, mouthX - x)), FINE, false, 1 << 16); + HeightLattice fine = new HeightLattice(new Terrain((x, z) -> SEA_LEVEL + 1D + rise * Math.max(0D, mouthX - x)), FINE, false, 1 << 16); ShapedNetwork shaped = new ReachShaper(settings).shape(WINDOW, surface, receivers, accumulation, channels, List.of(), fine, SEED); assertEquals(1, shaped.reaches().size()); return shaped.reaches().get(0); diff --git a/core/src/test/java/art/arcane/iris/pack/PackHydrologyValidatorTest.java b/core/src/test/java/art/arcane/iris/pack/PackHydrologyValidatorTest.java index f1e3dfaf3..7e8cb0892 100644 --- a/core/src/test/java/art/arcane/iris/pack/PackHydrologyValidatorTest.java +++ b/core/src/test/java/art/arcane/iris/pack/PackHydrologyValidatorTest.java @@ -250,15 +250,15 @@ public class PackHydrologyValidatorTest { {"name": "major", "minCatchment": 200000, "halfWidth": [9, 18], "bankBand": 48%s} ]} """; - File stale = pack(dimension(written.formatted(", \"deltas\": false", ", \"deltas\": true"), "")); + File extra = pack(dimension(written.formatted(", \"notATierField\": false", ", \"notATierField\": {\"depth\": 3}"), "")); File current = pack(dimension(written.formatted("", ""), "")); - PackHydrologyValidator.Validation validation = validate(stale); + PackHydrologyValidator.Validation validation = validate(extra); assertTrue(validation.errors().toString(), validation.errors().isEmpty()); assertTrue(validation.warnings().isEmpty()); - PackValidationResult packaging = PackValidator.validateForPackaging(stale); + PackValidationResult packaging = PackValidator.validateForPackaging(extra); assertEquals(PackValidator.validateForPackaging(current).getBlockingErrors(), packaging.getBlockingErrors()); - IrisHydrology loaded = loadHydrology(stale); + IrisHydrology loaded = loadHydrology(extra); for (IrisHydrologyTier tier : loaded.getTiers()) { assertEquals(tier.getName(), 48, tier.getEstuary().getLength()); assertEquals(tier.getName(), 2.5D, tier.getEstuary().getFlare(), 0D); diff --git a/core/src/test/java/art/arcane/iris/pack/schema/SchemaBuilderIdentityTest.java b/core/src/test/java/art/arcane/iris/pack/schema/SchemaBuilderIdentityTest.java index 58e3587e8..71bccee24 100644 --- a/core/src/test/java/art/arcane/iris/pack/schema/SchemaBuilderIdentityTest.java +++ b/core/src/test/java/art/arcane/iris/pack/schema/SchemaBuilderIdentityTest.java @@ -84,7 +84,7 @@ public class SchemaBuilderIdentityTest { @ClassRule public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean(); - private static final String EXPECTED_SCHEMA_DIGEST = "fe8d1a02aeff1f03d759d2c9def1807fadeac5e99beed02bf7640bd4cb8f6691"; + private static final String EXPECTED_SCHEMA_DIGEST = "6caf6bfdfd8b4cc360bf0da070a7636982d23aae13a1cfe14310b8d5f2410f26"; private static final List> SCHEMA_ROOTS = List.of( IrisDimension.class, diff --git a/core/src/test/java/art/arcane/iris/world/history/GenerationSemanticCaptureTest.java b/core/src/test/java/art/arcane/iris/world/history/GenerationSemanticCaptureTest.java index 02ec818a0..07ce189ad 100644 --- a/core/src/test/java/art/arcane/iris/world/history/GenerationSemanticCaptureTest.java +++ b/core/src/test/java/art/arcane/iris/world/history/GenerationSemanticCaptureTest.java @@ -28,6 +28,7 @@ import art.arcane.iris.generation.hydrology.underground.SeaInlet; import art.arcane.iris.generation.hydrology.water.Pond; import art.arcane.iris.generation.hydrology.water.PondKind; import art.arcane.iris.generation.hydrology.water.Reach; +import art.arcane.iris.generation.hydrology.water.ReachStyle; import art.arcane.iris.testsupport.FakeHydrology; import art.arcane.iris.testsupport.WaterScene; import art.arcane.iris.generation.mantle.EngineMantle; @@ -44,6 +45,7 @@ import org.junit.Test; import org.mockito.MockedStatic; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -491,6 +493,28 @@ public final class GenerationSemanticCaptureTest { } } + @Test + public void estuaryFeaturesRecordTheFluidOfTheirReach() { + HydrologySettings settings = FakeHydrology.settings(WATER_SEA_LEVEL); + Reach drawn = WaterScene.line(13L, settings.tiers().getFirst(), 2, 40, 13, 40, (x, z) -> WATER_SEA_LEVEL); + ReachStyle[] mouth = new ReachStyle[drawn.style().length]; + Arrays.fill(mouth, ReachStyle.MOUTH); + Reach estuary = new Reach(drawn.id(), drawn.tier(), 0L, drawn.xs(), drawn.zs(), drawn.grade(), drawn.halfWidth(), drawn.depth(), mouth, + drawn.catchment()); + try (FakeHydrology hydrology = new FakeHydrology(() -> false, (x, z) -> 60, WATER_SEA_LEVEL, List.of(estuary), List.of())) { + Fixture fixture = new Fixture(); + fixture.water(hydrology.runtime); + assertEquals(HydrologyCaveCell.SEA_FLUID, hydrology.runtime.raster(0, 2).fluid(5, 8)); + + assertEquals(Map.of(HydrologyFeatureType.MOUTH, 13L, HydrologyFeatureType.STREAM, 13L), features(fixture, 0, 2)); + ChunkGenerationSemantics captured = GenerationSemanticCapture.capture(fixture.engine, 0, 2, 5L); + for (ChunkGenerationSemantics.RiverFeatureOccurrence occurrence : captured.riverFeatures()) { + assertEquals(occurrence.type().name(), "water", occurrence.profileKey()); + } + assertEquals(Set.of("water"), captured.riverProfileKeys()); + } + } + @Test public void recordsSeaInletsInEveryChunkTheyPassUnderWithTheirOwnProfile() { int stations = 8;