Batch 6 part 1: one bottom-Y name, no silently-wrong defaults, geometry package, blocks

Finding 43: PackWorld.minHeight(), PlatformStart.bottomY() and StructureFit.bottomY()
become minWorldY(), the name TerrainSampler already used, and none of them has a default.
FeatureSettings.declaredBy, TerrainSampler.surfaceBlock/upperDimension and
BlockRegistry.oreFor lose defaults that answered wrong for a host that forgot them.
BlockBox, BlockPosition and BlockFace move to com.volmit.geometry.

Finding 44: BlockRegistry keeps resolve(BlockSpec) and adds find(key), which is
empty for a block the platform lacks; resolve(String) and resolve(BlockState) go.
BlockTrait drops INVENTORY, BLOCK_ENTITY and NEEDS_UPDATE, which nothing asked;
BlockAccess.is answers every trait. GenerationContext.hunk(Class) becomes blocks().
This commit is contained in:
piexel committed 2026-10-24 05:19:06 +02:00
1 parent 9473c827fe
commit 05f621d82d
63 files changed
+187 -143

No files matched your search

@@ -0,0 +1,26 @@
package com.volmit.geometry;
import java.util.Objects;
/** 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) {
throw new IllegalArgumentException("Inverted block bounds");
}
}
public boolean contains(int x, int y, int z) {
return x >= minX && x < maxX && y >= minY && y < maxY && z >= minZ && z < maxZ;
}
public boolean contains(BlockBox area) {
Objects.requireNonNull(area, "area");
return area.minX >= minX && area.maxX <= maxX
&& area.minY >= minY && area.maxY <= maxY
&& area.minZ >= minZ && area.maxZ <= maxZ;
}
}
@@ -0,0 +1,4 @@
package com.volmit.geometry;
/** One of the six faces of a block. */
public enum BlockFace { UP, DOWN, NORTH, SOUTH, EAST, WEST }
@@ -0,0 +1,28 @@
package com.volmit.geometry;
/** 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> {
/** The origin, which settings start from before the host reads their JSON: packs write {@code {"x": 1, "y": 2, "z": 3}},
* and an omitted coordinate is 0.
*/
private BlockPosition() {
this(0, 0, 0);
}
public BlockPosition add(BlockPosition offset) {
return new BlockPosition(Math.addExact(x, offset.x), Math.addExact(y, offset.y), Math.addExact(z, offset.z));
}
public BlockPosition subtract(BlockPosition offset) {
return new BlockPosition(Math.subtractExact(x, offset.x), Math.subtractExact(y, offset.y), Math.subtractExact(z, offset.z));
}
@Override
public int compareTo(BlockPosition other) {
int result = Integer.compare(x, other.x);
if (result == 0) result = Integer.compare(y, other.y);
return result == 0 ? Integer.compare(z, other.z) : result;
}
}