From bce7efaa7267df15417b79c00b5cd3238ebf8273 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 31 Oct 2026 00:43:10 -0500 Subject: [PATCH 1/9] 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/9] 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/9] 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/9] 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/9] 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"); } From 52989ce88d6f45154a45893860ca7c953cfc938b Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Sat, 31 Oct 2026 21:42:35 -0400 Subject: [PATCH 6/9] Fluid seam fixes - Fluid seams seal from the 3x3 neighbour rasters in the effective water stage - Seam bands spread across chunk edges like any other column - Raw rasters keep their fluid so falls and history capture see the real fluid - Seams no longer change the hydrology fingerprint - Seam profiles may hold solid blocks but cannot fill tiers, ponds, cave pools or policies - A seam profile cannot name a seam of its own - Pack validation reports a policy fluid that names a seam profile - Inland water skips columns outside the transition seam weight - Channel fluid test covers the per-reach rule --- .../hydrology/config/IrisFluidProfile.java | 3 +- .../hydrology/engine/HydrologyRuntime.java | 5 +- .../engine/IrisHydrologyTerrainSource.java | 5 +- .../hydrology/plan/HydrologySettings.java | 27 +++-- .../hydrology/raster/FluidSeams.java | 112 ++++++++++++++++++ .../hydrology/raster/RasterComposer.java | 74 ------------ .../generation/runtime/EffectiveWater.java | 11 +- .../iris/generation/runtime/IrisComplex.java | 49 +++++--- .../iris/pack/PackHydrologyValidator.java | 34 +++++- .../hydrology/plan/HydrologySettingsTest.java | 38 ++++++ .../raster/ChunkWaterRasterTest.java | 15 ++- .../hydrology/raster/FluidSeamsTest.java | 87 ++++++++++++++ .../runtime/EffectiveWaterTest.java | 19 ++- .../runtime/IrisComplexSurfaceBiomeTest.java | 22 ++++ .../iris/pack/PackHydrologyValidatorTest.java | 25 ++++ 15 files changed, 403 insertions(+), 123 deletions(-) create mode 100644 core/src/main/java/art/arcane/iris/generation/hydrology/raster/FluidSeams.java create mode 100644 core/src/test/java/art/arcane/iris/generation/hydrology/raster/FluidSeamsTest.java 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 2b047c188..09876f706 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,6 +19,7 @@ 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.") + + @Description("Name of another fluid profile that lines this fluid's edge where it touches a different fluid or the sea, such as obsidian where lava meets water. The seam profile may hold solid blocks and serves only as a seam. Unset leaves the two fluids side by side.") private String seam = null; } 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 5024fbcfd..db235e1ed 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 @@ -173,10 +173,7 @@ public final class HydrologyRuntime { if (fluid == null) { continue; } - if (!settings.fluids().containsKey(fluid)) { - throw new IllegalArgumentException("Biome '" + biome.getLoadKey() + "' hydrologyPolicy.fluid names '" + fluid - + "', which is not one of the hydrology fluids " + settings.fluids().keySet()); - } + settings.requireFillingFluid(fluid, "biome '" + biome.getLoadKey() + "' hydrologyPolicy.fluid"); named = true; } return named; 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 3b7151108..7440e9ba8 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 @@ -208,9 +208,8 @@ public final class IrisHydrologyTerrainSource implements HydrologyTerrainSource, boolean climateZones = inherited(biome, region, IrisHydrologyPolicy::getClimateZones, Boolean.TRUE); requireMultiplier("rainfall", rainfall, biome, region); requireMultiplier("pondDensity", pondDensity, biome, region); - if (fluid != null && !settings.fluids().containsKey(fluid)) { - throw new IllegalArgumentException("Hydrology policy for " + where(biome, region) + " names fluid '" + fluid - + "', which is not one of the hydrology fluids " + settings.fluids().keySet()); + if (fluid != null) { + settings.requireFillingFluid(fluid, "the hydrology policy for " + where(biome, region)); } return new Policy((float) rainfall, (float) pondDensity, permission(streams, ponds), fluid, climateZones); } 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 09bcde466..c9d7a20a8 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 @@ -169,7 +169,6 @@ 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; } @@ -493,13 +492,25 @@ public final class HydrologySettings { } private void requireFluidReferences() { - for (HydrologyTier tier : tiers) { - requireFluid(tier.fluid(), "the fluid of tier '" + tier.name() + "'"); - } - 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() + "'"); + if (seams.containsKey(seam.getValue())) { + throw new IllegalArgumentException("Hydrology fluid '" + seam.getValue() + "' is the seam of fluid '" + seam.getKey() + + "' and cannot name a seam of its own"); + } + } + for (HydrologyTier tier : tiers) { + requireFillingFluid(tier.fluid(), "the fluid of tier '" + tier.name() + "'"); + } + requireFillingFluid(ponds.fluid(), "ponds.fluid"); + requireFillingFluid(underground.cavePools().fluid(), "underground.cavePools.fluid"); + } + + public void requireFillingFluid(String name, String field) { + requireFluid(name, field); + if (seams.containsValue(name)) { + throw new IllegalArgumentException("Hydrology fluid '" + name + "' in " + field + + " is a seam profile; seams only line the edges of other fluids"); } } @@ -578,10 +589,6 @@ 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/FluidSeams.java b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/FluidSeams.java new file mode 100644 index 000000000..ee403ebc1 --- /dev/null +++ b/core/src/main/java/art/arcane/iris/generation/hydrology/raster/FluidSeams.java @@ -0,0 +1,112 @@ +package art.arcane.iris.generation.hydrology.raster; + +import art.arcane.iris.generation.hydrology.grid.CellHash; + +import java.util.Map; + +public final class FluidSeams { + private static final int CHUNK = 16; + private static final int RING = 2; + private static final int WINDOW = CHUNK + 2 * RING; + private static final int CELLS = WINDOW * WINDOW; + private static final long SALT_SEAM = 0x5345414d4c4eL; + private static final double SPREAD = 0.6D; + private static final byte UNKNOWN = 0; + private static final byte LAND = 1; + private static final byte SEA = 2; + + private FluidSeams() { + } + + public static String[] seal(Map seams, long seed, int chunkX, int chunkZ, Columns columns) { + if (seams.isEmpty()) { + return null; + } + int originX = chunkX * CHUNK - RING; + int originZ = chunkZ * CHUNK - RING; + String[] fluid = new String[CELLS]; + boolean sealable = false; + for (int cell = 0; cell < CELLS; cell++) { + fluid[cell] = columns.fluid(originX + cell % WINDOW, originZ + cell / WINDOW); + sealable |= fluid[cell] != null && seams.containsKey(fluid[cell]); + } + if (!sealable) { + return null; + } + byte[] sea = new byte[CELLS]; + boolean[] contact = new boolean[CELLS]; + for (int gz = 1; gz < WINDOW - 1; gz++) { + for (int gx = 1; gx < WINDOW - 1; gx++) { + int cell = gz * WINDOW + gx; + contact[cell] = touchesOther(cell, fluid, seams, sea, columns, originX, originZ); + } + } + String[] sealed = null; + for (int lz = 0; lz < CHUNK; lz++) { + for (int lx = 0; lx < CHUNK; lx++) { + int cell = (lz + RING) * WINDOW + lx + RING; + String seam = fluid[cell] == null ? null : seams.get(fluid[cell]); + if (seam == null || !contact[cell] && !spreads(cell, fluid, contact, seed, originX, originZ)) { + continue; + } + if (sealed == null) { + sealed = new String[CHUNK * CHUNK]; + } + sealed[lz << 4 | lx] = seam; + } + } + return sealed; + } + + private static boolean touchesOther(int cell, String[] fluid, Map seams, byte[] sea, Columns columns, + int originX, int originZ) { + String own = fluid[cell]; + String seam = own == null ? null : seams.get(own); + if (seam == null) { + return false; + } + for (int dz = -1; dz <= 1; dz++) { + for (int dx = -1; dx <= 1; dx++) { + if (dx == 0 && dz == 0) { + continue; + } + int next = cell + dz * WINDOW + dx; + String other = fluid[next]; + if (other == null ? sea(next, sea, columns, originX, originZ) : !other.equals(own) && !other.equals(seam)) { + return true; + } + } + } + return false; + } + + private static boolean spreads(int cell, String[] fluid, boolean[] contact, long seed, int originX, int originZ) { + int x = originX + cell % WINDOW; + int z = originZ + cell / WINDOW; + if (CellHash.unit(CellHash.mix(seed, SALT_SEAM, x, z)) >= SPREAD) { + return false; + } + for (int dz = -1; dz <= 1; dz++) { + for (int dx = -1; dx <= 1; dx++) { + int next = cell + dz * WINDOW + dx; + if (next != cell && contact[next] && fluid[cell].equals(fluid[next])) { + return true; + } + } + } + return false; + } + + private static boolean sea(int cell, byte[] sea, Columns columns, int originX, int originZ) { + if (sea[cell] == UNKNOWN) { + sea[cell] = columns.sea(originX + cell % WINDOW, originZ + cell / WINDOW) ? SEA : LAND; + } + return sea[cell] == SEA; + } + + public interface Columns { + String fluid(int x, int z); + + boolean sea(int x, int z); + } +} 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 43107d0e0..36de70970 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 @@ -2,7 +2,6 @@ package art.arcane.iris.generation.hydrology.raster; import art.arcane.iris.generation.hydrology.config.IrisBankStyle; import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell; -import art.arcane.iris.generation.hydrology.grid.CellHash; import art.arcane.iris.generation.hydrology.plan.HydrologySettings; import art.arcane.iris.generation.hydrology.underground.SeaInlet; import art.arcane.iris.generation.hydrology.water.HydrologyTier; @@ -25,8 +24,6 @@ final class RasterComposer { private static final double ROUNDING = 1e-6D; private static final int SLOPE_REACH = 2; private static final int RAY_STEP = 4; - private static final long SALT_SEAM = 0x5345414d4c4eL; - private static final double SEAM_SPREAD = 0.6D; private final HydrologySettings settings; private final ChunkFeatures features; @@ -81,7 +78,6 @@ final class RasterComposer { bermEdges(); measureLakeShores(); nameShores(); - sealSeams(); return pack(); } @@ -123,76 +119,6 @@ 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/EffectiveWater.java b/core/src/main/java/art/arcane/iris/generation/runtime/EffectiveWater.java index fae5b74c0..ebb8e63e3 100644 --- a/core/src/main/java/art/arcane/iris/generation/runtime/EffectiveWater.java +++ b/core/src/main/java/art/arcane/iris/generation/runtime/EffectiveWater.java @@ -64,18 +64,20 @@ final class EffectiveWater { } static final class Chunk { - static final Chunk EMPTY = new Chunk(null, null, null, null); + static final Chunk EMPTY = new Chunk(null, null, null, null, null); private final long[] columns; private final WaterRole[] roles; private final boolean[] owned; private final ChunkWaterRaster raster; + private final String[] seams; - Chunk(long[] columns, WaterRole[] roles, boolean[] owned, ChunkWaterRaster raster) { + Chunk(long[] columns, WaterRole[] roles, boolean[] owned, ChunkWaterRaster raster, String[] seams) { this.columns = columns; this.roles = roles; this.owned = owned; this.raster = raster; + this.seams = seams; } long column(int lx, int lz) { @@ -93,6 +95,11 @@ final class EffectiveWater { ChunkWaterRaster raster() { return raster; } + + String fluid(int lx, int lz) { + String seam = seams == null ? null : seams[lz << 4 | lx]; + return seam != null ? seam : raster.fluid(lx, lz); + } } static final class Chunks { 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 3ddf4ab52..ad9abf4ea 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 @@ -50,7 +50,9 @@ import art.arcane.iris.generation.decoration.HydrologyVegetation; import art.arcane.iris.generation.hydrology.cave.HydrologyCaveCell; import art.arcane.iris.generation.hydrology.config.IrisHydrologyMaterials; import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime; +import art.arcane.iris.generation.hydrology.plan.HydrologySettings; import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster; +import art.arcane.iris.generation.hydrology.raster.FluidSeams; import art.arcane.iris.generation.hydrology.raster.WaterRole; import art.arcane.iris.generation.hydrology.water.HydrologyTier; import art.arcane.iris.generation.image.IrisImageMapApplication; @@ -710,7 +712,31 @@ public class IrisComplex implements DataProvider { roles[index] = effectiveRole(own, x, z, columns[index]); owned[index] = owns(own, x, z, columns[index]); } - return new EffectiveWater.Chunk(columns, roles, owned, own); + return new EffectiveWater.Chunk(columns, roles, owned, own, sealedFluids(chunkX, chunkZ, around)); + } + + private String[] sealedFluids(int chunkX, int chunkZ, ChunkWaterRaster[] around) { + HydrologySettings settings = hydrologyRuntime.settings(); + if (settings.seams().isEmpty()) { + return null; + } + return FluidSeams.seal(settings.seams(), settings.seed(), chunkX, chunkZ, new FluidSeams.Columns() { + @Override + public String fluid(int x, int z) { + ChunkWaterRaster raster = around[aroundSlot(chunkX, chunkZ, x, z)]; + if (raster.empty() || seamWeight(x, z) == 0D || !raster.role(x & 15, z & 15).wet()) { + return null; + } + return raster.fluid(x & 15, z & 15); + } + + @Override + public boolean sea(int x, int z) { + ChunkWaterRaster raster = around[aroundSlot(chunkX, chunkZ, x, z)]; + int ground = raster.empty() || seamWeight(x, z) == 0D ? naturalTrueHeight(x, z) : raster.terrainHeight(x & 15, z & 15); + return ground < transitionFluidHeight(x, z, fluidHeight); + } + }); } private long waterColumn(int blockX, int blockZ) { @@ -1247,27 +1273,18 @@ public class IrisComplex implements DataProvider { 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(), !seams.contains(fluid.getKey()))); + "hydrology fluid " + fluid.getKey(), seams.contains(fluid.getKey()))); index++; } return Map.copyOf(streams); } - private ProceduralStream configuredFluidStream( - IrisMaterialPalette palette, - RNG fluidRng, - String configurationName - ) { - return configuredFluidStream(palette, fluidRng, configurationName, true); - } - private ProceduralStream configuredFluidStream( IrisMaterialPalette palette, RNG fluidRng, String configurationName, - boolean fluidOnly + boolean allowSolids ) { Objects.requireNonNull(palette, configurationName + " fluidPalette must be configured"); KList blocks = palette.getBlockData(data); @@ -1276,7 +1293,7 @@ public class IrisComplex implements DataProvider { configurationName + " fluidPalette must resolve at least one fluid block"); } for (NativeBlockState block : blocks) { - if (block == null || fluidOnly && !block.isFluid()) { + if (block == null || !allowSolids && !block.isFluid()) { throw new IllegalArgumentException( configurationName + " fluidPalette may contain only fluid blocks"); } @@ -1305,7 +1322,8 @@ public class IrisComplex implements DataProvider { } public NativeBlockState resolveWaterFluid(int x, int z) { - String profile = chunkRasterAt(x, z).fluid(x & 15, z & 15); + EffectiveWater.Chunk chunk = effectiveChunk(x >> 4, z >> 4); + String profile = chunk != null && chunk.raster() != null ? chunk.fluid(x & 15, z & 15) : hydrologyRasterAt(x, z).fluid(x & 15, z & 15); if (profile == null) { throw new IllegalStateException("Column " + x + "," + z + " has no water fluid in its hydrology raster"); } @@ -1756,7 +1774,6 @@ public class IrisComplex implements DataProvider { } 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( @@ -1777,7 +1794,7 @@ public class IrisComplex implements DataProvider { return false; } WaterRole role = raster.role(blockX & 15, blockZ & 15); - return role.wet() && role != WaterRole.MOUTH && role != WaterRole.INLET + return role.wet() && role != WaterRole.MOUTH && role != WaterRole.INLET && seamWeight(blockX, blockZ) != 0D && raster.waterHead(blockX & 15, blockZ & 15) > transitionFluidHeight(x, z, fluidHeight); } diff --git a/core/src/main/java/art/arcane/iris/pack/PackHydrologyValidator.java b/core/src/main/java/art/arcane/iris/pack/PackHydrologyValidator.java index 887bbf8e7..57e2fcbfb 100644 --- a/core/src/main/java/art/arcane/iris/pack/PackHydrologyValidator.java +++ b/core/src/main/java/art/arcane/iris/pack/PackHydrologyValidator.java @@ -79,13 +79,14 @@ final class PackHydrologyValidator { int reported = errors.size(); validateRanges(path, hydrology, errors); Set fluids = fluidNames(hydrology); + Set seams = seamNames(hydrology); validateFluidReferences(path, hydrology, fluids, errors); IrisData loaded = data == null ? IrisData.openDatapackCompiler(packFolder) : data; IrisDimension loadedDimension = loaded.getDimensionLoader().load(dimensionKey, false); if (loadedDimension == null) { return loaded; } - validatePolicies(path, dimensionKey, loaded, loadedDimension, fluids, errors); + validatePolicies(path, dimensionKey, loaded, loadedDimension, new PolicyFluids(fluids, seams), errors); if (errors.size() == reported && validateCompile(path, loadedDimension, errors)) { validateDecoratorBlocks(path, loaded, loadedDimension.getHydrology(), errors); } @@ -190,6 +191,22 @@ final class PackHydrologyValidator { return names; } + private static Set seamNames(JSONObject hydrology) { + JSONArray profiles = hydrology.optJSONArray("fluids"); + if (profiles == null) { + return Set.of(); + } + Set seams = new LinkedHashSet<>(); + for (int index = 0; index < profiles.length(); index++) { + JSONObject profile = profiles.optJSONObject(index); + String seam = profile == null ? null : profile.optString("seam", null); + if (seam != null && !seam.isBlank()) { + seams.add(seam); + } + } + return seams; + } + private static void validateFluidReferences(String path, JSONObject hydrology, Set fluids, List errors) { JSONArray tiers = hydrology.optJSONArray("tiers"); if (tiers == null) { @@ -208,7 +225,7 @@ final class PackHydrologyValidator { } } - private static void validatePolicies(String path, String dimensionKey, IrisData data, IrisDimension dimension, Set fluids, + private static void validatePolicies(String path, String dimensionKey, IrisData data, IrisDimension dimension, PolicyFluids fluids, List errors) { validatePolicy("Dimension '" + dimensionKey + "'." + POLICY, dimension.getHydrologyPolicy(), data, fluids, path, errors); List regions = new ArrayList<>(dimension.getAllRegions(() -> data)); @@ -227,13 +244,17 @@ final class PackHydrologyValidator { } } - private static void validatePolicy(String field, IrisHydrologyPolicy policy, IrisData data, Set fluids, String configPath, + private static void validatePolicy(String field, IrisHydrologyPolicy policy, IrisData data, PolicyFluids fluids, String configPath, List errors) { if (policy == null) { return; } - if (policy.getFluid() != null) { - requireFluid(field + ".fluid", policy.getFluid(), fluids, configPath, errors); + String fluid = policy.getFluid(); + if (fluid != null) { + requireFluid(field + ".fluid", fluid, fluids.defined(), configPath, errors); + if (fluids.seams().contains(fluid)) { + errors.add(field + ".fluid names fluid '" + fluid + "', which is a seam profile; seams only line the edges of other fluids."); + } } if (policy.getDecorators() != null) { validateDecorators(field + ".decorators", policy.getDecorators(), data, errors); @@ -283,4 +304,7 @@ final class PackHydrologyValidator { warnings = List.copyOf(warnings); } } + + private record PolicyFluids(Set defined, Set seams) { + } } diff --git a/core/src/test/java/art/arcane/iris/generation/hydrology/plan/HydrologySettingsTest.java b/core/src/test/java/art/arcane/iris/generation/hydrology/plan/HydrologySettingsTest.java index f34ed7f57..714447c0c 100644 --- a/core/src/test/java/art/arcane/iris/generation/hydrology/plan/HydrologySettingsTest.java +++ b/core/src/test/java/art/arcane/iris/generation/hydrology/plan/HydrologySettingsTest.java @@ -3,6 +3,7 @@ package art.arcane.iris.generation.hydrology.plan; 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.IrisHydrology; import art.arcane.iris.generation.hydrology.config.IrisHydrologyMaterials; import art.arcane.iris.generation.hydrology.water.HydrologyTier; @@ -17,6 +18,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import static org.junit.Assert.assertEquals; @@ -250,6 +252,33 @@ public class HydrologySettingsTest { assertRejected(config, "lava"); } + @Test + public void seamsLeaveTheFingerprintAlone() { + assertEquals(compile(lavaAndCrust(null)).fingerprint(), compile(lavaAndCrust("crust")).fingerprint()); + assertEquals(Map.of("lava", "crust"), compile(lavaAndCrust("crust")).seams()); + assertTrue(compile(lavaAndCrust(null)).seams().isEmpty()); + } + + @Test + public void compileRejectsAnUnknownSeam() { + assertRejected(lavaAndCrust("ash"), "ash"); + } + + @Test + public void compileRejectsASeamThatAlsoFillsWater() { + IrisHydrology tier = lavaAndCrust("crust"); + tier.getTiers().get(2).setFluid("crust"); + assertRejected(tier, "crust"); + + IrisHydrology ponds = lavaAndCrust("crust"); + ponds.getPonds().setFluid("crust"); + assertRejected(ponds, "crust"); + + IrisHydrology chained = lavaAndCrust("crust"); + chained.getFluids().get(2).setSeam("lava"); + assertRejected(chained, "crust"); + } + @Test public void compileRejectsMalformedRange() { IrisHydrology inverted = new IrisHydrology(); @@ -554,6 +583,15 @@ public class HydrologySettingsTest { assertTrue(failure.getMessage(), failure.getMessage().contains("\"palette\" list is missing, misspelt or empty")); } + private static IrisHydrology lavaAndCrust(String seam) { + IrisHydrology config = new IrisHydrology(); + config.getFluids().add(new IrisFluidProfile().setName("lava").setSeam(seam) + .setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:lava"))); + config.getFluids().add(new IrisFluidProfile().setName("crust") + .setPalette(new IrisMaterialPalette().qclear().qadd("minecraft:obsidian"))); + return config; + } + private static HydrologySettings compile(IrisHydrology config) { return HydrologySettings.compile(config, SEED, SEA_LEVEL, MIN_Y, MAX_Y); } diff --git a/core/src/test/java/art/arcane/iris/generation/hydrology/raster/ChunkWaterRasterTest.java b/core/src/test/java/art/arcane/iris/generation/hydrology/raster/ChunkWaterRasterTest.java index 4d1f1c065..d7b76de46 100644 --- a/core/src/test/java/art/arcane/iris/generation/hydrology/raster/ChunkWaterRasterTest.java +++ b/core/src/test/java/art/arcane/iris/generation/hydrology/raster/ChunkWaterRasterTest.java @@ -465,11 +465,14 @@ public class ChunkWaterRasterTest { } @Test - public void channelTakesTheAreaFluidWhereOneIsSet() { + public void reachKeepsThePolicyFluidOfItsUpstreamEnd() { HydrologySettings settings = settings(new IrisHydrology()); - Reach reach = line(61L, tier("stream", 1.5f, 0.5f, 0, IrisBankStyle.SMOOTH), 0L, 400f, 400f, 480f, 400f, (x, z) -> 69); + HydrologyTier stream = tier("stream", 1.5f, 0.5f, 0, IrisBankStyle.SMOOTH); + Reach outflow = line(61L, stream, 0L, 400f, 403f, 480f, 403f, (x, z) -> 69); + Reach inflow = line(62L, stream, 0L, 480f, 412f, 400f, 412f, (x, z) -> 69); WindowKey key = new WindowKey(0, 0); - IndexedWindow own = new IndexedWindow(new WindowPlan(key, List.of(reach), List.of(), List.of()), ReachIndex.build(List.of(reach), List.of())); + IndexedWindow own = new IndexedWindow(new WindowPlan(key, List.of(outflow, inflow), List.of(), List.of()), + ReachIndex.build(List.of(outflow, inflow), List.of())); ChannelFluids volcanic = (x, z) -> x < 440 ? "lava" : null; ChunkWaterRaster raster = new ChunkRasterizer(settings, volcanic).rasterize(27, 25, (x, z) -> 70, List.of(own), regions(27, 25, List.of())); int lava = 0; @@ -479,9 +482,9 @@ public class ChunkWaterRasterTest { if (!isChannel(raster.role(lx, lz))) { continue; } - boolean inside = 27 * 16 + lx < 440; - assertEquals("column " + lx + "," + lz, inside ? "lava" : "water", raster.fluid(lx, lz)); - if (inside) { + boolean startsVolcanic = raster.featureId(lx, lz) == 61L; + assertEquals("column " + lx + "," + lz, startsVolcanic ? "lava" : "water", raster.fluid(lx, lz)); + if (startsVolcanic) { lava++; } else { water++; diff --git a/core/src/test/java/art/arcane/iris/generation/hydrology/raster/FluidSeamsTest.java b/core/src/test/java/art/arcane/iris/generation/hydrology/raster/FluidSeamsTest.java new file mode 100644 index 000000000..afd9002f8 --- /dev/null +++ b/core/src/test/java/art/arcane/iris/generation/hydrology/raster/FluidSeamsTest.java @@ -0,0 +1,87 @@ +package art.arcane.iris.generation.hydrology.raster; + +import org.junit.Test; + +import java.util.Map; +import java.util.function.IntFunction; +import java.util.function.IntPredicate; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +public class FluidSeamsTest { + private static final long SEED = 4242L; + private static final Map LAVA_CRUST = Map.of("lava", "crust"); + + @Test + public void lavaSealsEveryColumnTouchingWater() { + FluidSeams.Columns columns = columns(x -> x < 100 ? "lava" : "water", x -> false); + String[] sealed = FluidSeams.seal(LAVA_CRUST, SEED, 6, 0, columns); + int spread = 0; + for (int lz = 0; lz < 16; lz++) { + for (int lx = 0; lx < 16; lx++) { + int x = 96 + lx; + String seam = sealed[lz << 4 | lx]; + if (x == 99) { + assertEquals("touching column " + x + "," + lz, "crust", seam); + } else if (x == 98) { + spread += seam == null ? 0 : 1; + } else { + assertNull("column " + x + "," + lz, seam); + } + } + } + assertTrue("spread columns " + spread, spread > 0 && spread < 16); + } + + @Test + public void spreadReachesAcrossTheChunkEdge() { + FluidSeams.Columns columns = columns(x -> x < 97 ? "lava" : "water", x -> false); + int spread = 0; + int rows = 0; + for (int chunkZ = 0; chunkZ < 8; chunkZ++) { + String[] west = FluidSeams.seal(LAVA_CRUST, SEED, 5, chunkZ, columns); + String[] east = FluidSeams.seal(LAVA_CRUST, SEED, 6, chunkZ, columns); + for (int lz = 0; lz < 16; lz++) { + rows++; + assertEquals("crust", east[lz << 4]); + assertNull(west[lz << 4 | 14]); + spread += west[lz << 4 | 15] == null ? 0 : 1; + } + } + double fraction = spread / (double) rows; + assertTrue("spread fraction at the chunk edge " + fraction, fraction > 0.45D && fraction < 0.75D); + } + + @Test + public void dryGroundBelowSeaLevelCountsAsTheSea() { + String[] sea = FluidSeams.seal(LAVA_CRUST, SEED, 6, 0, columns(x -> x < 100 ? "lava" : null, x -> x >= 100)); + for (int lz = 0; lz < 16; lz++) { + assertEquals("crust", sea[lz << 4 | 3]); + } + assertNull(FluidSeams.seal(LAVA_CRUST, SEED, 6, 0, columns(x -> x < 100 ? "lava" : null, x -> false))); + } + + @Test + public void nothingSealsWithoutASeamOrAnotherFluid() { + assertNull(FluidSeams.seal(Map.of(), SEED, 6, 0, columns(x -> x < 100 ? "lava" : "water", x -> false))); + assertNull(FluidSeams.seal(LAVA_CRUST, SEED, 6, 0, columns(x -> "water", x -> true))); + assertNull(FluidSeams.seal(LAVA_CRUST, SEED, 6, 0, columns(x -> "lava", x -> false))); + assertNull(FluidSeams.seal(LAVA_CRUST, SEED, 6, 0, columns(x -> x < 100 ? "lava" : "crust", x -> false))); + } + + private static FluidSeams.Columns columns(IntFunction fluid, IntPredicate sea) { + return new FluidSeams.Columns() { + @Override + public String fluid(int x, int z) { + return fluid.apply(x); + } + + @Override + public boolean sea(int x, int z) { + return sea.test(x); + } + }; + } +} diff --git a/core/src/test/java/art/arcane/iris/generation/runtime/EffectiveWaterTest.java b/core/src/test/java/art/arcane/iris/generation/runtime/EffectiveWaterTest.java index dc4654c73..fb898e245 100644 --- a/core/src/test/java/art/arcane/iris/generation/runtime/EffectiveWaterTest.java +++ b/core/src/test/java/art/arcane/iris/generation/runtime/EffectiveWaterTest.java @@ -2,6 +2,7 @@ package art.arcane.iris.generation.runtime; import art.arcane.iris.generation.context.ChunkContext; import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime; +import art.arcane.iris.generation.hydrology.raster.ChunkWaterRaster; import art.arcane.iris.generation.hydrology.raster.WaterRole; import art.arcane.iris.generation.hydrology.water.Pond; import art.arcane.iris.generation.hydrology.water.Reach; @@ -159,11 +160,25 @@ public class EffectiveWaterTest { } } + @Test + public void sealedColumnsTakeTheirSeamAndTheRestKeepTheRasterFluid() { + ChunkWaterRaster raster = mock(ChunkWaterRaster.class); + when(raster.fluid(anyInt(), anyInt())).thenReturn("lava"); + String[] seams = new String[256]; + seams[3 << 4 | 2] = "crust"; + EffectiveWater.Chunk sealed = new EffectiveWater.Chunk(new long[256], new WaterRole[256], new boolean[256], raster, seams); + EffectiveWater.Chunk open = new EffectiveWater.Chunk(new long[256], new WaterRole[256], new boolean[256], raster, null); + + assertEquals("crust", sealed.fluid(2, 3)); + assertEquals("lava", sealed.fluid(3, 2)); + assertEquals("lava", open.fluid(2, 3)); + } + @Test public void chunksSharingACacheSlotNeverAnswerForEachOther() { EffectiveWater.Chunks chunks = new EffectiveWater.Chunks(); - EffectiveWater.Chunk first = new EffectiveWater.Chunk(new long[256], new WaterRole[256], new boolean[256], null); - EffectiveWater.Chunk second = new EffectiveWater.Chunk(new long[256], new WaterRole[256], new boolean[256], null); + EffectiveWater.Chunk first = new EffectiveWater.Chunk(new long[256], new WaterRole[256], new boolean[256], null, null); + EffectiveWater.Chunk second = new EffectiveWater.Chunk(new long[256], new WaterRole[256], new boolean[256], null, null); chunks.put(0, 0, first); assertSame(first, chunks.get(0, 0)); diff --git a/core/src/test/java/art/arcane/iris/generation/runtime/IrisComplexSurfaceBiomeTest.java b/core/src/test/java/art/arcane/iris/generation/runtime/IrisComplexSurfaceBiomeTest.java index 2ddc92d48..d5a75fe01 100644 --- a/core/src/test/java/art/arcane/iris/generation/runtime/IrisComplexSurfaceBiomeTest.java +++ b/core/src/test/java/art/arcane/iris/generation/runtime/IrisComplexSurfaceBiomeTest.java @@ -24,6 +24,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import java.nio.file.Files; import java.nio.file.Path; import java.util.HashSet; import java.util.Set; @@ -39,6 +40,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class IrisComplexSurfaceBiomeTest { + private static final int INLAND_SEA_LEVEL = 85; + @ClassRule public static final PlatformLeakGuard PLATFORM_GUARD = PlatformLeakGuard.clean(); @Rule @@ -208,6 +211,25 @@ public class IrisComplexSurfaceBiomeTest { } } + @Test(timeout = 120_000L) + public void pondAboveSeaLevelKeepsTheLandBiomeOverAFloorBelowIt() throws Exception { + Path pack = HydrologyFixture.pack(temporaryFolder.newFolder().toPath(), null, null); + Files.writeString(pack.resolve("dimensions/main.json"), """ + {"regions":["plain"],"landChance":1,"fluidHeight":%d,"carvingEnabled":false} + """.formatted(INLAND_SEA_LEVEL)); + Files.writeString(pack.resolve("regions/plain.json"), "{\"landBiomes\":[\"plain\"],\"seaBiomes\":[\"ocean\"]}"); + Files.writeString(pack.resolve("biomes/ocean.json"), "{\"generators\":[{\"generator\":\"flat\",\"min\":10,\"max\":10}]}"); + try (HydrologyFixture fixture = new HydrologyFixture(pack)) { + ChunkWaterRaster raster = fixture.hydrology.runtime.raster(0, 0); + int sea = fixture.engine.getDimension().getFluidHeight(); + assertEquals(WaterRole.POND, raster.role(8, 8)); + assertTrue("the pond floor sits below sea level", raster.terrainHeight(8, 8) < sea); + assertTrue("the pond surface sits above sea level", raster.waterHead(8, 8) > sea); + assertTrue("the land around the pond sits above sea level", HydrologyFixture.NATURAL > sea); + assertEquals("plain", fixture.complex.getTrueBiomeStream().get(8, 8).getLoadKey()); + } + } + private static int shoreColumn(HydrologyFixture fixture, int distance) { for (int x = 0; x < 64; x++) { ChunkWaterRaster raster = fixture.hydrology.runtime.raster(x >> 4, 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 8fc16c27d..6247acbae 100644 --- a/core/src/test/java/art/arcane/iris/pack/PackHydrologyValidatorTest.java +++ b/core/src/test/java/art/arcane/iris/pack/PackHydrologyValidatorTest.java @@ -93,6 +93,31 @@ public class PackHydrologyValidatorTest { assertEquals(validation.errors().toString(), 6, validation.errors().size()); } + @Test + public void rejectsPoliciesThatFillWaterWithASeamProfile() throws Exception { + File pack = pack(dimension(""" + { + "enabled": true, + "fluids": [ + {"name": "water"}, + {"name": "lava", "palette": {"palette": [{"block": "minecraft:lava"}]}, "seam": "crust"}, + {"name": "crust", "palette": {"palette": [{"block": "minecraft:obsidian"}]}} + ] + } + """, "")); + write(pack, "regions/region.json", """ + {"landBiomes": ["biome"], "hydrologyPolicy": {"fluid": "lava"}} + """); + write(pack, "biomes/biome.json", """ + {"name": "Biome", "hydrologyPolicy": {"fluid": "crust"}} + """); + + List errors = validate(pack).errors(); + + assertContains(errors, "Biome 'biome'.hydrologyPolicy.fluid names fluid 'crust', which is a seam profile"); + assertEquals(errors.toString(), 1, errors.size()); + } + @Test public void rejectsFluidReferencesTheFluidProfilesDoNotDefine() throws Exception { File pack = pack(dimension(""" From c2eb8b5f424c2b469b85e928bd1590166ad9ce5b Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Sat, 31 Oct 2026 21:58:58 -0400 Subject: [PATCH 7/9] Fixed effect sounds and vines - Store the effect sound category as a vanilla category name - Resolve the sound category to a Bukkit category when an effect plays - Send modded effect sounds on the authored category - Skip the sound and warn once for an unknown sound category - Keep authored vine side faces only where a sturdy block or the vine above holds them - Attach kept vine faces upward under a sturdy block - Reattach multi-face blocks with no holdable side face to sturdy neighbours - Cover sound category and vine face rules on Bukkit and modded - Repin the studio schema digest --- .../iris/modded/ModdedEngineEffects.java | 11 +- .../iris/modded/ModdedDecoratorHooksTest.java | 127 ++++++++++++++++++ .../modded/NativePlayerEffectsTest.java | 69 ++++++++++ .../generation/decoration/DecoratorCore.java | 79 ++++++++--- .../arcane/iris/world/entity/IrisEffect.java | 51 ++++++- .../decoration/DecoratorCoreTest.java | 127 ++++++++++++++++++ .../schema/SchemaBuilderIdentityTest.java | 2 +- .../entity/IrisEffectSoundCategoryTest.java | 58 ++++++++ 8 files changed, 498 insertions(+), 26 deletions(-) create mode 100644 adapters/modded-common/src/test/java/art/arcane/volmlib/nativelib/minecraft26_2/modded/NativePlayerEffectsTest.java create mode 100644 core/src/test/java/art/arcane/iris/world/entity/IrisEffectSoundCategoryTest.java diff --git a/adapters/modded-common/src/main/java/art/arcane/iris/modded/ModdedEngineEffects.java b/adapters/modded-common/src/main/java/art/arcane/iris/modded/ModdedEngineEffects.java index dd101010d..2b3a58977 100644 --- a/adapters/modded-common/src/main/java/art/arcane/iris/modded/ModdedEngineEffects.java +++ b/adapters/modded-common/src/main/java/art/arcane/iris/modded/ModdedEngineEffects.java @@ -55,6 +55,7 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement private static final double PLAYER_REFRESH_CHANCE = 0.02D; private static final Set UNKNOWN_POTIONS = ConcurrentHashMap.newKeySet(); private static final Set UNKNOWN_SOUNDS = ConcurrentHashMap.newKeySet(); + private static final Set UNKNOWN_SOUND_CATEGORIES = ConcurrentHashMap.newKeySet(); private static final Set UNKNOWN_PARTICLES = ConcurrentHashMap.newKeySet(); private static final Set UNSUPPORTED_PARTICLES = ConcurrentHashMap.newKeySet(); @@ -252,6 +253,14 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement warnUnknown(UNKNOWN_SOUNDS, "sound", key); return; } + String categoryKey = effect.getSoundCategoryKey(); + NativePlayerEffects.SoundCategory category = NativePlayerEffects.soundCategory(categoryKey); + if (category == null) { + if (UNKNOWN_SOUND_CATEGORIES.add(categoryKey)) { + IrisLogging.warn("Unknown sound category: \"" + categoryKey + "\"."); + } + return; + } int distance = effect.getSoundDistance(); double x = player.x() + RNG.r.i(-distance, distance); @@ -260,7 +269,7 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement float volume = (float) effect.getVolume(); float pitch = (float) RNG.r.d(effect.getMinPitch(), effect.getMaxPitch()); NativePlayerEffects.sound(player, sound, new NativePlayerEffects.SoundEmission( - x, y, z, volume, pitch, ThreadLocalRandom.current().nextLong())); + category, x, y, z, volume, pitch, ThreadLocalRandom.current().nextLong())); } private void applyParticles(NativeWorld level, NativeProtocolPlayer player, IrisEffect effect) { diff --git a/adapters/modded-common/src/test/java/art/arcane/iris/modded/ModdedDecoratorHooksTest.java b/adapters/modded-common/src/test/java/art/arcane/iris/modded/ModdedDecoratorHooksTest.java index c9bb86add..0cfbb8e9d 100644 --- a/adapters/modded-common/src/test/java/art/arcane/iris/modded/ModdedDecoratorHooksTest.java +++ b/adapters/modded-common/src/test/java/art/arcane/iris/modded/ModdedDecoratorHooksTest.java @@ -1,14 +1,32 @@ package art.arcane.iris.modded; +import art.arcane.iris.generation.mantle.EngineMantle; +import art.arcane.volmlib.nativelib.minecraft26_2.modded.ModdedBlockState; import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeBlockFaces; import art.arcane.volmlib.nativelib.terrain.NativeBlockState; import art.arcane.volmlib.util.hunk.Hunk; +import art.arcane.volmlib.util.mantle.runtime.Mantle; +import art.arcane.volmlib.util.matter.Matter; +import net.minecraft.SharedConstants; +import net.minecraft.core.Direction; +import net.minecraft.server.Bootstrap; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.junit.BeforeClass; import org.junit.Test; import org.mockito.MockedStatic; +import java.util.EnumSet; +import java.util.Set; + +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; @@ -17,6 +35,12 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; public class ModdedDecoratorHooksTest { + @BeforeClass + public static void bootstrap() { + SharedConstants.tryDetectVersion(); + Bootstrap.bootStrap(); + } + @Test public void faceFixingExcludesTheUpperBoundaryWhileKeepingTheLastRowAccessible() { NativeBlockState state = mock(NativeBlockState.class); @@ -41,4 +65,107 @@ public class ModdedDecoratorHooksTest { verify(hunk, never()).get(1, 4, 2); verify(hunk).get(1, 3, 2); } + + @Test + public void stackedVineCurtainHangsFromTheWallItsTopStrandFaces() { + Hunk hunk = Hunk.newArrayHunk(16, 8, 16); + hunk.set(8, 6, 8, stone()); + hunk.set(8, 5, 7, stone()); + hunk.set(9, 4, 8, stone()); + NativeBlockState vine = state(Blocks.VINE, Direction.NORTH); + + for (int y = 5; y >= 3; y--) { + hunk.set(8, y, 8, fix(vine, hunk, y)); + } + + assertEquals(EnumSet.of(Direction.NORTH, Direction.UP), faces(hunk.get(8, 5, 8))); + assertEquals(EnumSet.of(Direction.NORTH), faces(hunk.get(8, 4, 8))); + assertEquals(EnumSet.of(Direction.NORTH), faces(hunk.get(8, 3, 8))); + } + + @Test + public void unsupportedAuthoredSideFaceOnALoneVineIsDroppedAndReattached() { + NativeBlockState vine = state(Blocks.VINE, Direction.NORTH); + Hunk walled = Hunk.newArrayHunk(16, 8, 16); + walled.set(9, 3, 8, stone()); + + assertEquals(EnumSet.of(Direction.EAST), faces(fix(vine, walled, 3))); + assertEquals(EnumSet.of(Direction.UP), faces(fix(vine, Hunk.newArrayHunk(16, 8, 16), 3))); + } + + @Test + public void glowLichenSideFaceIsNotHeldByTheLichenAboveIt() { + NativeBlockState lichen = state(Blocks.GLOW_LICHEN, Direction.NORTH); + Hunk hunk = Hunk.newArrayHunk(16, 8, 16); + hunk.set(8, 2, 8, stone()); + hunk.set(8, 4, 8, state(Blocks.GLOW_LICHEN, Direction.NORTH)); + + assertEquals(EnumSet.of(Direction.DOWN), faces(fix(lichen, hunk, 3))); + } + + @Test + public void supportedAuthoredSideFaceKeepsItsDirection() { + NativeBlockState vine = state(Blocks.VINE, Direction.NORTH); + Hunk hunk = Hunk.newArrayHunk(16, 8, 16); + hunk.set(8, 3, 7, stone()); + hunk.set(9, 3, 8, stone()); + + assertEquals(EnumSet.of(Direction.NORTH), faces(fix(vine, hunk, 3))); + } + + @Test + public void vineWithoutAuthoredSideFaceReattachesToEverySturdyNeighbour() { + NativeBlockState vine = state(Blocks.VINE, Direction.UP); + Hunk hunk = Hunk.newArrayHunk(16, 8, 16); + hunk.set(7, 3, 8, stone()); + hunk.set(8, 3, 9, stone()); + hunk.set(8, 4, 8, stone()); + + assertEquals(EnumSet.of(Direction.SOUTH, Direction.WEST, Direction.UP), faces(fix(vine, hunk, 3))); + } + + @SuppressWarnings("unchecked") + private static NativeBlockState fix(NativeBlockState state, Hunk hunk, int y) { + EngineMantle mantle = mock(EngineMantle.class); + Mantle storage = mock(Mantle.class); + NativeBlockState air = ModdedBlockState.of(Blocks.AIR.defaultBlockState(), null); + when(mantle.getMantle()).thenReturn(storage); + when(storage.get(anyInt(), anyInt(), anyInt(), eq(NativeBlockState.class))).thenReturn(air); + return new ModdedDecoratorHooks().fixFaces(state, hunk, 8, 8, 8, y, 8, mantle); + } + + private static NativeBlockState stone() { + return ModdedBlockState.of(Blocks.STONE.defaultBlockState(), null); + } + + private static NativeBlockState state(Block block, Direction... faces) { + BlockState state = block.defaultBlockState(); + for (Direction face : faces) { + state = state.setValue(property(face), Boolean.TRUE); + } + return ModdedBlockState.of(state, null); + } + + private static Set faces(NativeBlockState state) { + BlockState handle = (BlockState) state.nativeHandle(); + EnumSet faces = EnumSet.noneOf(Direction.class); + for (Direction face : Direction.values()) { + BooleanProperty property = property(face); + if (handle.hasProperty(property) && handle.getValue(property)) { + faces.add(face); + } + } + return faces; + } + + private static BooleanProperty property(Direction face) { + return switch (face) { + case NORTH -> BlockStateProperties.NORTH; + case EAST -> BlockStateProperties.EAST; + case SOUTH -> BlockStateProperties.SOUTH; + case WEST -> BlockStateProperties.WEST; + case UP -> BlockStateProperties.UP; + case DOWN -> BlockStateProperties.DOWN; + }; + } } diff --git a/adapters/modded-common/src/test/java/art/arcane/volmlib/nativelib/minecraft26_2/modded/NativePlayerEffectsTest.java b/adapters/modded-common/src/test/java/art/arcane/volmlib/nativelib/minecraft26_2/modded/NativePlayerEffectsTest.java new file mode 100644 index 000000000..31f35745b --- /dev/null +++ b/adapters/modded-common/src/test/java/art/arcane/volmlib/nativelib/minecraft26_2/modded/NativePlayerEffectsTest.java @@ -0,0 +1,69 @@ +package art.arcane.volmlib.nativelib.minecraft26_2.modded; + +import art.arcane.iris.world.entity.IrisEffect; +import net.minecraft.SharedConstants; +import net.minecraft.network.protocol.game.ClientboundSoundPacket; +import net.minecraft.server.Bootstrap; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.sounds.SoundSource; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.ArgumentCaptor; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +public class NativePlayerEffectsTest { + private static final String SOUND = "minecraft:block.amethyst_block.chime"; + + @BeforeClass + public static void bootstrap() { + SharedConstants.tryDetectVersion(); + Bootstrap.bootStrap(); + } + + @Test + public void everyVanillaSoundSourceIsReachableByItsName() { + for (SoundSource source : SoundSource.values()) { + assertSame(source.getName(), source, sentSource(NativePlayerEffects.soundCategory(source.getName()))); + } + } + + @Test + public void effectCategoryNamesResolveIgnoringCase() { + assertSame(SoundSource.AMBIENT, sentSource(category(" Ambient "))); + assertSame(SoundSource.RECORDS, sentSource(category("RECORD"))); + assertSame(SoundSource.MASTER, sentSource(category(null))); + } + + @Test + public void unknownCategoryNamesDoNotResolve() { + assertNull(category("ambiant")); + assertNull(category("records")); + assertNull(category("players")); + } + + private static NativePlayerEffects.SoundCategory category(String authored) { + return NativePlayerEffects.soundCategory(new IrisEffect().setSoundCategory(authored).getSoundCategoryKey()); + } + + private static SoundSource sentSource(NativePlayerEffects.SoundCategory category) { + assertNotNull(category); + NativePlayerEffects.Sound sound = NativePlayerEffects.sound(SOUND); + assertNotNull(sound); + ServerPlayer handle = mock(ServerPlayer.class); + ServerGamePacketListenerImpl connection = mock(ServerGamePacketListenerImpl.class); + handle.connection = connection; + + NativePlayerEffects.sound(NativeProtocolPlayer.fromHandle(handle), sound, + new NativePlayerEffects.SoundEmission(category, 1.0D, 64.0D, -3.0D, 1.0F, 1.0F, 7L)); + + ArgumentCaptor packet = ArgumentCaptor.forClass(ClientboundSoundPacket.class); + verify(connection).send(packet.capture()); + return packet.getValue().getSource(); + } +} 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 905dbb137..9859db55b 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 @@ -37,6 +37,7 @@ final class DecoratorCore { private static final long SEED_OFFSET = 29356788L; private static final long PART_FACTOR = 10439677L; + private static final String VINE = "minecraft:vine"; private static final String WEEPING_VINES = "minecraft:weeping_vines"; private static final String WEEPING_VINES_PLANT = "minecraft:weeping_vines_plant"; private static final String TWISTING_VINES = "minecraft:twisting_vines"; @@ -454,22 +455,20 @@ final class DecoratorCore { if (fixer != null) { return fixer.fixFaces(b, hunk, rX, rZ, x, y, z, mantle); } - BlockData rawB = (BlockData) b.nativeHandle(); - BlockData cloned = rawB.clone(); + BlockData cloned = ((BlockData) b.nativeHandle()).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); - } + if (keepSupportedSides(data, VINE.equals(IrisProceduralBlocks.materialKey(b)), hunk, rX, rZ, x, y, z, mantle)) { return BukkitBlockState.of(cloned); } - data.getFaces().forEach(f -> data.setFace(f, false)); + for (BlockFace f : Faces.CARTESIAN) { + if (data.hasFace(f)) { + data.setFace(f, false); + } + } boolean found = false; - for (BlockFace f : BlockFace.values()) { - if (f.isCartesian() && sturdy(f, hunk, rX, rZ, x, y, z, mantle) && data.getAllowedFaces().contains(f)) { + for (BlockFace f : Faces.CARTESIAN) { + if (data.getAllowedFaces().contains(f) && sturdy(f, hunk, rX, rZ, x, y, z, mantle)) { found = true; data.setFace(f, true); } @@ -483,20 +482,58 @@ 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 keepSupportedSides(MultipleFacing data, boolean vine, Hunk hunk, + int rX, int rZ, int x, int y, int z, EngineMantle mantle) { + boolean side = false; + for (BlockFace f : Faces.SIDES) { + if (!data.hasFace(f)) { + continue; + } + if (sturdy(f, hunk, rX, rZ, x, y, z, mantle) || vine && vineAboveCarries(f, hunk, rX, rZ, x, y, z, mantle)) { + side = true; + } else { + data.setFace(f, false); + } + } + if (!side) { + return false; + } + if (data.getAllowedFaces().contains(BlockFace.UP)) { + data.setFace(BlockFace.UP, sturdy(BlockFace.UP, hunk, rX, rZ, x, y, z, mantle)); + } + if (data.hasFace(BlockFace.DOWN) && !sturdy(BlockFace.DOWN, hunk, rX, rZ, x, y, z, mantle)) { + data.setFace(BlockFace.DOWN, false); + } + return true; + } + 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)) { + BlockFace attached = f.getOppositeFace(); + if (mantle != null && sturdy(mantle.getMantle().get(x + f.getModX(), yy, z + f.getModZ(), NativeBlockState.class), attached)) { 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 xx >= 0 && xx <= 15 && zz >= 0 && zz <= 15 && yy >= 0 && yy < hunk.getHeight() + && sturdy(hunk.get(xx, yy, zz), attached); + } + + private static boolean sturdy(NativeBlockState state, BlockFace attached) { + return state != null && ((BlockData) state.nativeHandle()).isFaceSturdy(attached, BlockSupport.FULL); + } + + private static boolean vineAboveCarries(BlockFace f, Hunk hunk, int rX, int rZ, + int x, int y, int z, EngineMantle mantle) { + if (mantle != null && carries(mantle.getMantle().get(x, y + 1, z, NativeBlockState.class), f)) { + return true; } - return ((BlockData) hunk.get(xx, yy, zz).nativeHandle()).isFaceSturdy(f.getOppositeFace(), BlockSupport.FULL); + return y + 1 < hunk.getHeight() && carries(hunk.get(rX, y + 1, rZ), f); + } + + private static boolean carries(NativeBlockState state, BlockFace f) { + return state != null && VINE.equals(IrisProceduralBlocks.materialKey(state)) + && state.nativeHandle() instanceof MultipleFacing facing && facing.hasFace(f); } static boolean canGoOn(NativeBlockState decorator, NativeBlockState surface) { @@ -586,4 +623,10 @@ final class DecoratorCore { default -> state; }; } + + private static final class Faces { + private static final BlockFace[] SIDES = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}; + private static final BlockFace[] CARTESIAN = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, + BlockFace.UP, BlockFace.DOWN}; + } } 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 d41d027cf..508d343f9 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 @@ -51,6 +51,10 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; +import java.util.Locale; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + @Snippet("effect") @Accessors(chain = true) @NoArgsConstructor @@ -58,6 +62,9 @@ import org.bukkit.util.Vector; @Description("An iris effect") @Data public class IrisEffect { + private static final String MASTER_SOUND_CATEGORY = "master"; + private static final Set UNKNOWN_SOUND_CATEGORIES = ConcurrentHashMap.newKeySet(); + private final transient AtomicCache pt = new AtomicCache<>(); private final transient AtomicCache latch = new AtomicCache<>(); private final transient AtomicCache particleEffectResolved = new AtomicCache<>(); @@ -119,8 +126,8 @@ public class IrisEffect { @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; + @Description("The sound category the sound plays in, which picks the client volume slider that controls it: master, music, record, weather, block, hostile, neutral, player, ambient, voice or ui.") + private String soundCategory = MASTER_SOUND_CATEGORY; @DependsOn({"particleEffect"}) @MinNumber(0) @MaxNumber(512) @@ -185,6 +192,10 @@ public class IrisEffect { return sound; } + public String getSoundCategoryKey() { + return soundCategory == null || soundCategory.isBlank() ? MASTER_SOUND_CATEGORY : soundCategory.trim().toLowerCase(Locale.ROOT); + } + public Particle getParticleEffect() { if (particleEffect == null) { return null; @@ -199,6 +210,32 @@ public class IrisEffect { return soundResolved.aquire(() -> resolveKeyed(Sound.class, sound)); } + static SoundCategory bukkitSoundCategory(String key) { + return switch (key) { + case "master" -> SoundCategory.MASTER; + case "music" -> SoundCategory.MUSIC; + case "record" -> SoundCategory.RECORDS; + case "weather" -> SoundCategory.WEATHER; + case "block" -> SoundCategory.BLOCKS; + case "hostile" -> SoundCategory.HOSTILE; + case "neutral" -> SoundCategory.NEUTRAL; + case "player" -> SoundCategory.PLAYERS; + case "ambient" -> SoundCategory.AMBIENT; + case "voice" -> SoundCategory.VOICE; + case "ui" -> SoundCategory.UI; + default -> null; + }; + } + + private SoundCategory resolveSoundCategory() { + String key = getSoundCategoryKey(); + SoundCategory category = bukkitSoundCategory(key); + if (category == null && UNKNOWN_SOUND_CATEGORIES.add(key)) { + IrisLogging.warn("Unknown sound category: \"" + key + "\"."); + } + return category; + } + private static T resolveKeyed(Class type, String key) { NamespacedKey namespacedKey = NamespacedKey.fromString(key); return namespacedKey == null ? null : RegistryUtil.lookup(type).get(namespacedKey); @@ -242,9 +279,10 @@ public class IrisEffect { BukkitFx.run(p, () -> { Sound soundType = getSound(); Particle particleType = getParticleEffect(); - if (soundType != null) { + SoundCategory category = soundType == null ? null : resolveSoundCategory(); + if (category != 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, soundCategory, (float) volume, (float) RNG.r.d(minPitch, maxPitch)); + p.playSound(part, soundType, category, (float) volume, (float) RNG.r.d(minPitch, maxPitch)); } if (particleType != null) { @@ -319,9 +357,10 @@ public class IrisEffect { J.runEntity(p, () -> { Sound soundType = getSound(); Particle particleType = getParticleEffect(); - if (soundType != null) { + SoundCategory category = soundType == null ? null : resolveSoundCategory(); + if (category != 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, soundCategory, (float) volume, (float) RNG.r.d(minPitch, maxPitch)); + p.getWorld().playSound(part, soundType, category, (float) volume, (float) RNG.r.d(minPitch, maxPitch)); } if (particleType != null) { diff --git a/core/src/test/java/art/arcane/iris/generation/decoration/DecoratorCoreTest.java b/core/src/test/java/art/arcane/iris/generation/decoration/DecoratorCoreTest.java index 1063af9b3..c1c555711 100644 --- a/core/src/test/java/art/arcane/iris/generation/decoration/DecoratorCoreTest.java +++ b/core/src/test/java/art/arcane/iris/generation/decoration/DecoratorCoreTest.java @@ -11,11 +11,15 @@ import art.arcane.volmlib.util.math.RNG; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockSupport; import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.MultipleFacing; import org.junit.Test; import org.mockito.MockedStatic; +import java.util.EnumSet; import java.util.LinkedHashMap; +import java.util.Locale; import java.util.Map; +import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -25,15 +29,23 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyDouble; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.CALLS_REAL_METHODS; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.when; public class DecoratorCoreTest { + private static final String VINE = "minecraft:vine"; + private static final String GLOW_LICHEN = "minecraft:glow_lichen"; + private static final Set VINE_FACES = EnumSet.of(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, + BlockFace.WEST, BlockFace.UP); + private static final Set LICHEN_FACES = EnumSet.of(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, + BlockFace.WEST, BlockFace.UP, BlockFace.DOWN); @Test public void partSeed_differsByPartOrdinal() { @@ -741,6 +753,121 @@ public class DecoratorCoreTest { } } + @Test + public void stackedVineCurtainHangsFromTheWallItsTopStrandFaces() { + IrisDecorator decorator = mock(IrisDecorator.class); + IrisData data = mock(IrisData.class); + NativeBlockState vine = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.NORTH)); + when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(3); + when(decorator.getTopThreshold()).thenReturn(1.0); + when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(vine); + when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(vine); + Hunk output = Hunk.newArrayHunk(16, 8, 16); + output.set(8, 6, 8, sturdyState()); + output.set(8, 5, 7, sturdyState()); + output.set(9, 4, 8, sturdyState()); + + DecoratorCore.placeStackDown(decorator, 8, 8, 8, 8, 5, 0, output, new RNG(1L), data, 3, + new DecoratorCore.PlaceOpts(), null); + + assertEquals(EnumSet.of(BlockFace.NORTH, BlockFace.UP), faces(output.get(8, 5, 8))); + assertEquals(EnumSet.of(BlockFace.NORTH), faces(output.get(8, 4, 8))); + assertEquals(EnumSet.of(BlockFace.NORTH), faces(output.get(8, 3, 8))); + } + + @Test + public void unsupportedAuthoredSideFaceOnALoneVineIsDroppedAndReattached() { + NativeBlockState vine = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.NORTH)); + Hunk walled = Hunk.newArrayHunk(16, 8, 16); + walled.set(9, 3, 8, sturdyState()); + + assertEquals(EnumSet.of(BlockFace.EAST), faces(DecoratorCore.fixFacesForHunk(vine, walled, 8, 8, 8, 3, 8, null))); + assertEquals(EnumSet.of(BlockFace.UP), + faces(DecoratorCore.fixFacesForHunk(vine, Hunk.newArrayHunk(16, 8, 16), 8, 8, 8, 3, 8, null))); + } + + @Test + public void glowLichenSideFaceIsNotHeldByTheLichenAboveIt() { + NativeBlockState lichen = facingState(GLOW_LICHEN, LICHEN_FACES, EnumSet.of(BlockFace.NORTH)); + Hunk output = Hunk.newArrayHunk(16, 8, 16); + output.set(8, 2, 8, sturdyState()); + output.set(8, 4, 8, facingState(GLOW_LICHEN, LICHEN_FACES, EnumSet.of(BlockFace.NORTH))); + + assertEquals(EnumSet.of(BlockFace.DOWN), faces(DecoratorCore.fixFacesForHunk(lichen, output, 8, 8, 8, 3, 8, null))); + } + + @Test + public void supportedAuthoredSideFaceKeepsItsDirection() { + NativeBlockState vine = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.NORTH)); + Hunk output = Hunk.newArrayHunk(16, 8, 16); + output.set(8, 3, 7, sturdyState()); + output.set(9, 3, 8, sturdyState()); + + assertEquals(EnumSet.of(BlockFace.NORTH), faces(DecoratorCore.fixFacesForHunk(vine, output, 8, 8, 8, 3, 8, null))); + } + + @Test + public void vineWithoutAuthoredSideFaceReattachesToEverySturdyNeighbour() { + NativeBlockState vine = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.UP)); + Hunk output = Hunk.newArrayHunk(16, 8, 16); + output.set(7, 3, 8, sturdyState()); + output.set(8, 3, 9, sturdyState()); + output.set(8, 4, 8, sturdyState()); + + assertEquals(EnumSet.of(BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP), + faces(DecoratorCore.fixFacesForHunk(vine, output, 8, 8, 8, 3, 8, null))); + } + + private NativeBlockState facingState(String material, Set allowed, Set faces) { + MultipleFacing handle = facing(material, allowed, faces); + String key = handle.getAsString(); + NativeBlockState state = mock(NativeBlockState.class); + when(state.isVineBlock()).thenReturn(true); + when(state.materialKey()).thenReturn(material); + when(state.key()).thenReturn(key); + when(state.nativeHandle()).thenReturn(handle); + return state; + } + + private static MultipleFacing facing(String material, Set allowed, Set faces) { + EnumSet current = EnumSet.noneOf(BlockFace.class); + current.addAll(faces); + MultipleFacing data = mock(MultipleFacing.class); + when(data.getAllowedFaces()).thenReturn(allowed); + when(data.getFaces()).thenAnswer(invocation -> EnumSet.copyOf(current)); + when(data.hasFace(any(BlockFace.class))).thenAnswer(invocation -> current.contains(invocation.getArgument(0))); + doAnswer(invocation -> { + BlockFace face = invocation.getArgument(0); + if (!allowed.contains(face)) { + throw new IllegalArgumentException(face + " is not allowed on " + material); + } + if (invocation.getArgument(1)) { + current.add(face); + } else { + current.remove(face); + } + return null; + }).when(data).setFace(any(BlockFace.class), anyBoolean()); + when(data.clone()).thenAnswer(invocation -> facing(material, allowed, current)); + when(data.getAsString()).thenAnswer(invocation -> { + StringBuilder key = new StringBuilder(material).append('['); + for (BlockFace face : allowed) { + if (key.charAt(key.length() - 1) != '[') { + key.append(','); + } + key.append(face.name().toLowerCase(Locale.ROOT)).append('=').append(current.contains(face)); + } + return key.append(']').toString(); + }); + return data; + } + + private static Set faces(NativeBlockState state) { + EnumSet faces = EnumSet.noneOf(BlockFace.class); + faces.addAll(((MultipleFacing) state.nativeHandle()).getFaces()); + return faces; + } + private NativeBlockState airState() { NativeBlockState air = mock(NativeBlockState.class); when(air.isAir()).thenReturn(true); 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 a4d0b8579..1ab80416b 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 = "2224e73a1e9d76231d4df8bb1992451340e5f533b3fbafae9f4e1437747e666c"; + private static final String EXPECTED_SCHEMA_DIGEST = "f7890d23da41a0411eb92828d59c68d89ecc9ca266b357a9fd5d92107a9da4a5"; private static final List> SCHEMA_ROOTS = List.of( IrisDimension.class, diff --git a/core/src/test/java/art/arcane/iris/world/entity/IrisEffectSoundCategoryTest.java b/core/src/test/java/art/arcane/iris/world/entity/IrisEffectSoundCategoryTest.java new file mode 100644 index 000000000..6270b4967 --- /dev/null +++ b/core/src/test/java/art/arcane/iris/world/entity/IrisEffectSoundCategoryTest.java @@ -0,0 +1,58 @@ +package art.arcane.iris.world.entity; + +import org.bukkit.SoundCategory; +import org.junit.Test; + +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + +public class IrisEffectSoundCategoryTest { + private static final Map VANILLA_CATEGORIES = Map.ofEntries( + Map.entry("master", SoundCategory.MASTER), + Map.entry("music", SoundCategory.MUSIC), + Map.entry("record", SoundCategory.RECORDS), + Map.entry("weather", SoundCategory.WEATHER), + Map.entry("block", SoundCategory.BLOCKS), + Map.entry("hostile", SoundCategory.HOSTILE), + Map.entry("neutral", SoundCategory.NEUTRAL), + Map.entry("player", SoundCategory.PLAYERS), + Map.entry("ambient", SoundCategory.AMBIENT), + Map.entry("voice", SoundCategory.VOICE), + Map.entry("ui", SoundCategory.UI)); + + @Test + public void soundCategoryIsStoredAsAPlainStringField() throws NoSuchFieldException { + assertEquals(String.class, IrisEffect.class.getDeclaredField("soundCategory").getType()); + } + + @Test + public void soundCategoryDefaultsToMaster() { + assertEquals("master", new IrisEffect().getSoundCategoryKey()); + assertEquals("master", new IrisEffect().setSoundCategory(null).getSoundCategoryKey()); + assertEquals("master", new IrisEffect().setSoundCategory(" ").getSoundCategoryKey()); + } + + @Test + public void soundCategoryKeyIgnoresCaseAndSurroundingSpace() { + assertEquals("ambient", new IrisEffect().setSoundCategory(" Ambient ").getSoundCategoryKey()); + assertEquals("music", new IrisEffect().setSoundCategory("MUSIC").getSoundCategoryKey()); + } + + @Test + public void everyVanillaCategoryNameResolvesToItsBukkitCategory() { + for (Map.Entry entry : VANILLA_CATEGORIES.entrySet()) { + assertSame(entry.getKey(), entry.getValue(), IrisEffect.bukkitSoundCategory(entry.getKey())); + } + assertEquals(SoundCategory.values().length, VANILLA_CATEGORIES.size()); + } + + @Test + public void unknownCategoryNamesDoNotResolve() { + assertNull(IrisEffect.bukkitSoundCategory("ambiant")); + assertNull(IrisEffect.bukkitSoundCategory("records")); + assertNull(IrisEffect.bukkitSoundCategory("players")); + } +} From 067fffe066e4106da93843e9c83e37903253381d Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Sat, 31 Oct 2026 22:03:49 -0400 Subject: [PATCH 8/9] Ceiling vine curtains - A vine under a sturdy ceiling keeps its authored side faces - Vines below it hold those faces through the vine above - The vine-above check reads the facing before the material key --- .../iris/modded/ModdedDecoratorHooksTest.java | 15 ++++++++++++++ .../generation/decoration/DecoratorCore.java | 9 +++++---- .../decoration/DecoratorCoreTest.java | 20 +++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/adapters/modded-common/src/test/java/art/arcane/iris/modded/ModdedDecoratorHooksTest.java b/adapters/modded-common/src/test/java/art/arcane/iris/modded/ModdedDecoratorHooksTest.java index 0cfbb8e9d..8771a7270 100644 --- a/adapters/modded-common/src/test/java/art/arcane/iris/modded/ModdedDecoratorHooksTest.java +++ b/adapters/modded-common/src/test/java/art/arcane/iris/modded/ModdedDecoratorHooksTest.java @@ -83,6 +83,21 @@ public class ModdedDecoratorHooksTest { assertEquals(EnumSet.of(Direction.NORTH), faces(hunk.get(8, 3, 8))); } + @Test + public void stackedVineCurtainHangsUnderAnOpenCeiling() { + Hunk hunk = Hunk.newArrayHunk(16, 8, 16); + hunk.set(8, 6, 8, stone()); + NativeBlockState vine = state(Blocks.VINE, Direction.NORTH); + + for (int y = 5; y >= 3; y--) { + hunk.set(8, y, 8, fix(vine, hunk, y)); + } + + assertEquals(EnumSet.of(Direction.NORTH, Direction.UP), faces(hunk.get(8, 5, 8))); + assertEquals(EnumSet.of(Direction.NORTH), faces(hunk.get(8, 4, 8))); + assertEquals(EnumSet.of(Direction.NORTH), faces(hunk.get(8, 3, 8))); + } + @Test public void unsupportedAuthoredSideFaceOnALoneVineIsDroppedAndReattached() { NativeBlockState vine = state(Blocks.VINE, Direction.NORTH); 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 9859db55b..cc541f82b 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 @@ -484,12 +484,13 @@ final class DecoratorCore { private static boolean keepSupportedSides(MultipleFacing data, boolean vine, Hunk hunk, int rX, int rZ, int x, int y, int z, EngineMantle mantle) { + boolean ceiling = sturdy(BlockFace.UP, hunk, rX, rZ, x, y, z, mantle); boolean side = false; for (BlockFace f : Faces.SIDES) { if (!data.hasFace(f)) { continue; } - if (sturdy(f, hunk, rX, rZ, x, y, z, mantle) || vine && vineAboveCarries(f, hunk, rX, rZ, x, y, z, mantle)) { + if (sturdy(f, hunk, rX, rZ, x, y, z, mantle) || vine && (ceiling || vineAboveCarries(f, hunk, rX, rZ, x, y, z, mantle))) { side = true; } else { data.setFace(f, false); @@ -499,7 +500,7 @@ final class DecoratorCore { return false; } if (data.getAllowedFaces().contains(BlockFace.UP)) { - data.setFace(BlockFace.UP, sturdy(BlockFace.UP, hunk, rX, rZ, x, y, z, mantle)); + data.setFace(BlockFace.UP, ceiling); } if (data.hasFace(BlockFace.DOWN) && !sturdy(BlockFace.DOWN, hunk, rX, rZ, x, y, z, mantle)) { data.setFace(BlockFace.DOWN, false); @@ -532,8 +533,8 @@ final class DecoratorCore { } private static boolean carries(NativeBlockState state, BlockFace f) { - return state != null && VINE.equals(IrisProceduralBlocks.materialKey(state)) - && state.nativeHandle() instanceof MultipleFacing facing && facing.hasFace(f); + return state != null && state.nativeHandle() instanceof MultipleFacing facing + && VINE.equals(IrisProceduralBlocks.materialKey(state)) && facing.hasFace(f); } static boolean canGoOn(NativeBlockState decorator, NativeBlockState surface) { diff --git a/core/src/test/java/art/arcane/iris/generation/decoration/DecoratorCoreTest.java b/core/src/test/java/art/arcane/iris/generation/decoration/DecoratorCoreTest.java index c1c555711..da10e164e 100644 --- a/core/src/test/java/art/arcane/iris/generation/decoration/DecoratorCoreTest.java +++ b/core/src/test/java/art/arcane/iris/generation/decoration/DecoratorCoreTest.java @@ -775,6 +775,26 @@ public class DecoratorCoreTest { assertEquals(EnumSet.of(BlockFace.NORTH), faces(output.get(8, 3, 8))); } + @Test + public void stackedVineCurtainHangsUnderAnOpenCeiling() { + IrisDecorator decorator = mock(IrisDecorator.class); + IrisData data = mock(IrisData.class); + NativeBlockState vine = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.NORTH)); + when(decorator.getHeight(any(RNG.class), anyDouble(), anyDouble(), eq(data))).thenReturn(3); + when(decorator.getTopThreshold()).thenReturn(1.0); + when(decorator.pickBlockData(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(vine); + when(decorator.pickBlockDataTop(any(RNG.class), eq(data), anyDouble(), anyDouble())).thenReturn(vine); + Hunk output = Hunk.newArrayHunk(16, 8, 16); + output.set(8, 6, 8, sturdyState()); + + DecoratorCore.placeStackDown(decorator, 8, 8, 8, 8, 5, 0, output, new RNG(1L), data, 3, + new DecoratorCore.PlaceOpts(), null); + + assertEquals(EnumSet.of(BlockFace.NORTH, BlockFace.UP), faces(output.get(8, 5, 8))); + assertEquals(EnumSet.of(BlockFace.NORTH), faces(output.get(8, 4, 8))); + assertEquals(EnumSet.of(BlockFace.NORTH), faces(output.get(8, 3, 8))); + } + @Test public void unsupportedAuthoredSideFaceOnALoneVineIsDroppedAndReattached() { NativeBlockState vine = facingState(VINE, VINE_FACES, EnumSet.of(BlockFace.NORTH)); From bd442728024279154154a8fcfacd8e245cd9a69d Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Sat, 31 Oct 2026 22:07:15 -0400 Subject: [PATCH 9/9] Schema digest - Studio schema digest covers seam and sound category fields --- .../art/arcane/iris/pack/schema/SchemaBuilderIdentityTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1ab80416b..d5052e5d0 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 = "f7890d23da41a0411eb92828d59c68d89ecc9ca266b357a9fd5d92107a9da4a5"; + private static final String EXPECTED_SCHEMA_DIGEST = "0b7bc58cb81a7e630d13662b2157868bd306f3afef571942dc5b8e667323a250"; private static final List> SCHEMA_ROOTS = List.of( IrisDimension.class,