From 09afee8ae3620c5dcb6d48a769173164906ed2e6 Mon Sep 17 00:00:00 2001 From: piexel Date: Thu, 8 Oct 2026 14:50:04 +0200 Subject: [PATCH] Make Y the height above the dimension's bottom everywhere in the API: document it, and drop GenerationContext.originY, which is always 0 now --- CONTRACTS.md | 3 +++ DESIGN.md | 17 ++++++++++++++--- README.md | 8 ++++++++ .../java/com/volmit/block/BlockPalette.java | 5 +++-- .../volmit/generation/GenerationContext.java | 5 +++-- .../generation/MantleGenerationContext.java | 4 ++-- .../java/com/volmit/host/ChunkInvocation.java | 5 ----- src/main/java/com/volmit/hunk/Hunk.java | 4 +++- src/main/java/com/volmit/mantle/BlockBox.java | 5 ++++- src/main/java/com/volmit/mantle/Mantle.java | 5 +++-- .../java/com/volmit/placement/PlacedBlock.java | 4 +++- .../java/com/volmit/placement/PlacedMarker.java | 4 +++- .../com/volmit/placement/PlacementAccess.java | 3 ++- .../com/volmit/placement/PlacementEdit.java | 3 ++- .../com/volmit/placement/PlacementRequest.java | 3 ++- .../java/com/volmit/world/BlockPosition.java | 4 +++- src/main/java/com/volmit/world/BlockView.java | 5 +++-- .../java/com/volmit/world/NoiseSampler.java | 5 +++-- .../java/com/volmit/world/TerrainSample.java | 3 ++- .../java/com/volmit/world/TerrainSampler.java | 5 +++-- src/test/java/com/volmit/ApiValuesTest.java | 6 +++--- .../com/volmit/example/ChunkPipelineTest.java | 14 +++++++------- .../com/volmit/example/chunk/VeinModule.java | 6 +++--- .../com/volmit/example/chunk/VeinSettings.java | 4 ++-- .../java/com/volmit/mantle/MantleValueTest.java | 14 +++++++------- .../java/com/volmit/support/TestContexts.java | 1 - 26 files changed, 91 insertions(+), 54 deletions(-) diff --git a/CONTRACTS.md b/CONTRACTS.md index 77e04a87e..dee556ffd 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -84,6 +84,9 @@ running Iris is the pack publisher's responsibility. (`FeatureSchema.shorthand()`), and render the schema to accept both forms. - Name the packages of the classes Iris describes itself with `ModuleHost.describingHostTypesIn(...)`, decode them as Iris does, and render each `HostKind` with Iris's own description of the class. +- Hand modules heights above the dimension's bottom (0 = bottom block, whatever the platform's minimum + height is) in every value that carries Y: samples, bounds, block views, placement edits, the mantle, + hunks. X and Z stay world coordinates. Convert in one place at the boundary. - Preserve pack field names and defaults, seed derivation, RNG draw order, coordinate conventions and iteration order where existing worlds must not change. Per-stage streams do not reproduce Iris's current shared draws; matching them where worlds must stay the same is adapter diff --git a/DESIGN.md b/DESIGN.md index e42efb7b2..f49c300e3 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -471,12 +471,23 @@ stage that never draws never creates its stream. Object generators are not stages. `ObjectGenerationContext.random()` stays, a `WorldRandom` seeded from the variant seed the host chooses. +## Coordinates + +X and Z are world coordinates. Y is the height above the dimension's bottom: 0 is always the dimension's +bottom block, whatever its minimum height is in the platform, so Y is never negative. That applies to +every value that carries a height: `TerrainSample` heights, `TerrainSampler` and `BlockView` positions and +bounds, `BlockPalette` and `NoiseSampler` sample positions, `PlacedBlock` and `PlacedMarker` positions, +placement anchors, `Mantle` positions and bounds, and a chunk `Hunk`'s local y. `BlockBox` carries +whichever coordinates its owner defines; an object's bounds are local to the object, and a placed +footprint can extend below height 0 where the object overhangs the bottom. The host converts to and from +the platform's Y at its boundary. + ## Chunk invocations `ChunkRunner.generate(inputs, invocationSeed)` runs active chunk stages once each in resolved order. `GenerationContext.hunk(type)` returns the host-owned local volume of that value type, shared by -all stages of the invocation. Hunk coordinates are local; samples and mantle coordinates are -world blocks. A chunk stage writes only its own chunk and reads the mantle: the runner hands it a view +all stages of the invocation. Hunk coordinates are local. Samples and mantle coordinates use +world X and Z, and Y as the height above the dimension's bottom. A chunk stage writes only its own chunk and reads the mantle: the runner hands it a view whose writes throw. The runner does no neighbor scheduling or rollback. A failed invocation must stop the host from publishing the chunk. @@ -770,6 +781,6 @@ Exact signatures for these families should follow their first real port. ## Readiness gate A feature replaces its legacy implementation only when existing pack JSON works, representative -seeds match promised output, negative heights and chunk boundaries pass, concurrent execution is +seeds match promised output, dimensions whose bottom is below world Y 0 and chunk boundaries pass, concurrent execution is deterministic, reload caches expire and failures cannot publish partial chunks. Until then the legacy path stays available. diff --git a/README.md b/README.md index 0f60227ae..07efd588f 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,14 @@ declares each settings type once. A feature whose settings class has exactly one option may be written as that option's value, such as `"snow": 0.5` for `"snow": {"amount": 0.5}` or a bare list for a class holding one list. +## Coordinates + +X and Z are world coordinates. Y is always the height above the dimension's bottom: 0 is the bottom block +of the dimension, whatever its minimum height is in the platform, so Y is never negative. This holds for +every API value that carries a height: terrain and biome samples, `BlockBox` bounds of the terrain +sampler, block views, placement edits and the mantle, hunks, block palettes and noise samplers. The host +converts to and from the platform's own Y at its boundary; modules never see it. + ## Random streams Stages and object generators draw from `com.volmit.random.WorldRandom`, an IrisApi type whose every diff --git a/src/main/java/com/volmit/block/BlockPalette.java b/src/main/java/com/volmit/block/BlockPalette.java index 504c0c1e0..c040f1072 100644 --- a/src/main/java/com/volmit/block/BlockPalette.java +++ b/src/main/java/com/volmit/block/BlockPalette.java @@ -2,10 +2,11 @@ package com.volmit.block; import com.volmit.random.WorldRandom; -/** Resolved, immutable palette. Coordinates are world blocks; selection uses only the given stream. +/** Resolved, immutable palette. X and Z are world coordinates, Y is the height above the + * dimension's bottom (0 = bottom); selection uses only the given stream. * An empty/unresolvable palette is a pack-load error. Implementations must support concurrent calls. */ @FunctionalInterface public interface BlockPalette { - BlockState select(int worldX, int worldY, int worldZ, WorldRandom random); + BlockState select(int worldX, int y, int worldZ, WorldRandom random); } diff --git a/src/main/java/com/volmit/generation/GenerationContext.java b/src/main/java/com/volmit/generation/GenerationContext.java index 229cdd5ac..59454b1c1 100644 --- a/src/main/java/com/volmit/generation/GenerationContext.java +++ b/src/main/java/com/volmit/generation/GenerationContext.java @@ -7,9 +7,10 @@ import com.volmit.world.TerrainSampler; /** Per-invocation chunk generation inputs. Must not be retained after execution. */ public interface GenerationContext extends InvocationContext { - /** World block coordinates corresponding to local volume coordinates (0, 0, 0). */ + /** World coordinates of the local volume's first column. The volume starts at the dimension's bottom: + * local y is the height above it (0 = bottom block). + */ int originX(); - int originY(); int originZ(); TerrainSampler terrain(); diff --git a/src/main/java/com/volmit/generation/MantleGenerationContext.java b/src/main/java/com/volmit/generation/MantleGenerationContext.java index 957d49282..fc27bd6d3 100644 --- a/src/main/java/com/volmit/generation/MantleGenerationContext.java +++ b/src/main/java/com/volmit/generation/MantleGenerationContext.java @@ -6,7 +6,7 @@ import com.volmit.world.TerrainSampler; /** Per-invocation inputs of the mantle pipeline for one chunk. Must not be retained after execution. */ public interface MantleGenerationContext extends InvocationContext { - /** The chunk's first block along X, in world coordinates. */ + /** The chunk's first block along X, in world coordinates. Heights are above the dimension's bottom. */ int originX(); /** The chunk's first block along Z, in world coordinates. */ @@ -16,6 +16,6 @@ public interface MantleGenerationContext extends InvocationContext { FeatureSettings settings(); - /** The mantle of the chunk widened by the pipeline's reach, full height. Writes outside it throw. */ + /** The mantle of the chunk widened by the pipeline's reach, full height (heights 0 up to the dimension height). Writes outside it throw. */ Mantle mantle(); } diff --git a/src/main/java/com/volmit/host/ChunkInvocation.java b/src/main/java/com/volmit/host/ChunkInvocation.java index 5f32a590c..421344ed8 100644 --- a/src/main/java/com/volmit/host/ChunkInvocation.java +++ b/src/main/java/com/volmit/host/ChunkInvocation.java @@ -35,11 +35,6 @@ final class ChunkInvocation implements ChunkStageContext { return inputs.originX(); } - @Override - public int originY() { - return inputs.originY(); - } - @Override public int originZ() { return inputs.originZ(); diff --git a/src/main/java/com/volmit/hunk/Hunk.java b/src/main/java/com/volmit/hunk/Hunk.java index d484f68a9..25e5dde0c 100644 --- a/src/main/java/com/volmit/hunk/Hunk.java +++ b/src/main/java/com/volmit/hunk/Hunk.java @@ -2,7 +2,9 @@ package com.volmit.hunk; /** Dense local volume. Coordinates range from zero inclusive to each dimension exclusive. * Reads/writes outside that range throw IndexOutOfBoundsException. Null values are forbidden; - * block volumes represent empty space with an air state. Invocation-owned hunks must not escape. + * block volumes represent empty space with an air state. + * A chunk's volume starts at the dimension's bottom: its local y is the height above + * the dimension's bottom (0 = bottom). Invocation-owned hunks must not escape. * This is a new minimal contract, not a copy of Iris's full Hunk implementation. */ public interface Hunk { diff --git a/src/main/java/com/volmit/mantle/BlockBox.java b/src/main/java/com/volmit/mantle/BlockBox.java index 023968cf7..deb3f1bca 100644 --- a/src/main/java/com/volmit/mantle/BlockBox.java +++ b/src/main/java/com/volmit/mantle/BlockBox.java @@ -2,7 +2,10 @@ package com.volmit.mantle; import java.util.Objects; -/** World block bounds, minimum inclusive and maximum exclusive. Empty boxes are valid. */ +/** Block bounds, minimum inclusive and maximum exclusive. Empty boxes are valid. X and Z are world coordinates; + * Y is the height above the dimension's bottom (0 = bottom). Boxes of local volumes, such as an object's + * bounds, use that volume's own coordinates. + */ public record BlockBox(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { public BlockBox { if (minX > maxX || minY > maxY || minZ > maxZ) { diff --git a/src/main/java/com/volmit/mantle/Mantle.java b/src/main/java/com/volmit/mantle/Mantle.java index 00c62ed53..a69f37d1a 100644 --- a/src/main/java/com/volmit/mantle/Mantle.java +++ b/src/main/java/com/volmit/mantle/Mantle.java @@ -1,8 +1,9 @@ package com.volmit.mantle; /** - * Invocation-scoped access to typed mantle data. Coordinates are world block coordinates, - * including negative Y; the host translates them to storage coordinates. + * Invocation-scoped access to typed mantle data. X and Z are world block coordinates; Y is + * the height above the dimension's bottom (0 = bottom), so it is never negative. The host translates + * them to storage coordinates. * *

The host owns chunk acquisition, release, persistence and the permitted access area. * Out-of-area access throws IndexOutOfBoundsException. Access after the invocation ends diff --git a/src/main/java/com/volmit/placement/PlacedBlock.java b/src/main/java/com/volmit/placement/PlacedBlock.java index 8b4bfddd4..e9b2a9ab6 100644 --- a/src/main/java/com/volmit/placement/PlacedBlock.java +++ b/src/main/java/com/volmit/placement/PlacedBlock.java @@ -6,7 +6,9 @@ import com.volmit.world.BlockPosition; import java.util.Objects; import java.util.Optional; -/** A proposed or buffered write in world coordinates, including its block entity payload. */ +/** A proposed or buffered write, including its block entity payload. The position has world X and Z and a + * Y that is the height above the dimension's bottom (0 = bottom). + */ public record PlacedBlock(BlockPosition position, BlockState state, Optional blockEntity) { public PlacedBlock { Objects.requireNonNull(position, "position"); diff --git a/src/main/java/com/volmit/placement/PlacedMarker.java b/src/main/java/com/volmit/placement/PlacedMarker.java index 9bdabf47c..631b62089 100644 --- a/src/main/java/com/volmit/placement/PlacedMarker.java +++ b/src/main/java/com/volmit/placement/PlacedMarker.java @@ -5,7 +5,9 @@ import com.volmit.world.BlockPosition; import java.util.Map; import java.util.Objects; -/** Marker metadata in world coordinates. */ +/** Marker metadata. The position has world X and Z and a Y that is the height above the dimension's bottom + * (0 = bottom). + */ public record PlacedMarker(BlockPosition position, ResourceId type, Map attributes) { public PlacedMarker { Objects.requireNonNull(position, "position"); diff --git a/src/main/java/com/volmit/placement/PlacementAccess.java b/src/main/java/com/volmit/placement/PlacementAccess.java index f7a4c46a3..6da2ca1e9 100644 --- a/src/main/java/com/volmit/placement/PlacementAccess.java +++ b/src/main/java/com/volmit/placement/PlacementAccess.java @@ -3,7 +3,8 @@ package com.volmit.placement; import com.volmit.mantle.Mantle; import com.volmit.world.BlockView; -/** Buffered world-space access for placement stages, without ownership of commit/close. +/** Buffered access for placement stages, without ownership of commit/close. X and Z are world coordinates; + * Y is the height above the dimension's bottom (0 = bottom). * Reads include the overlay. Bounds are the host-prepared placement area. * Block/entity/marker/mantle writes share the host edit. * Out-of-area access throws; nested mantle edits are unsupported. Do not retain this view. diff --git a/src/main/java/com/volmit/placement/PlacementEdit.java b/src/main/java/com/volmit/placement/PlacementEdit.java index 473a26605..1119053fe 100644 --- a/src/main/java/com/volmit/placement/PlacementEdit.java +++ b/src/main/java/com/volmit/placement/PlacementEdit.java @@ -1,6 +1,7 @@ package com.volmit.placement; -/** Host-owned buffered placement writes, in world coordinates, including cross-chunk writes. +/** Host-owned buffered placement writes, with world X and Z and Y as the height above the + * dimension's bottom (0 = bottom), including cross-chunk writes. * All reads see the overlay. Block/entity/marker/mantle mutations participate in one commit. * Out-of-bounds access fails, never clips. The host excludes competing writers and handles * block entity replacement/removal when states change. Nested mantle edits are unsupported. diff --git a/src/main/java/com/volmit/placement/PlacementRequest.java b/src/main/java/com/volmit/placement/PlacementRequest.java index 704a979b5..21af84d93 100644 --- a/src/main/java/com/volmit/placement/PlacementRequest.java +++ b/src/main/java/com/volmit/placement/PlacementRequest.java @@ -6,7 +6,8 @@ import com.volmit.resource.ResourceId; import com.volmit.world.BlockPosition; import java.util.Objects; -/** One placement attempt. Geometry is already transformed; anchor is a world block position. +/** One placement attempt. Geometry is already transformed; anchor is a world block position (world X and Z, Y as the height + * above the dimension's bottom). * World position = local position - object anchor + request anchor. Arithmetic never wraps. * id identifies this attempt within the host's generation plan. */ diff --git a/src/main/java/com/volmit/world/BlockPosition.java b/src/main/java/com/volmit/world/BlockPosition.java index 05071ac9c..24dcf2da4 100644 --- a/src/main/java/com/volmit/world/BlockPosition.java +++ b/src/main/java/com/volmit/world/BlockPosition.java @@ -1,6 +1,8 @@ package com.volmit.world; -/** A block position. Owning contracts specify whether it is local or world space. */ +/** A block position. Owning contracts specify whether it is local or in the world. A world position has + * world X and Z and a Y that is the height above the dimension's bottom (0 = bottom). + */ public record BlockPosition(int x, int y, int z) implements Comparable { public BlockPosition add(BlockPosition offset) { return new BlockPosition(Math.addExact(x, offset.x), Math.addExact(y, offset.y), Math.addExact(z, offset.z)); diff --git a/src/main/java/com/volmit/world/BlockView.java b/src/main/java/com/volmit/world/BlockView.java index ba04a201a..bf1ba01b2 100644 --- a/src/main/java/com/volmit/world/BlockView.java +++ b/src/main/java/com/volmit/world/BlockView.java @@ -3,11 +3,12 @@ package com.volmit.world; import com.volmit.block.BlockState; import com.volmit.mantle.BlockBox; -/** Read-only prepared generation blocks in world coordinates, not the live server world. +/** Read-only prepared generation blocks, not the live server world. X and Z are world coordinates; + * Y is the height above the dimension's bottom (0 = bottom), also in {@link #bounds()}. * Empty space is a non-null air state. Out-of-area access throws IndexOutOfBoundsException. * Views expire with the owning invocation; access afterwards throws IllegalStateException. */ public interface BlockView { BlockBox bounds(); - BlockState get(int worldX, int worldY, int worldZ); + BlockState get(int worldX, int y, int worldZ); } diff --git a/src/main/java/com/volmit/world/NoiseSampler.java b/src/main/java/com/volmit/world/NoiseSampler.java index 8ed32874a..bfa92e57e 100644 --- a/src/main/java/com/volmit/world/NoiseSampler.java +++ b/src/main/java/com/volmit/world/NoiseSampler.java @@ -1,9 +1,10 @@ package com.volmit.world; -/** Immutable, seeded noise resource. Coordinates are world-space sample coordinates. +/** Immutable, seeded noise resource. X and Z are world coordinates; Y is the + * height above the dimension's bottom (0 = bottom). * Range and scale belong to the resource; no implicit normalization is performed. */ @FunctionalInterface public interface NoiseSampler { - double sample(double worldX, double worldY, double worldZ); + double sample(double worldX, double y, double worldZ); } diff --git a/src/main/java/com/volmit/world/TerrainSample.java b/src/main/java/com/volmit/world/TerrainSample.java index d800857a5..3a09b1bad 100644 --- a/src/main/java/com/volmit/world/TerrainSample.java +++ b/src/main/java/com/volmit/world/TerrainSample.java @@ -3,7 +3,8 @@ package com.volmit.world; import java.util.Objects; import java.util.OptionalInt; -/** Pre-modification terrain sample in world coordinates. +/** Pre-modification terrain sample of one world column. Heights are above the dimension's bottom + * (0 = bottom). * surfaceY is the top solid surface height, not the first air block. fluidY is the top fluid * block when present. Slope is nonnegative height change per horizontal block. * This is the host's terrain field, not a scan of current edited blocks. diff --git a/src/main/java/com/volmit/world/TerrainSampler.java b/src/main/java/com/volmit/world/TerrainSampler.java index 818286ff7..44cc518c5 100644 --- a/src/main/java/com/volmit/world/TerrainSampler.java +++ b/src/main/java/com/volmit/world/TerrainSampler.java @@ -3,11 +3,12 @@ package com.volmit.world; import com.volmit.mantle.BlockBox; /** Read-only host sampling for the same pack snapshot as the invocation. - * Bounds are world blocks, maxima exclusive. Sampling outside prepared bounds fails with + * X and Z are world coordinates; Y is the height above the dimension's bottom (0 = bottom). + * Bounds use the same coordinates, maxima exclusive. Sampling outside prepared bounds fails with * IndexOutOfBoundsException. Views expire with the invocation and must not escape it. */ public interface TerrainSampler { BlockBox bounds(); TerrainSample column(int worldX, int worldZ); - BiomeSample biome(int worldX, int worldY, int worldZ); + BiomeSample biome(int worldX, int y, int worldZ); } diff --git a/src/test/java/com/volmit/ApiValuesTest.java b/src/test/java/com/volmit/ApiValuesTest.java index c660777e0..ef6540bd3 100644 --- a/src/test/java/com/volmit/ApiValuesTest.java +++ b/src/test/java/com/volmit/ApiValuesTest.java @@ -131,9 +131,9 @@ class ApiValuesTest { @Test void placementAlignsAnchorsAndCheckedArithmeticNeverWraps() { var object = new GeneratedObject(new BlockBox(-1, -1, -1, 2, 2, 2), new BlockPosition(1, 1, 1), List.of(), List.of()); - var request = new PlacementRequest(ResourceId.parse("test:placement"), object, new BlockPosition(-16, -64, -16)); - assertEquals(new BlockPosition(-16, -64, -16), request.worldPosition(object.anchor())); - assertEquals(new BlockBox(-18, -66, -18, -15, -63, -15), request.footprint()); + var request = new PlacementRequest(ResourceId.parse("test:placement"), object, new BlockPosition(-16, 64, -16)); + assertEquals(new BlockPosition(-16, 64, -16), request.worldPosition(object.anchor())); + assertEquals(new BlockBox(-18, 62, -18, -15, 65, -15), request.footprint()); var overflow = new PlacementRequest(request.id(), object, new BlockPosition(Integer.MAX_VALUE, 0, 0)); assertThrows(ArithmeticException.class, overflow::footprint); } diff --git a/src/test/java/com/volmit/example/ChunkPipelineTest.java b/src/test/java/com/volmit/example/ChunkPipelineTest.java index c91a275e4..6f809532a 100644 --- a/src/test/java/com/volmit/example/ChunkPipelineTest.java +++ b/src/test/java/com/volmit/example/ChunkPipelineTest.java @@ -40,8 +40,8 @@ class ChunkPipelineTest { private static final int SIZE = 4; private static final int HEIGHT = 8; private static final int CHUNK = 16; - private static final int MIN_Y = -64; - private static final int MAX_Y = 320; + private static final int BOTTOM = 0; + private static final int TOP = 384; private static final BlockState AIR = new BlockState("minecraft:air"); private static final BlockState GRASS = new BlockState("minecraft:grass_block"); private static final ResourceId DIMENSION = ResourceId.parse("pack:dimension/overworld"); @@ -136,18 +136,18 @@ class ChunkPipelineTest { @Test void mantleStagesWriteBeyondTheirChunkAndChunkStagesReadTheirOwnPart() { var loaded = LoadedModules.load(List.of(DiscoveredModule.builtIn(new VeinModule())), Map.of(), Set.of(), Set.of()); - var vein = new Entry<>(Target.BIOME, PLAINS, new VeinSettings(12, -60)); + var vein = new Entry<>(Target.BIOME, PLAINS, new VeinSettings(12, 4)); int reach = loaded.mantle().stages().getFirst().reachBlocks(new DeclaredSettings(vein)); assertEquals(3, reach, "a 12 block vein from the centre column runs 3 blocks into the next chunk"); var mantle = new MemoryMantle(); - var reachArea = new BlockBox(-reach, MIN_Y, -reach, CHUNK + reach, MAX_Y, CHUNK + reach); + var reachArea = new BlockBox(-reach, BOTTOM, -reach, CHUNK + reach, TOP, CHUNK + reach); new MantleRunner(loaded.mantle()).generate(VeinModule.PLAN, TestContexts.mantle(0, 0, ColumnSettings.everywhere(vein), mantle.within(reachArea)), TestContexts.SEED); - assertEquals(1, mantle.get(VeinModule.ORE, 18, -60, 7), "the vein runs on into the next chunk"); + assertEquals(1, mantle.get(VeinModule.ORE, 18, 4, 7), "the vein runs on into the next chunk"); var blocks = new ArrayHunk<>(BlockState.class, CHUNK, HEIGHT, CHUNK, AIR); - var chunkArea = new BlockBox(0, MIN_Y, 0, CHUNK, MAX_Y, CHUNK); + var chunkArea = new BlockBox(0, BOTTOM, 0, CHUNK, TOP, CHUNK); new ChunkRunner(loaded.chunk()).generate( TestContexts.generation(Map.of(BlockState.class, blocks), ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED); assertEquals(VeinModule.ORE_BLOCK, blocks.get(7, 4, 7)); @@ -167,7 +167,7 @@ class ChunkPipelineTest { }; var builder = new StageGraphBuilder(); builder.install(DiscoveredModule.builtIn(module)); - var inputs = TestContexts.generation(Map.of(), ColumnSettings.NONE, mantle.within(new BlockBox(0, MIN_Y, 0, CHUNK, MAX_Y, CHUNK))); + var inputs = TestContexts.generation(Map.of(), ColumnSettings.NONE, mantle.within(new BlockBox(0, BOTTOM, 0, CHUNK, TOP, CHUNK))); var failure = assertThrows(UnsupportedOperationException.class, () -> new ChunkRunner(builder.resolve(Pipeline.CHUNK)).generate(inputs, TestContexts.SEED)); diff --git a/src/test/java/com/volmit/example/chunk/VeinModule.java b/src/test/java/com/volmit/example/chunk/VeinModule.java index aef26b590..a68bfbe5f 100644 --- a/src/test/java/com/volmit/example/chunk/VeinModule.java +++ b/src/test/java/com/volmit/example/chunk/VeinModule.java @@ -71,10 +71,10 @@ public final class VeinModule implements IrisModule { private static void place(ChunkStageContext context) { var blocks = context.hunk(BlockState.class); - var chunk = new BlockBox(context.originX(), context.originY(), context.originZ(), - context.originX() + blocks.getWidth(), context.originY() + blocks.getHeight(), context.originZ() + blocks.getDepth()); + var chunk = new BlockBox(context.originX(), 0, context.originZ(), + context.originX() + blocks.getWidth(), blocks.getHeight(), context.originZ() + blocks.getDepth()); context.mantle().layer(ORE).visit(chunk, (x, y, z, planned) -> - blocks.set(x - context.originX(), y - context.originY(), z - context.originZ(), ORE_BLOCK)); + blocks.set(x - context.originX(), y, z - context.originZ(), ORE_BLOCK)); } private static final class IntegerCodec implements MantleCodec { diff --git a/src/test/java/com/volmit/example/chunk/VeinSettings.java b/src/test/java/com/volmit/example/chunk/VeinSettings.java index a16a8607a..8ec476726 100644 --- a/src/test/java/com/volmit/example/chunk/VeinSettings.java +++ b/src/test/java/com/volmit/example/chunk/VeinSettings.java @@ -11,8 +11,8 @@ public final class VeinSettings implements IrisFeature { @Desc("Blocks along X, starting at the chunk's centre column") private int length = 12; - @Desc("World height of the vein") - private int y = -60; + @Desc("Height of the vein above the dimension's bottom") + private int y = 4; public VeinSettings() {} diff --git a/src/test/java/com/volmit/mantle/MantleValueTest.java b/src/test/java/com/volmit/mantle/MantleValueTest.java index 5f1a5107f..4fea9c395 100644 --- a/src/test/java/com/volmit/mantle/MantleValueTest.java +++ b/src/test/java/com/volmit/mantle/MantleValueTest.java @@ -6,14 +6,14 @@ import static org.junit.jupiter.api.Assertions.*; class MantleValueTest { @Test - void boundsUseWorldCoordinatesAndExclusiveMaximum() { - var box = new BlockBox(-16, -64, -16, 16, 320, 16); - assertTrue(box.contains(-16, -64, -16)); - assertTrue(box.contains(15, 319, 15)); + void boundsUseWorldXZHeightsAboveTheBottomAndExclusiveMaximum() { + var box = new BlockBox(-16, 0, -16, 16, 384, 16); + assertTrue(box.contains(-16, 0, -16)); + assertTrue(box.contains(15, 383, 15)); assertFalse(box.contains(16, 0, 0)); - assertFalse(box.contains(0, 320, 0)); + assertFalse(box.contains(0, 384, 0)); assertFalse(box.contains(0, 0, 16)); - assertFalse(box.contains(0, -65, 0)); + assertFalse(box.contains(0, -1, 0)); assertTrue(box.contains(box)); assertTrue(box.contains(new BlockBox(0, 0, 0, 1, 1, 1))); assertFalse(box.contains(new BlockBox(-17, 0, 0, 1, 1, 1))); @@ -26,7 +26,7 @@ class MantleValueTest { assertThrows(IllegalArgumentException.class, () -> new BlockBox(0, 1, 0, 1, 0, 1)); assertThrows(IllegalArgumentException.class, () -> new BlockBox(0, 0, 1, 1, 1, 0)); assertFalse(new BlockBox(0, 0, 0, 0, 0, 0).contains(0, 0, 0)); - var extremes = new BlockBox(Integer.MIN_VALUE, -64, 0, Integer.MAX_VALUE, 320, 1); + var extremes = new BlockBox(Integer.MIN_VALUE, 0, 0, Integer.MAX_VALUE, 384, 1); assertTrue(extremes.contains(Integer.MIN_VALUE, 0, 0)); } diff --git a/src/test/java/com/volmit/support/TestContexts.java b/src/test/java/com/volmit/support/TestContexts.java index 82a68bae4..35c69e226 100644 --- a/src/test/java/com/volmit/support/TestContexts.java +++ b/src/test/java/com/volmit/support/TestContexts.java @@ -26,7 +26,6 @@ public final class TestContexts { public static GenerationContext generation(Map, Hunk> hunks, FeatureSettings settings, Mantle mantle) { return new GenerationContext() { public int originX() { return 0; } - public int originY() { return -64; } public int originZ() { return 0; } public long worldSeed() { return SEED; } public PackResources resources() { throw new AssertionError("Unused resources"); }