Make Y the height above the dimension's bottom everywhere in the API: document it, and drop GenerationContext.originY, which is always 0 now

This commit is contained in:
piexel committed 2026-10-08 14:50:04 +02:00
1 parent 33fc9adca9
commit 09afee8ae3
26 files changed
+91 -54

No files matched your search

@@ -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);
}
@@ -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();
@@ -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();
}
@@ -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();
+3 -1
View File
@@ -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<T> {
@@ -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) {
+3 -2
View File
@@ -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.
*
* <p>The host owns chunk acquisition, release, persistence and the permitted access area.
* Out-of-area access throws IndexOutOfBoundsException. Access after the invocation ends
@@ -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<BlockEntityData> blockEntity) {
public PlacedBlock {
Objects.requireNonNull(position, "position");
@@ -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<String, String> attributes) {
public PlacedMarker {
Objects.requireNonNull(position, "position");
@@ -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.
@@ -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.
@@ -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.
*/
@@ -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<BlockPosition> {
public BlockPosition add(BlockPosition offset) {
return new BlockPosition(Math.addExact(x, offset.x), Math.addExact(y, offset.y), Math.addExact(z, offset.z));
@@ -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);
}
@@ -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);
}
@@ -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.
@@ -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);
}