Batch 7 stage 4a: biome height, sky biome and platform biome writes

TerrainSampler.biomeHeight and skyBiome answer for a pack biome at any
column; Mantle.setPlatformBiome makes a block show a platform biome, inside
a chunk stage's own chunk. These replace the module's FloatingHost facade.
README, DESIGN (ledger drops FloatingHost) and CONTRACTS updated.
This commit is contained in:
piexel committed 2026-10-28 01:58:46 +01:00
1 parent f1eb619344
commit 95582abb6e
9 files changed
+79 -2

No files matched your search

+5
View File
@@ -149,6 +149,11 @@ running Iris is the pack publisher's responsibility.
- Answer `TerrainSampler.surfaceBiome(x, z)` (the id `biome(x, y, z).surfaceBiome()` gives), `surfaceKind`, `minWorldY()`, `surfaceBlock` (empty
where no image map gives one) and `upperDimension()` (empty when nothing sits above); `FeatureSettings.declaredBy(biome, type)` answers the
settings the biome declares itself (empty when it declares none or is unknown); `BlockRegistry.oreFor` answers from the platform.
- Answer `TerrainSampler.biomeHeight(biome, x, z, seed)` (the height above the bottom the biome's terrain generators give the
column when shaped with `seed`) and `skyBiome(biome, x, z)` (the platform biome the biome shows as in the sky; empty when it
names none) for any biome of the pack, throwing IllegalArgumentException for one it does not have. Store
`Mantle.setPlatformBiome(x, y, z, biome)` where the biome pass that writes the chunk's biomes reads it; a chunk stage's
mantle accepts it inside the chunk's own columns only, and a placement's mantle or an edit may refuse it.
- 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). `surfaceY(x, z)` equals `column(x, z).surfaceY()`; a host
overrides it when the height costs less than the whole column. `surfaceHeight(x, z)` must equal
+5 -2
View File
@@ -579,6 +579,11 @@ chunk, and a neighbor may already be generated, so its mantle stays as the pipel
`Mantle.isCarved(x, y, z)` is the host's answer whether the cave planner carved a block, as `blocks()` is its read-only layer of planned blocks: a
void the planner marked need not show in the chunk (under a dimension above, the cave stage leaves it solid), and a stage that places something
solid asks it. A yes-or-no question rather than a layer, because no module writes it and none needs to visit it.
`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.
`TerrainSampler.biomeHeight` and `skyBiome` answer for a biome that need not stand at the column, because such a stage builds that biome's ground
away from where the layout puts it. Neither takes a random: Iris picks sky and custom biomes with a generator seeded from the world's biome seed.
`BlockRegistry.oreFor(rock, ore)` is the platform's answer to which variant of an ore belongs in a rock.
## Mantle invocations
@@ -1280,8 +1285,6 @@ API now: `world.running()`, `world.seed(purpose)`, `TerrainSampler`, `FeatureSet
height, which written blocks are the object's). Iris reads it in two places: for the placement-level module settings of
the run, and when Iris places an object itself (its studio and commands, the jigsaw placer). It goes when those settings
are part of the run the API describes and Iris no longer places objects itself.
- **`FloatingHost`** (world). Island height comes from Iris's biome generators and island tops are painted by Iris's biome
palettes, which the API layout does not describe. Its objects are placed through `PackWorld.placements()`.
- **`StructureHost`** (world). Iris's structure assembler, locator and placer, and the loot tables of a structure for the
loot of its pieces. The structure model (structures, pools, pieces) is `iris:structure`'s own resource kinds, which Iris
registers with its own modules because its jigsaw studio reads them. Its surface is already API vocabulary; it goes when
+4
View File
@@ -176,6 +176,10 @@ begins (write nothing there). `surfaceY(x, z)` is a column's height alone, cheap
no slope, and `surfaceHeight(x, z)` the same height rounded to the block a stage places on. `surfaceBiome(x, z)` is the id of a column's surface biome alone and `surfaceKind(x, z)` what it was generated as (`BiomeKind`: land, sea,
shore); `surfaceBlock(x, z)` is the block an image map gives the ground there, `minWorldY()` the world Y of the dimension's bottom, and
`upperDimension()` the dimension stacked above (`UpperDimension`: its own settings, resources and image-map blocks), for a stage that fills in its ground.
`biomeHeight(biome, x, z, seed)` is the height a pack biome's terrain generators would give a column, whatever biome stands there, and
`skyBiome(biome, x, z)` the platform biome that biome shows as in the sky (a custom biome, or a pick from its sky scatter); a stage that builds
ground of a biome somewhere else, such as a floating island, shapes and paints it with them. `ctx.mantle().setPlatformBiome(x, y, z, biome)` makes a
block show that platform biome instead of its column's, inside the stage's own chunk.
`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().isCarved(x, y, z)` says whether the cave planner
@@ -2,6 +2,7 @@ package com.volmit.mantle;
import com.volmit.block.BlockState;
import com.volmit.geometry.BlockBox;
import com.volmit.resource.ResourceId;
/**
* Invocation-scoped access to typed mantle data. X and Z are world block coordinates; Y is
@@ -39,6 +40,13 @@ public interface Mantle {
*/
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
* sets it inside its own chunk only, like module layers.
*/
void setPlatformBiome(int x, int y, int z, ResourceId biome);
/** Only one edit may be active per view. Parent reads remain allowed, but parent
* mutations are prohibited until the edit ends (IllegalStateException).
*/
@@ -69,6 +69,19 @@ public interface TerrainSampler {
*/
Optional<BlockState> surfaceBlock(int worldX, int worldZ);
/** The height, above the bottom, that the terrain generators of pack biome {@code biome} give the column when shaped
* with {@code seed}, whatever biome the column really has: what a biome's ground would be if it stood there. Throws
* IllegalArgumentException when the pack has no such biome. Outside the bounds it throws like {@link #column}.
*/
double biomeHeight(ResourceId biome, int worldX, int worldZ, long seed);
/** The platform biome pack biome {@code biome} shows as when it floats in the sky at the column, such as
* {@code minecraft:plains}: one of its custom biomes, or a pick from its sky scatter. Empty when the biome names
* none. Throws IllegalArgumentException when the pack has no such biome. Outside the bounds it throws like
* {@link #column}. Write it with {@link com.volmit.mantle.Mantle#setPlatformBiome}.
*/
Optional<ResourceId> skyBiome(ResourceId biome, int worldX, int worldZ);
/** The Y in the world of the dimension's bottom block, such as {@code -64}: what to add to a height above the bottom
* to get the Y a pack's settings name when they speak of world heights.
*/
@@ -8,6 +8,7 @@ import com.volmit.mantle.MantleEdit;
import com.volmit.mantle.MantleKey;
import com.volmit.mantle.MantleLayer;
import com.volmit.mantle.MantleVisitor;
import com.volmit.resource.ResourceId;
import java.util.HashMap;
import java.util.Map;
@@ -55,6 +56,12 @@ final class ChunkMantle implements Mantle {
return mantle.isCarved(x, y, z);
}
@Override
public void setPlatformBiome(int x, int y, int z, ResourceId biome) {
requireOwnChunk(x, y, z);
mantle.setPlatformBiome(x, y, z, biome);
}
@Override
public MantleEdit edit() {
throw new UnsupportedOperationException("Chunk stages write mantle layers directly, without an edit");
@@ -11,6 +11,7 @@ import com.volmit.placement.PlacedBlock;
import com.volmit.placement.PlacedMarker;
import com.volmit.placement.PlacementAccess;
import com.volmit.placement.PlacementEdit;
import com.volmit.resource.ResourceId;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -135,6 +136,12 @@ final class PlacementViews {
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);
parent.setPlatformBiome(x, y, z, biome);
}
}
private static final class RestrictedMantleLayer<T> implements MantleLayer<T> {
@@ -276,6 +276,23 @@ class ChunkPipelineTest {
assertNull(mantle.get(VeinModule.ORE, CHUNK, 0, 0));
}
@Test
void chunkStagesSetPlatformBiomesInTheirOwnChunkOnly() {
var mantle = new MemoryMantle();
var aroundTheChunk = new BlockBox(-CHUNK, BOTTOM, -CHUNK, 2 * CHUNK, TOP, 2 * CHUNK);
var sky = ResourceId.parse("minecraft:plains");
var graph = TestSetups.stages(oreWriter((context, layer) -> {
context.mantle().setPlatformBiome(15, 200, 0, sky);
context.mantle().setPlatformBiome(CHUNK, 200, 0, sky);
})).resolve(Pipeline.CHUNK);
var inputs = TestContexts.generation(null, ColumnSettings.NONE, mantle.within(aroundTheChunk));
assertThrows(UnsupportedOperationException.class,
() -> new ChunkRunner(graph).generate(inputs, TestContexts.SEED, StageTimings.NONE));
assertEquals(sky, mantle.platformBiome(15, 200, 0));
assertNull(mantle.platformBiome(CHUNK, 200, 0));
}
private static IrisModule oreWriter(BiConsumer<ChunkStageContext, MantleLayer<Integer>> body) {
var stage = Stage.chunk("test:writer/work");
return new IrisModule() {
@@ -8,6 +8,7 @@ import com.volmit.mantle.MantleEdit;
import com.volmit.mantle.MantleKey;
import com.volmit.mantle.MantleLayer;
import com.volmit.mantle.MantleVisitor;
import com.volmit.resource.ResourceId;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
@@ -24,6 +25,9 @@ public final class MemoryMantle {
/** Where the carved voids are kept; the host owns them, so no module registers this layer. */
private static final MantleKey<Boolean> CAVERNS = new MantleKey<>("host:caverns", Boolean.class);
/** Where the platform biomes stages set are kept; the host owns them, so no module registers this layer. */
private static final MantleKey<ResourceId> PLATFORM_BIOMES = new MantleKey<>("host:platform-biomes", ResourceId.class);
private final Map<String, TreeMap<BlockPosition, Object>> layers = new HashMap<>();
/** A view that accepts reads and writes inside {@code bounds} only. */
@@ -33,6 +37,10 @@ public final class MemoryMantle {
public <T> MantleLayer<T> layer(MantleKey<T> key) { return new Layer<>(key, bounds, true); }
public MantleLayer<BlockState> blocks() { return new Layer<>(PLANNED_BLOCKS, bounds, false); }
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);
}
public MantleEdit edit() { throw new UnsupportedOperationException("Edits are not used in these tests"); }
};
}
@@ -47,6 +55,11 @@ public final class MemoryMantle {
values(CAVERNS).put(new BlockPosition(x, y, z), Boolean.TRUE);
}
/** The platform biome a stage set at the block; null where none did. */
public ResourceId platformBiome(int x, int y, int z) {
return get(PLATFORM_BIOMES, x, y, z);
}
public <T> T get(MantleKey<T> key, int x, int y, int z) {
return key.type().cast(values(key).get(new BlockPosition(x, y, z)));
}