diff --git a/CONTRACTS.md b/CONTRACTS.md index 7271d1c57..9b36ee862 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -161,7 +161,7 @@ running Iris is the pack publisher's responsibility. the host's own identity of it (a custom block of a content plugin stays one). - Serve `Mantle.carved()` in every invocation, keeping the voids in the host's own form: a mantle stage's view writes them, a chunk stage's view only reads them (its writes throw UnsupportedOperationException), and a dimension that keeps no mantle holds none. Answer - `Mantle.isCarved(x, y, z)` (false where it holds none) and cover the chunk and the 16 blocks around it in a chunk stage's mantle, as the + `carved().get(x, y, z)` (null where it holds none) and cover the chunk and the 16 blocks around it in a chunk stage's mantle, as the sampler does. - Name pack resources to services by `ResourceId` and convert to the host's keys at the host's edge; read a `ResourceId` setting written as a bare pack key as the pack's id of that key. diff --git a/DESIGN.md b/DESIGN.md index 9af25df67..8eca79f7c 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -630,7 +630,7 @@ biome it shows), as `blocks()` is its layer of planned blocks. It is the one hos (Iris's cave carver does, thousands per chunk, so the plain fills are shared constants and the host keeps them in its own form), and a chunk stage reads them, around its chunk as far as its mantle reaches, and cuts them out of its terrain. A chunk stage's writes throw, as the mantle is complete when chunk stages run. A void the planner marked need not show in the chunk (under a dimension above, the cave stage -leaves it solid), so `Mantle.isCarved(x, y, z)` stays as the short question for a stage that places something solid. +leaves it solid), so a stage that places something solid asks `carved().get(x, y, z) != null`; there is no separate `isCarved` on the mantle. `Mantle.setPlatformBiome(x, y, z, biome)` is the other way round: modules write it and only the host's biome pass reads it, in the host's own form (Iris stores the platform's id for the biome), so it is a write rather than a layer a module could read back. It is general rather than a floating-island call: any stage that makes a block belong elsewhere, such as an island floating over another biome, can set the biome it shows. diff --git a/README.md b/README.md index bd1cdc98a..d266e476e 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ block show that platform biome instead of its column's, inside the stage's own c `ctx.settings().declaredBy(biomeId, Type.class)` reads what a biome declares itself, such as a cave biome of a `BiomeSample`, which is no level of `at(...)`. A mantle stage's `ctx.terrain()` covers the chunk and the larger of its reach and 16 blocks around it; a chunk stage's `ctx.mantle()` covers the same area as its terrain. `ctx.mantle().blocks()` holds the blocks placements wrote into the mantle for the chunks to take over, such as objects and structures; a chunk stage copies them in (Iris's `iris:matter`). `ctx.mantle().carved()` is the layer of voids the cave planner carved (`CarvedVoid`: `OPEN`, `FLUID`, `LAVA` or `AIR`, optionally with a biome), and -`isCarved(x, y, z)` asks whether one is there, whatever the chunk's blocks show. A chunk stage only reads both; a mantle stage plans the voids +`carved().get(x, y, z) != null` asks whether one is there, whatever the chunk's blocks show. A chunk stage only reads both; a mantle stage plans the voids with `carved().set(...)`, and a chunk stage's write throws. A chunk stage may write the layers its module registered, inside its own chunk's columns; around it, the mantle stays as the mantle stages left it. `blocks().oreFor(rock, ore)` gives the ore variant that suits the rock (deepslate ores in deepslate), which the platform decides, and `PackBiome.vanillaBiome()` the biome vanilla's rules see a pack biome as. diff --git a/api/src/main/java/com/volmit/mantle/Mantle.java b/api/src/main/java/com/volmit/mantle/Mantle.java index 0ca469f34..e2480590f 100644 --- a/api/src/main/java/com/volmit/mantle/Mantle.java +++ b/api/src/main/java/com/volmit/mantle/Mantle.java @@ -38,15 +38,12 @@ public interface Mantle { * Mantle stages write it ({@code set} plans a void, {@code remove} takes it back); a chunk stage only reads it, around * its chunk as far as its mantle reaches, and its writes throw UnsupportedOperationException. A chunk stage takes the * voids over into its chunk (Iris's {@code iris:carve} cuts them out of the terrain). The host owns this layer and keeps - * it in its own form, so it needs no registration. A dimension that keeps no mantle carves nothing. + * it in its own form, so it needs no registration. A dimension that keeps no mantle carves nothing. A stage that only + * asks whether a position is carved, whether or not the chunk's own blocks show it, such as under a dimension stacked + * above, tests {@code carved().get(x, y, z) != null}. */ MantleLayer carved(); - /** Whether the mantle holds a carved void at the position, whether or not the chunk's own blocks show it, such as - * under a dimension stacked above: the same as {@code carved().get(x, y, z) != null}, for a stage that only asks. - */ - boolean isCarved(int x, int y, int z); - /** Shows the block as platform biome {@code biome}, such as {@code minecraft:plains} or a pack's custom biome, instead * of the biome its column generates as; the host's biome pass reads it when it writes the chunk's biomes. The host * owns this layer and keeps it in its own form, so it is written only and needs no registration. A chunk stage diff --git a/host/src/main/java/com/volmit/host/ChunkMantle.java b/host/src/main/java/com/volmit/host/ChunkMantle.java index 292a75054..40e2c7c44 100644 --- a/host/src/main/java/com/volmit/host/ChunkMantle.java +++ b/host/src/main/java/com/volmit/host/ChunkMantle.java @@ -60,11 +60,6 @@ final class ChunkMantle implements Mantle { return carved; } - @Override - public boolean isCarved(int x, int y, int z) { - return mantle.isCarved(x, y, z); - } - @Override public void setPlatformBiome(int x, int y, int z, ResourceId biome) { requireOwnChunk(x, y, z); diff --git a/host/src/main/java/com/volmit/host/PlacementViews.java b/host/src/main/java/com/volmit/host/PlacementViews.java index c2e38e32f..205612a52 100644 --- a/host/src/main/java/com/volmit/host/PlacementViews.java +++ b/host/src/main/java/com/volmit/host/PlacementViews.java @@ -140,12 +140,6 @@ final class PlacementViews { return carved; } - @Override - public boolean isCarved(int x, int y, int z) { - checkPosition(bounds(), x, y, z); - return parent.isCarved(x, y, z); - } - @Override public void setPlatformBiome(int x, int y, int z, ResourceId biome) { checkPosition(bounds(), x, y, z); diff --git a/host/src/test/java/com/volmit/example/ChunkPipelineTest.java b/host/src/test/java/com/volmit/example/ChunkPipelineTest.java index 85e009940..1f77ccd93 100644 --- a/host/src/test/java/com/volmit/example/ChunkPipelineTest.java +++ b/host/src/test/java/com/volmit/example/ChunkPipelineTest.java @@ -198,8 +198,6 @@ class ChunkPipelineTest { public ModuleInfo info() { return ModuleInfo.of("test:caves", "Caves", "1"); } public void setup(ModuleSetup setup) { setup.stages().define(probe).run(context -> { - carved.add(String.valueOf(context.mantle().isCarved(6, 9, 2))); - carved.add(String.valueOf(context.mantle().isCarved(6, 10, 2))); carved.add(String.valueOf(context.mantle().carved().get(6, 9, 2))); carved.add(String.valueOf(context.mantle().carved().get(6, 10, 2))); carved.add(assertThrows(UnsupportedOperationException.class, @@ -216,7 +214,7 @@ class ChunkPipelineTest { StageTimings.NONE); var cannotCarve = "Carved voids are planned by mantle stages (Stage.mantle), not by chunk stages"; - assertEquals(List.of("true", "false", CarvedVoid.OPEN.toString(), "null", cannotCarve, cannotCarve), carved); + assertEquals(List.of(CarvedVoid.OPEN.toString(), "null", cannotCarve, cannotCarve), carved); } @Test diff --git a/host/src/test/java/com/volmit/support/MemoryMantle.java b/host/src/test/java/com/volmit/support/MemoryMantle.java index 41a7dd010..38f94172b 100644 --- a/host/src/test/java/com/volmit/support/MemoryMantle.java +++ b/host/src/test/java/com/volmit/support/MemoryMantle.java @@ -38,7 +38,6 @@ public final class MemoryMantle { public MantleLayer layer(MantleKey key) { return new Layer<>(key, bounds, true); } public MantleLayer blocks() { return new Layer<>(PLANNED_BLOCKS, bounds, false); } public MantleLayer carved() { return new Layer<>(CAVERNS, bounds, true); } - public boolean isCarved(int x, int y, int z) { return new Layer<>(CAVERNS, bounds, false).get(x, y, z) != null; } public void setPlatformBiome(int x, int y, int z, ResourceId biome) { if (!bounds.contains(x, y, z)) throw new IndexOutOfBoundsException("Outside the mantle view: " + x + "," + y + "," + z); values(PLATFORM_BIOMES).put(new BlockPosition(x, y, z), biome);