diff --git a/VoxelEngine.Tests/WorldGen/CaveCarverTests.cs b/VoxelEngine.Tests/WorldGen/CaveCarverTests.cs index d876f9b..ecbf430 100644 --- a/VoxelEngine.Tests/WorldGen/CaveCarverTests.cs +++ b/VoxelEngine.Tests/WorldGen/CaveCarverTests.cs @@ -183,4 +183,20 @@ public class CaveCarverTests Assert.True(bothEmpty || bothCarved, $"seam mismatch: c1={airC1Seam}, c2={airC2Seam}"); } + + [Fact] + public void Carve_RespectsMinCaveY_NoCarvingAboveCeiling() + { + var cfg = new Configuration { MinCaveY = 20 }; + var carver = new CaveCarver(seed: 42, Blocks, cfg); + Chunk c = MakeStoneChunk(); + + // Chunk Y=2 → worldY 32..47, all above MinCaveY=20 → must stay solid. + carver.Carve(c, new Vector3i(0, 2, 0)); + + for (int x = 0; x < Chunk.Size; x++) + for (int y = 0; y < Chunk.Size; y++) + for (int z = 0; z < Chunk.Size; z++) + Assert.Equal(Blocks.Stone.Id, c[x, y, z]); + } } diff --git a/World/WorldGen/CaveCarver.cs b/World/WorldGen/CaveCarver.cs index 22b3a90..96f36c5 100644 --- a/World/WorldGen/CaveCarver.cs +++ b/World/WorldGen/CaveCarver.cs @@ -51,6 +51,7 @@ public sealed class CaveCarver { int worldY = baseY + y; if (worldY <= 0) continue; + if (worldY > this._cfg.MinCaveY) continue; ushort id = chunk[x, y, z]; if (id == this._blocks.Air.Id) continue; @@ -160,6 +161,7 @@ public sealed class CaveCarver { int worldY = baseY + y; if (worldY <= 0) continue; + if (worldY > this._cfg.MinCaveY) continue; float vx = baseX + x + 0.5f; float vy = baseY + y + 0.5f;