From bce7efaa7267df15417b79c00b5cd3238ebf8273 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 31 Oct 2026 00:43:10 -0500 Subject: [PATCH 1/5] Let biome effects choose their sound category IrisEffect played its sound with Player.playSound(location, sound, volume, pitch), which Paper sends on SoundCategory.MASTER, so packs that use effects for biome music or ambience could only be turned down with the master slider. A new soundCategory field (default MASTER, so existing packs sound the same) picks the category: music can follow the music slider, moods the ambient slider. --- .../java/art/arcane/iris/world/entity/IrisEffect.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/art/arcane/iris/world/entity/IrisEffect.java b/core/src/main/java/art/arcane/iris/world/entity/IrisEffect.java index 0c39dd8e0..d41d027cf 100644 --- a/core/src/main/java/art/arcane/iris/world/entity/IrisEffect.java +++ b/core/src/main/java/art/arcane/iris/world/entity/IrisEffect.java @@ -44,6 +44,7 @@ import org.bukkit.World; import org.bukkit.NamespacedKey; import org.bukkit.Particle; import org.bukkit.Sound; +import org.bukkit.SoundCategory; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; @@ -117,6 +118,9 @@ public class IrisEffect { @MaxNumber(512) @Description("The sound volume.") private double volume = 1.5D; + @DependsOn({"sound"}) + @Description("The sound category the sound plays in, which picks the client volume slider that controls it (for example MUSIC, AMBIENT or HOSTILE).") + private SoundCategory soundCategory = SoundCategory.MASTER; @DependsOn({"particleEffect"}) @MinNumber(0) @MaxNumber(512) @@ -240,7 +244,7 @@ public class IrisEffect { Particle particleType = getParticleEffect(); if (soundType != null) { Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance)); - p.playSound(part, soundType, (float) volume, (float) RNG.r.d(minPitch, maxPitch)); + p.playSound(part, soundType, soundCategory, (float) volume, (float) RNG.r.d(minPitch, maxPitch)); } if (particleType != null) { @@ -317,7 +321,7 @@ public class IrisEffect { Particle particleType = getParticleEffect(); if (soundType != null) { Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance)); - p.getWorld().playSound(part, soundType, (float) volume, (float) RNG.r.d(minPitch, maxPitch)); + p.getWorld().playSound(part, soundType, soundCategory, (float) volume, (float) RNG.r.d(minPitch, maxPitch)); } if (particleType != null) { From 6d6bd4f054d08c913cb8231188325fc80e256686 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 31 Oct 2026 00:43:10 -0500 Subject: [PATCH 2/5] Keep a pack's side faces on hanging vines DecoratorCore.fixFacesForHunk cleared every face of a placed vine and re-attached it to solid neighbours, falling back to UP. A ceiling decorator that stacks vines downward therefore made a flat sheet under every block instead of a hanging curtain, whatever faces the pack set. When the pack already gives a vine a side face, keep it (the vine above holds it, as in vanilla) and add UP only where a solid ceiling is directly above. Vines without authored side faces are fixed as before. --- .../generation/decoration/DecoratorCore.java | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/core/src/main/java/art/arcane/iris/generation/decoration/DecoratorCore.java b/core/src/main/java/art/arcane/iris/generation/decoration/DecoratorCore.java index 8cee6de8e..905dbb137 100644 --- a/core/src/main/java/art/arcane/iris/generation/decoration/DecoratorCore.java +++ b/core/src/main/java/art/arcane/iris/generation/decoration/DecoratorCore.java @@ -457,40 +457,21 @@ final class DecoratorCore { BlockData rawB = (BlockData) b.nativeHandle(); BlockData cloned = rawB.clone(); MultipleFacing data = (MultipleFacing) cloned; + if (data.getFaces().stream().anyMatch(f -> f != BlockFace.UP && f != BlockFace.DOWN)) { + // The pack chose which side a hanging strand faces: keep it (the vine above holds it up), and tie the + // block under a solid ceiling to it, so ceiling decorators hang curtains instead of flat ceiling sheets. + if (data.getAllowedFaces().contains(BlockFace.UP) && sturdy(BlockFace.UP, hunk, rX, rZ, x, y, z, mantle)) { + data.setFace(BlockFace.UP, true); + } + return BukkitBlockState.of(cloned); + } data.getFaces().forEach(f -> data.setFace(f, false)); boolean found = false; for (BlockFace f : BlockFace.values()) { - if (!f.isCartesian()) { - continue; - } - int yy = y + f.getModY(); - - NativeBlockState rs = null; - if (mantle != null) { - rs = mantle.getMantle().get(x + f.getModX(), yy, z + f.getModZ(), NativeBlockState.class); - } - BlockData r = rs == null ? (BlockData) EngineMantle.AIR.get().nativeHandle() : (BlockData) rs.nativeHandle(); - if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) { - if (data.getAllowedFaces().contains(f)) { - found = true; - data.setFace(f, true); - } - continue; - } - - int xx = rX + f.getModX(); - int zz = rZ + f.getModZ(); - if (xx < 0 || xx > 15 || zz < 0 || zz > 15 || yy < 0 || yy >= hunk.getHeight()) { - continue; - } - - r = (BlockData) hunk.get(xx, yy, zz).nativeHandle(); - if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) { - if (data.getAllowedFaces().contains(f)) { - found = true; - data.setFace(f, true); - } + if (f.isCartesian() && sturdy(f, hunk, rX, rZ, x, y, z, mantle) && data.getAllowedFaces().contains(f)) { + found = true; + data.setFace(f, true); } } if (!found) { @@ -502,6 +483,22 @@ final class DecoratorCore { return BukkitBlockState.of(cloned); } + /** Whether the neighbour on that face (mantle first, then this chunk's hunk) offers a full sturdy face to attach to. */ + private static boolean sturdy(BlockFace f, Hunk hunk, int rX, int rZ, int x, int y, int z, EngineMantle mantle) { + int yy = y + f.getModY(); + NativeBlockState rs = mantle == null ? null : mantle.getMantle().get(x + f.getModX(), yy, z + f.getModZ(), NativeBlockState.class); + BlockData r = rs == null ? (BlockData) EngineMantle.AIR.get().nativeHandle() : (BlockData) rs.nativeHandle(); + if (r.isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL)) { + return true; + } + int xx = rX + f.getModX(); + int zz = rZ + f.getModZ(); + if (xx < 0 || xx > 15 || zz < 0 || zz > 15 || yy < 0 || yy >= hunk.getHeight()) { + return false; + } + return ((BlockData) hunk.get(xx, yy, zz).nativeHandle()).isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL); + } + static boolean canGoOn(NativeBlockState decorator, NativeBlockState surface) { if (!B.canPlaceOnto(decorator, surface)) { return false; From 6ed70b38563a6c6e1e45d61d0f6847a1b5908504 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 31 Oct 2026 00:43:10 -0500 Subject: [PATCH 3/5] Keep the land biome under inland water above sea level The surface biome is typed from the ground height, so a pond or stream whose floor dips below the dimension's fluid height became the region's sea biome (ocean colours and ocean spawns in a small pond on low land). When the hydrology raster marks the column as inland water (pond, channel, cascade or waterfall; not a mouth or sea inlet) whose surface is above sea level, and the base biome is a land biome, keep that land biome. --- .../iris/generation/runtime/IrisComplex.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/art/arcane/iris/generation/runtime/IrisComplex.java b/core/src/main/java/art/arcane/iris/generation/runtime/IrisComplex.java index 4bb51ddaa..72fdc9caa 100644 --- a/core/src/main/java/art/arcane/iris/generation/runtime/IrisComplex.java +++ b/core/src/main/java/art/arcane/iris/generation/runtime/IrisComplex.java @@ -1721,9 +1721,14 @@ public class IrisComplex implements DataProvider { if (mapped != null) { return mapped; } + IrisBiome base = baseBiomeStream.get(x, z); + if (base.getInferredType() == InferredType.LAND && inlandWater(x, z)) { + // a pond or stream above sea level keeps the land around it, even where its floor dips below sea level + return base; + } return fixBiomeType( terrainHeight, - baseBiomeStream.get(x, z), + base, regionStream.get(x, z), x, z, @@ -1731,6 +1736,18 @@ public class IrisComplex implements DataProvider { ); } + private boolean inlandWater(double x, double z) { + int blockX = blockCoordinate(x); + int blockZ = blockCoordinate(z); + ChunkWaterRaster raster = hydrologyRasterAt(blockX, blockZ); + if (raster.empty()) { + return false; + } + WaterRole role = raster.role(blockX & 15, blockZ & 15); + return role.wet() && role != WaterRole.MOUTH && role != WaterRole.INLET + && raster.waterHead(blockX & 15, blockZ & 15) > transitionFluidHeight(x, z, fluidHeight); + } + private IrisBiome hydrologyShoreBiome(double terrainHeight, double x, double z) { int blockX = blockCoordinate(x); int blockZ = blockCoordinate(z); From 09d6e4b720829e9c329e384c94ba1fff6952371c Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 31 Oct 2026 02:12:13 -0500 Subject: [PATCH 4/5] Let hydrology policies set the fluid of rivers A hydrology policy's fluid filled ponds and lakes, but channels always used their tier's fluid, so a volcanic region could have lava lakes but only water rivers. Each reach now takes the fluid its policy (biome, then region, then dimension) names where the reach starts, its upstream end, falling back to the tier's fluid when no policy names one, and keeps it to its downstream end. Deciding per reach rather than per column keeps a river one fluid from source to confluence, so two fluids only meet where streams join or flow into a lake, not along every border a river crosses. River plans and the plan cache are unchanged. --- .../hydrology/engine/HydrologyRuntime.java | 15 ++++++++----- .../engine/IrisHydrologyTerrainSource.java | 10 +++++++++ .../hydrology/raster/ChunkRasterizer.java | 15 ++++++++++++- .../hydrology/raster/RasterComposer.java | 22 +++++++++++++++++-- 4 files changed, 54 insertions(+), 8 deletions(-) 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 2f525c3d9..2b3c2251d 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 @@ -80,6 +80,7 @@ public final class HydrologyRuntime { private final HydrologyBinding binding; private final Function stores; private final boolean caveFluidPolicies; + private final ChunkRasterizer.AreaFluid areaFluid; private final AtomicLong rasterRevision = new AtomicLong(); private volatile PreparedHydrologyCacheIdentity storeIdentity; private boolean storeOpen; @@ -102,16 +103,19 @@ public final class HydrologyRuntime { this.binding = HydrologyBinding.UNBOUND; this.stores = identity -> null; this.caveFluidPolicies = false; + this.areaFluid = ChunkRasterizer.AreaFluid.NONE; } public HydrologyRuntime(HydrologySettings settings, HydrologyPlanCache cache, IntBinaryOperator naturalHeight, BooleanSupplier mainThread, LongSupplier ticker) { - this(settings, cache, naturalHeight, mainThread, ticker, HydrologyBinding.UNBOUND, identity -> null, false); + this(settings, cache, naturalHeight, mainThread, ticker, HydrologyBinding.UNBOUND, identity -> null, false, + ChunkRasterizer.AreaFluid.NONE); } private HydrologyRuntime(HydrologySettings settings, HydrologyPlanCache cache, IntBinaryOperator naturalHeight, BooleanSupplier mainThread, LongSupplier ticker, HydrologyBinding binding, - Function stores, boolean caveFluidPolicies) { + Function stores, boolean caveFluidPolicies, + ChunkRasterizer.AreaFluid areaFluid) { this.settings = Objects.requireNonNull(settings, "settings"); this.cache = Objects.requireNonNull(cache, "cache"); this.rasterizer = new ChunkRasterizer(settings); @@ -128,6 +132,7 @@ public final class HydrologyRuntime { this.binding = Objects.requireNonNull(binding, "binding"); this.stores = Objects.requireNonNull(stores, "stores"); this.caveFluidPolicies = caveFluidPolicies; + this.areaFluid = Objects.requireNonNull(areaFluid, "areaFluid"); } public static HydrologyRuntime create(Engine engine, IrisComplex complex) { @@ -154,7 +159,7 @@ public final class HydrologyRuntime { String dimensionKey = dimension.getLoadKey(); IrisWorld world = engine.getWorld(); return new HydrologyRuntime(settings, cache, source::naturalHeight, mainThread, System::nanoTime, binding, - identity -> store(world, dimensionKey, settings, identity), caveFluidPolicies); + identity -> store(world, dimensionKey, settings, identity), caveFluidPolicies, source::channelFluid); } static boolean requireBiomeFluids(Collection biomes, HydrologySettings settings) { @@ -516,7 +521,7 @@ public final class HydrologyRuntime { } ChunkWaterRaster raster; try (HydrologyBinding.Scope ignored = binding.open()) { - raster = rasterizer.rasterize(chunkX, chunkZ, naturalHeight, windows, lakes); + raster = rasterizer.rasterize(chunkX, chunkZ, naturalHeight, windows, lakes, areaFluid); } prefetch(chunkX, chunkZ); return raster; @@ -644,7 +649,7 @@ public final class HydrologyRuntime { try { if (!closed) { try (HydrologyBinding.Scope ignored = binding.open()) { - remember(key, rasterizer.rasterize(chunkX, chunkZ, naturalHeight, plans.windows(), plans.lakes())); + remember(key, rasterizer.rasterize(chunkX, chunkZ, naturalHeight, plans.windows(), plans.lakes(), areaFluid)); } } } catch (RuntimeException failure) { diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/engine/IrisHydrologyTerrainSource.java b/core/src/main/java/art/arcane/iris/generation/hydrology/engine/IrisHydrologyTerrainSource.java index 2cd730752..43eeb494f 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/engine/IrisHydrologyTerrainSource.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/engine/IrisHydrologyTerrainSource.java @@ -163,6 +163,16 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource return type == InferredType.SEA; } + /** The fluid this column's hydrology policy names (biome, then region, then dimension), or null if none does. */ + public String channelFluid(int x, int z) { + ChunkBakeCache.enterSparse(); + try { + return policy(biomes.get(x, z), regions.get(x, z)).fluid(); + } finally { + ChunkBakeCache.exitSparse(); + } + } + private Policy policy(IrisBiome biome, IrisRegion region) { PolicyKey key = new PolicyKey(biome, region); Policy known = policies.get(key); diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/ChunkRasterizer.java b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/ChunkRasterizer.java index 369be027d..f437dd672 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/raster/ChunkRasterizer.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/ChunkRasterizer.java @@ -33,13 +33,26 @@ public final class ChunkRasterizer { chunkX * CHUNK + CHUNK - 1 + halo, chunkZ * CHUNK + CHUNK - 1 + halo); } + /** The fluid an area's hydrology policy names for the water flowing through it, or null to keep the tier's fluid. */ + @FunctionalInterface + public interface AreaFluid { + AreaFluid NONE = (x, z) -> null; + + String at(int x, int z); + } + public ChunkWaterRaster rasterize(int chunkX, int chunkZ, IntBinaryOperator naturalHeight, List windows, List lakeRegionPlans) { + return rasterize(chunkX, chunkZ, naturalHeight, windows, lakeRegionPlans, AreaFluid.NONE); + } + + public ChunkWaterRaster rasterize(int chunkX, int chunkZ, IntBinaryOperator naturalHeight, List windows, + List lakeRegionPlans, AreaFluid areaFluid) { Objects.requireNonNull(naturalHeight, "naturalHeight"); ChunkFeatures features = ChunkFeatures.gather(settings, chunkX, chunkZ, halo, windows, lakeRegionPlans, lakeRegions(chunkX, chunkZ)); if (features.empty()) { return ChunkWaterRaster.EMPTY; } - return new RasterComposer(settings, features, chunkX, chunkZ).compose(naturalHeight); + return new RasterComposer(settings, features, chunkX, chunkZ, areaFluid).compose(naturalHeight); } } 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 36dec7012..aa36744d6 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 @@ -11,6 +11,8 @@ import art.arcane.iris.generation.hydrology.water.Reach; import art.arcane.iris.generation.hydrology.water.ReachStyle; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; import java.util.function.IntBinaryOperator; final class RasterComposer { @@ -43,8 +45,12 @@ final class RasterComposer { private final int[] inletColumn = new int[2]; private IntBinaryOperator naturalHeight; - RasterComposer(HydrologySettings settings, ChunkFeatures features, int chunkX, int chunkZ) { + private final ChunkRasterizer.AreaFluid areaFluid; + private final Map reachFluids = new HashMap<>(); + + RasterComposer(HydrologySettings settings, ChunkFeatures features, int chunkX, int chunkZ, ChunkRasterizer.AreaFluid areaFluid) { this.settings = settings; + this.areaFluid = areaFluid; this.features = features; this.originX = chunkX * CHUNK - 1; this.originZ = chunkZ * CHUNK - 1; @@ -138,7 +144,19 @@ final class RasterComposer { role[cell] = role(reach.style()[point]); feature[cell] = reach.id(); tier[cell] = reach.tier(); - fluid[cell] = reach.tier().fluid(); + fluid[cell] = reachFluid(reach); + } + + /** + * The fluid of a whole reach: the one the hydrology policy names where the reach starts (its upstream end), else the + * tier's. Deciding per reach instead of per column keeps a river one fluid from source to confluence, so two fluids + * only meet where streams join or flow into a lake, not along every region border the river crosses. + */ + private String reachFluid(Reach reach) { + return reachFluids.computeIfAbsent(reach.id(), id -> { + String area = areaFluid.at((int) Math.floor(reach.xs()[0]), (int) Math.floor(reach.zs()[0])); + return area != null ? area : reach.tier().fluid(); + }); } private static int bed(ReachCursor.Choice hit, int surface, int ground, double variation, double detail) { From 4a499c18c4c6946a44844e281d5f2c2799f31014 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 31 Oct 2026 02:12:22 -0500 Subject: [PATCH 5/5] Let a fluid set the block that forms where it meets another fluid World generation places fluids without updates, so where lava meets water or the sea the two sit side by side instead of reacting. A fluid profile can now name a seam: another fluid profile that fills its edge where it touches a different fluid or the sea (a dry column whose ground is below sea level). A profile used as a seam may hold solid blocks, e.g. lava with a seam of obsidian, magma and basalt gets a cooled crust where it meets water. Every touching cell (diagonals included) seals, plus about 60% of the cells next to those, picked by a world-position hash, so the seam is a ragged band rather than a straight line. Without a seam nothing changes. --- .../hydrology/config/IrisFluidProfile.java | 2 + .../hydrology/plan/HydrologySettings.java | 24 ++++++ .../hydrology/raster/RasterComposer.java | 73 +++++++++++++++++++ .../iris/generation/runtime/IrisComplex.java | 19 ++++- 4 files changed, 114 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/config/IrisFluidProfile.java b/core/src/main/java/art/arcane/iris/generation/hydrology/config/IrisFluidProfile.java index 808cc1f39..2b047c188 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/config/IrisFluidProfile.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/config/IrisFluidProfile.java @@ -19,4 +19,6 @@ public class IrisFluidProfile { @Required @Description("Blocks that fill the water feature.") private IrisMaterialPalette palette = new IrisMaterialPalette().qclear().qadd("minecraft:water"); + @Description("Name of another fluid profile that fills this fluid's edge where it touches a different fluid, such as obsidian where lava meets water. Worldgen places fluids without updates, so unset leaves the two fluids side by side.") + private String seam = null; } diff --git a/core/src/main/java/art/arcane/iris/generation/hydrology/plan/HydrologySettings.java b/core/src/main/java/art/arcane/iris/generation/hydrology/plan/HydrologySettings.java index 3f5c9b07f..37d5a67d0 100644 --- a/core/src/main/java/art/arcane/iris/generation/hydrology/plan/HydrologySettings.java +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/plan/HydrologySettings.java @@ -58,6 +58,7 @@ public final class HydrologySettings { private final Deformation deformation; private final Underground underground; private final Map fluids; + private final Map seams; private final int prefetchRings; private final boolean persist; private final long fingerprint; @@ -79,6 +80,7 @@ public final class HydrologySettings { this.deformation = deformation(config.getDeformation()); this.underground = underground(config.getUnderground()); this.fluids = fluids(config.getFluids()); + this.seams = seams(config.getFluids()); this.prefetchRings = config.getPrefetchRings(); this.persist = config.isPersist(); requireFluidReferences(); @@ -159,6 +161,11 @@ public final class HydrologySettings { return fluids; } + /** Fluid name -> the fluid profile that fills its edge where it touches a different fluid. */ + public Map seams() { + return seams; + } + public int prefetchRings() { return prefetchRings; } @@ -316,6 +323,16 @@ public final class HydrologySettings { return Collections.unmodifiableMap(compiled); } + private static Map seams(List profiles) { + Map seams = new LinkedHashMap<>(); + for (IrisFluidProfile profile : profiles) { + if (profile.getSeam() != null && !profile.getSeam().isBlank()) { + seams.put(profile.getName(), profile.getSeam()); + } + } + return Collections.unmodifiableMap(seams); + } + private static IrisMaterialPalette requirePalette(IrisFluidProfile profile, String field) { IrisMaterialPalette palette = profile.getPalette(); if (palette == null || unwritten(palette)) { @@ -457,6 +474,9 @@ public final class HydrologySettings { } requireFluid(ponds.fluid(), "ponds.fluid"); requireFluid(underground.cavePools().fluid(), "underground.cavePools.fluid"); + for (Map.Entry seam : seams.entrySet()) { + requireFluid(seam.getValue(), "the seam of fluid '" + seam.getKey() + "'"); + } } private void requireFluid(String name, String field) { @@ -527,6 +547,10 @@ public final class HydrologySettings { for (Map.Entry fluid : fluids.entrySet()) { hash.add(fluid.getKey()).add(fluid.getValue()); } + hash.add(seams.size()); + for (Map.Entry seam : seams.entrySet()) { + hash.add(seam.getKey()).add(seam.getValue()); + } } public record FloatRange(float min, float max) { 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 aa36744d6..192df5051 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 @@ -25,6 +25,8 @@ final class RasterComposer { private static final double CONE_EXPONENT = 0.8D; private static final double ROUNDING = 1e-6D; private static final long SALT_BANK = 0x42414e4b4e5aL; + private static final long SALT_SEAM = 0x5345414d4c4eL; + private static final double SEAM_SPREAD = 0.6D; private final HydrologySettings settings; private final ChunkFeatures features; @@ -78,6 +80,7 @@ final class RasterComposer { bermEdges(); measureLakeShores(); nameShores(); + sealSeams(); return pack(); } @@ -119,6 +122,76 @@ final class RasterComposer { } } + /** + * Where a fluid with a seam touches a different fluid (or the sea), fill its edge with the seam, e.g. a cooled-lava + * crust where lava meets water. Every touching cell seals, and about SEAM_SPREAD of the cells next to those, picked + * by a world-position hash, so the crust is a ragged band instead of a one-block line. + */ + private void sealSeams() { + Map seams = settings.seams(); + if (seams.isEmpty()) { + return; + } + boolean[] contact = new boolean[CELLS]; + for (int cell = 0; cell < CELLS; cell++) { + if (!sealable(cell, seams)) { + continue; + } + String seam = seams.get(fluid[cell]); + for (int dz = -1; dz <= 1 && !contact[cell]; dz++) { + for (int dx = -1; dx <= 1 && !contact[cell]; dx++) { + int next = neighbour(cell, dx, dz); + contact[cell] = next >= 0 && meetsOther(cell, next, seam); + } + } + } + boolean[] sealed = contact.clone(); + for (int cell = 0; cell < CELLS; cell++) { + if (contact[cell] || !sealable(cell, seams)) { + continue; + } + int x = originX + cell % GRID; + int z = originZ + cell / GRID; + if (CellHash.unit(CellHash.mix(settings.seed(), SALT_SEAM, x, z)) >= SEAM_SPREAD) { + continue; + } + for (int dz = -1; dz <= 1 && !sealed[cell]; dz++) { + for (int dx = -1; dx <= 1 && !sealed[cell]; dx++) { + int next = neighbour(cell, dx, dz); + sealed[cell] = next >= 0 && contact[next]; + } + } + } + for (int cell = 0; cell < CELLS; cell++) { + if (sealed[cell]) { + fluid[cell] = seams.get(fluid[cell]); + } + } + } + + private boolean sealable(int cell, Map seams) { + return !corner(cell) && fluid[cell] != null && role[cell].wet() && seams.containsKey(fluid[cell]); + } + + /** Whether the neighbour holds a different fluid: other hydrology water, or the sea (dry here, ground below sea level). */ + private boolean meetsOther(int cell, int next, String seam) { + if (corner(next) || next == cell) { + return false; + } + if (role[next].wet()) { + String other = fluid[next]; + return other != null && !other.equals(fluid[cell]) && !other.equals(seam); + } + return terrain[next] < settings.seaLevel(); + } + + /** The grid cell dx,dz away, or -1 outside the grid. */ + private static int neighbour(int cell, int dx, int dz) { + int x = cell % GRID + dx; + int z = cell / GRID + dz; + return x < 0 || x >= GRID || z < 0 || z >= GRID ? -1 : z * GRID + x; + } + private void standing(int cell, Pond water, int floor) { head[cell] = level(water.level()); terrain[cell] = Math.min(floor, head[cell] - 1); diff --git a/core/src/main/java/art/arcane/iris/generation/runtime/IrisComplex.java b/core/src/main/java/art/arcane/iris/generation/runtime/IrisComplex.java index 72fdc9caa..53cee7383 100644 --- a/core/src/main/java/art/arcane/iris/generation/runtime/IrisComplex.java +++ b/core/src/main/java/art/arcane/iris/generation/runtime/IrisComplex.java @@ -485,7 +485,7 @@ public class IrisComplex implements DataProvider { naturalTrueBiomeStream = new BakedStream<>(bakeCache, BakePlane.NATURAL_TRUE_BIOME, naturalTrueBiomeSource); shoreBiomes = new HydrologyShoreBiomes(engine.getDimension(), data, engine.getSeedManager().getBodies()); hydrologyRuntime = HydrologyRuntime.create(engine, this); - waterFluidStreams = hydrologyRuntime.enabled() ? createWaterFluidStreams(hydrologyRuntime.settings().fluids()) : Map.of(); + waterFluidStreams = hydrologyRuntime.enabled() ? createWaterFluidStreams(hydrologyRuntime.settings().fluids(), hydrologyRuntime.settings().seams().values()) : Map.of(); pondMaterials = hydrologyRuntime.enabled() ? hydrologyRuntime.settings().ponds().materials() : null; waterVegetation = hydrologyRuntime.enabled() ? HydrologyVegetationSource.create(engine.getDimension(), hydrologyRuntime.settings(), data, engine.getDimension().getAllRegions(engine), engine.getDimension().getReachableBiomes(engine)) : HydrologyVegetationSource.NONE; @@ -1224,12 +1224,14 @@ public class IrisComplex implements DataProvider { public record BiomePick(IrisBiome biome, InferredType type) { } - private Map> createWaterFluidStreams(Map fluids) { + private Map> createWaterFluidStreams(Map fluids, + Collection seams) { Map> streams = new HashMap<>(); int index = 0; for (Map.Entry fluid : fluids.entrySet()) { + // a seam (obsidian where lava meets water) is the solid result of two fluids meeting, not a fluid itself streams.put(fluid.getKey(), configuredFluidStream(fluid.getValue(), rng.nextParallelRNG(10900 + index), - "hydrology fluid " + fluid.getKey())); + "hydrology fluid " + fluid.getKey(), !seams.contains(fluid.getKey()))); index++; } return Map.copyOf(streams); @@ -1239,6 +1241,15 @@ public class IrisComplex implements DataProvider { IrisMaterialPalette palette, RNG fluidRng, String configurationName + ) { + return configuredFluidStream(palette, fluidRng, configurationName, true); + } + + private ProceduralStream configuredFluidStream( + IrisMaterialPalette palette, + RNG fluidRng, + String configurationName, + boolean fluidOnly ) { Objects.requireNonNull(palette, configurationName + " fluidPalette must be configured"); KList blocks = palette.getBlockData(data); @@ -1247,7 +1258,7 @@ public class IrisComplex implements DataProvider { configurationName + " fluidPalette must resolve at least one fluid block"); } for (NativeBlockState block : blocks) { - if (block == null || !block.isFluid()) { + if (block == null || fluidOnly && !block.isFluid()) { throw new IllegalArgumentException( configurationName + " fluidPalette may contain only fluid blocks"); }