diff --git a/CONTRACTS.md b/CONTRACTS.md index e75816330..da0dc108f 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -128,7 +128,8 @@ running Iris is the pack publisher's responsibility. dimension keeps no mantle or the chunk generates without it. A block a stage reads and writes back unchanged keeps the host's own identity of it (a custom block of a content plugin stays one). - Answer `TerrainSampler.fluidHeight()` (the height the host fills with fluid below) and `upperDimensionY(x, z)` (where a - dimension stacked above begins; empty when none does). + dimension stacked above begins; empty when none does). `surfaceY(x, z)` equals `column(x, z).surfaceY()`; a host + overrides it when the height costs less than the whole column. - Make placement edits atomic across blocks, block entities, markers and mantle in generation storage. Abort chunk publication when any stage fails. - Preserve unknown persisted mantle layers or fail explicitly. diff --git a/DESIGN.md b/DESIGN.md index 93ac694d4..e65c72e9d 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -496,7 +496,8 @@ whose writes throw. The runner does no neighbor scheduling or rollback. A failed the host from publishing the chunk. A chunk stage writes only its chunk but may look around it: its `TerrainSampler` covers the chunk and the 16 blocks -around it, so a stage that smooths a surface reads its neighbors' heights. The sampler also gives the dimension's +around it, so a stage that smooths a surface reads its neighbors' heights (`surfaceY`, which spares the host the slope +that `column` works out). The sampler also gives the dimension's `fluidHeight()` and, per column, `upperDimensionY` where a dimension stacked above begins; a stage writes nothing at or above it. The mantle's `blocks()` are the blocks placements wrote into the mantle for chunks to take over (objects, structures): a chunk stage copies them into its chunk, as Iris's `iris:matter` does. They are the host's layer, so they diff --git a/README.md b/README.md index 8d894069d..c2048d9ec 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,8 @@ graph.define(APPLY).run(CaveModule::apply); // reads its own chunk's CAVES and A chunk stage writes only its own chunk but may look around it: `ctx.terrain()` covers the chunk and the 16 blocks around it, gives the dimension's `fluidHeight()` and, per column, `upperDimensionY(x, z)` where a dimension stacked above -begins (write nothing there). `ctx.mantle().blocks()` holds the blocks placements wrote into the mantle for the chunks to +begins (write nothing there). `surfaceY(x, z)` is a column's height alone, cheaper than `column(x, z)` when a stage needs +no slope. `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`). Stages only read them. ```java diff --git a/src/main/java/com/volmit/world/TerrainSampler.java b/src/main/java/com/volmit/world/TerrainSampler.java index 2b3bf9363..65d129fcd 100644 --- a/src/main/java/com/volmit/world/TerrainSampler.java +++ b/src/main/java/com/volmit/world/TerrainSampler.java @@ -11,6 +11,13 @@ import java.util.OptionalInt; public interface TerrainSampler { BlockBox bounds(); TerrainSample column(int worldX, int worldZ); + + /** The column's {@link TerrainSample#surfaceY()} alone, for a module that needs neither slope nor fluid: the host + * may answer it without working out the rest of {@link #column}. Outside the bounds it throws like {@link #column}. + */ + default double surfaceY(int worldX, int worldZ) { + return column(worldX, worldZ).surfaceY(); + } BiomeSample biome(int worldX, int y, int worldZ); /** The height up to which the host fills the world with fluid wherever the terrain lies lower, the sea level of the