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

@@ -1,3 +0,0 @@
package com.volmit.block;
public enum BlockFace { UP, DOWN, NORTH, SOUTH, EAST, WEST }
@@ -1,17 +1,18 @@
package com.volmit.block;
import com.volmit.geometry.BlockFace;
import com.volmit.object.BlockEntityData;
import com.volmit.resource.ResourceId;
import java.util.Optional;
/** Host adapter for resolved states and cached behavior. No native platform objects escape.
* Unknown materials, unsupported properties, and malformed states throw IllegalArgumentException.
* Methods are safe for concurrent generation calls; predicates must not read the live world.
/** What the platform knows about blocks, for one pack snapshot. No native platform objects escape. Methods are safe for
* concurrent generation calls; predicates must not read the live world.
*
* <p>Two ways to get a state: {@link #resolve(BlockSpec)} reads a block the way packs write it (a custom block of the
* pack, a backup, never failing), {@link #find(String)} asks the platform for exactly one block. Both answer complete
* states, with every property the platform gives the block, like the states the host hands out; compare against those.
*/
public interface BlockRegistry {
BlockState resolve(String key);
default BlockState resolve(BlockState state) { return resolve(state.key()); }
/** The state {@code spec} names, resolved the way packs expect, so it never throws for a block the platform lacks:
* a block of the pack's {@code blocks} folder with the spec's properties over its own, else the platform's block
* (a key without a namespace is {@code minecraft:}) with the spec's properties, else the backup resolved the same
@@ -19,6 +20,12 @@ public interface BlockRegistry {
*/
BlockState resolve(BlockSpec spec);
/** The platform's block {@code key}, such as {@code minecraft:lava} or {@code minecraft:oak_log[axis=y]}, with the
* properties the key leaves out at the platform's defaults; empty when the platform has no such block or property.
* For a module that must know whether the platform has a block, unlike {@link #resolve(BlockSpec)}.
*/
Optional<BlockState> find(String key);
/** The block entity {@code spec}'s {@code tileData} describes, in the host's format; empty when the spec has none
* or its resolved block has no block entity.
*/
@@ -35,12 +42,9 @@ public interface BlockRegistry {
PaletteSampler palette(PaletteSpec spec, long seed);
/** The ore that suits the {@code rock} it is placed in, which the platform decides: an ore placed in deepslate is its
* deepslate variant, one placed in other rock its ordinary one. {@code ore} itself when it has no variant, and by
* default for a registry that knows none.
* deepslate variant, one placed in other rock its ordinary one; {@code ore} itself when it has no variant.
*/
default BlockState oreFor(BlockState rock, BlockState ore) {
return ore;
}
BlockState oreFor(BlockState rock, BlockState ore);
boolean hasTrait(BlockState state, BlockTrait trait);
boolean inTag(BlockState state, ResourceId tag);
@@ -11,8 +11,10 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
/** Immutable, platform-neutral block description with value equality.
* Construction validates syntax, not platform availability or valid material properties.
* Resolve through BlockRegistry before writing. Custom-content IDs are allowed.
* Construction validates syntax, not platform availability or valid material properties. Custom-content IDs are
* allowed. A state may be written as it is: the host gives the properties it leaves out the platform's defaults. The
* states the host hands out (from the world, a hunk, {@link BlockRegistry}) are complete, with every property, so a
* module compares them with a complete state, which {@link BlockRegistry#find} or {@link BlockRegistry#resolve} give.
*/
public record BlockState(ResourceId material, Map<String, String> properties) {
private static final String PROPERTIES_START = "[";
@@ -1,9 +1,9 @@
package com.volmit.block;
/** Host-defined block behavior; tags provide extensible material groups. {@code VINE} is a block that hangs from or
* clings to the faces around it, such as vines and glow lichen.
/** What a block is, as the platform answers it ({@link BlockRegistry#hasTrait}); tags name further groups
* ({@link BlockRegistry#inTag}). {@code VINE} is a block that hangs from or clings to the faces around it, such as
* vines and glow lichen; {@code CUSTOM} a block of a content plugin or mod rather than of the platform itself.
*/
public enum BlockTrait {
AIR, SOLID, OCCLUDING, FLUID, WATER, GRAVITY, FOLIAGE, DECORATION, VINE,
LOG, LEAVES, ORE, INVENTORY, BLOCK_ENTITY, CUSTOM, NEEDS_UPDATE
AIR, SOLID, OCCLUDING, FLUID, WATER, GRAVITY, FOLIAGE, DECORATION, VINE, LOG, LEAVES, ORE, CUSTOM
}
@@ -52,9 +52,7 @@ public interface FeatureSettings {
* {@link #at}. {@code biome} is an id as a {@code BiomeSample} gives it. Empty when the biome declares none, or the
* host knows no such biome.
*/
default <F extends IrisFeature> Optional<F> declaredBy(ResourceId biome, Class<F> featureType) {
return Optional.empty();
}
<F extends IrisFeature> Optional<F> declaredBy(ResourceId biome, Class<F> featureType);
/** One level's declaration of the settings.
*
@@ -1,7 +1,7 @@
package com.volmit.generation;
import com.volmit.config.FeatureSettings;
import com.volmit.mantle.BlockBox;
import com.volmit.geometry.BlockBox;
import com.volmit.world.TerrainSampler;
/** What chunk and mantle invocations share: the chunk they run for, its terrain and its settings. X and Z are world
@@ -1,5 +1,6 @@
package com.volmit.generation;
import com.volmit.block.BlockState;
import com.volmit.hunk.Hunk;
import com.volmit.mantle.Mantle;
import com.volmit.world.TerrainSampler;
@@ -30,8 +31,9 @@ public interface GenerationContext extends ChunkContext {
*/
Mantle mantle();
/** The host-owned local volume of the given value type, shared by all stages of this
* invocation. Unsupported types throw IllegalArgumentException.
/** The chunk's blocks, which the stages of this invocation build one after the other: a volume of 16 by the
* dimension's height by 16, local to the chunk, owned by the host and shared by every stage of the invocation.
* Empty space is air.
*/
<T> Hunk<T> hunk(Class<T> type);
Hunk<BlockState> blocks();
}
@@ -1,4 +1,4 @@
package com.volmit.mantle;
package com.volmit.geometry;
import java.util.Objects;
@@ -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 }
@@ -1,4 +1,4 @@
package com.volmit.world;
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).
@@ -1,6 +1,7 @@
package com.volmit.mantle;
import com.volmit.block.BlockState;
import com.volmit.geometry.BlockBox;
/**
* Invocation-scoped access to typed mantle data. X and Z are world block coordinates; Y is
@@ -1,5 +1,7 @@
package com.volmit.mantle;
import com.volmit.geometry.BlockBox;
/** A registered layer bounded by its owning Mantle view and sharing its lifetime.
* Values must be non-null and treated as immutable. Wrong value types are rejected with
* IllegalArgumentException; null arguments with NullPointerException.
@@ -1,7 +1,7 @@
package com.volmit.object;
import com.volmit.mantle.BlockBox;
import com.volmit.world.BlockPosition;
import com.volmit.geometry.BlockBox;
import com.volmit.geometry.BlockPosition;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
@@ -1,7 +1,7 @@
package com.volmit.object;
import com.volmit.block.BlockState;
import com.volmit.world.BlockPosition;
import com.volmit.geometry.BlockPosition;
import java.util.Objects;
import java.util.Optional;
@@ -1,7 +1,7 @@
package com.volmit.object;
import com.volmit.resource.ResourceId;
import com.volmit.world.BlockPosition;
import com.volmit.geometry.BlockPosition;
import java.util.Map;
import java.util.Objects;
@@ -2,7 +2,7 @@ package com.volmit.placement;
import com.volmit.block.BlockState;
import com.volmit.object.BlockEntityData;
import com.volmit.world.BlockPosition;
import com.volmit.geometry.BlockPosition;
import java.util.Objects;
import java.util.Optional;
@@ -1,7 +1,7 @@
package com.volmit.placement;
import com.volmit.resource.ResourceId;
import com.volmit.world.BlockPosition;
import com.volmit.geometry.BlockPosition;
import java.util.Map;
import java.util.Objects;
@@ -1,9 +1,9 @@
package com.volmit.placement;
import com.volmit.mantle.BlockBox;
import com.volmit.geometry.BlockBox;
import com.volmit.geometry.BlockPosition;
import com.volmit.object.GeneratedObject;
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 (world X and Z, Y as the height
@@ -1,7 +1,7 @@
package com.volmit.service;
import com.volmit.entity.EntitySpec;
import com.volmit.world.BlockPosition;
import com.volmit.geometry.BlockPosition;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Objects;
@@ -1,8 +1,8 @@
package com.volmit.service;
import com.volmit.block.BlockState;
import com.volmit.geometry.BlockPosition;
import com.volmit.item.ItemDrop;
import com.volmit.world.BlockPosition;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Objects;
@@ -1,8 +1,8 @@
package com.volmit.service;
import com.volmit.entity.EntitySpec;
import com.volmit.geometry.BlockPosition;
import com.volmit.resource.ResourceId;
import com.volmit.world.BlockPosition;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Objects;
@@ -1,6 +1,6 @@
package com.volmit.service;
import com.volmit.world.BlockPosition;
import com.volmit.geometry.BlockPosition;
import java.util.Objects;
/** How a search for something in a world ended: found at a position, not there, or given up before covering the whole
@@ -1,9 +1,9 @@
package com.volmit.service;
import com.volmit.block.BlockState;
import com.volmit.geometry.BlockPosition;
import com.volmit.item.ItemDrop;
import com.volmit.resource.ResourceId;
import com.volmit.world.BlockPosition;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Objects;
@@ -1,9 +1,9 @@
package com.volmit.service;
import com.volmit.block.BlockState;
import com.volmit.geometry.BlockPosition;
import com.volmit.placement.PlacedBlock;
import com.volmit.resource.ResourceId;
import com.volmit.world.BlockPosition;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Objects;
@@ -1,6 +1,6 @@
package com.volmit.vanilla;
import com.volmit.mantle.BlockBox;
import com.volmit.geometry.BlockBox;
import com.volmit.resource.ResourceId;
/** One of the platform's own starts, as the platform made it, before the host publishes it. Valid only while the
@@ -26,8 +26,10 @@ public interface PlatformStart {
*/
boolean aligned();
/** The world height of the dimension's bottom, for rules written in world heights, such as a band of world Y. */
int bottomY();
/** The Y in the world of the dimension's bottom block, such as {@code -64}, for rules written in world heights, such
* as a band of world Y; the same number as {@link com.volmit.world.PackWorld#minWorldY()}.
*/
int minWorldY();
/** The height of the terrain's surface at a column, above the dimension's bottom: the highest block of the terrain
* the host generated there, fluids ignored.
@@ -2,10 +2,10 @@ package com.volmit.vanilla;
import com.volmit.ModuleLog;
import com.volmit.block.BlockState;
import com.volmit.mantle.BlockBox;
import com.volmit.geometry.BlockBox;
import com.volmit.geometry.BlockPosition;
import com.volmit.resource.ResourceId;
import com.volmit.world.BlockAccess;
import com.volmit.world.BlockPosition;
import com.volmit.world.PackWorld;
import java.util.List;
import java.util.Optional;
@@ -33,10 +33,11 @@ public interface StructureFit {
*/
BlockBox area();
/** The world height of the dimension's bottom, for rules written in world heights: a band of world heights, the
* platform's deepslate below 0, noise sampled at world heights.
/** The Y in the world of the dimension's bottom block, such as {@code -64}, for rules written in world heights: a
* band of world heights, the platform's deepslate below 0, noise sampled at world heights. The same number as
* {@link PackWorld#minWorldY()}.
*/
int bottomY();
int minWorldY();
/** The chunk column's live blocks. */
BlockAccess blocks();
@@ -1,6 +1,6 @@
package com.volmit.world;
import com.volmit.block.BlockFace;
import com.volmit.geometry.BlockFace;
import com.volmit.block.BlockState;
import com.volmit.block.BlockTrait;
import com.volmit.resource.ResourceId;
@@ -29,9 +29,8 @@ public interface BlockAccess extends BlockView {
* {@link BlockTrait#SOLID} for what the platform counts as solid, {@link BlockTrait#FLUID} for a state holding any
* fluid (a source, a flowing fluid, a waterlogged block), {@link BlockTrait#LOG} for logs, wood, stems and hyphae and
* {@link BlockTrait#LEAVES} for leaves, by the platform's tags or names. These can differ in corner cases from
* {@link com.volmit.block.BlockRegistry#hasTrait}, which describes blocks the way generation picks them. Other
* traits are not answered: the platform's world has no native question for them, so asking throws
* {@link UnsupportedOperationException}.
* {@link com.volmit.block.BlockRegistry#hasTrait}, which describes blocks the way generation picks them; every other
* trait, which the platform's world has no question of its own for, is answered as that registry answers it.
*/
boolean is(BlockState state, BlockTrait trait);
@@ -1,7 +1,7 @@
package com.volmit.world;
import com.volmit.block.BlockState;
import com.volmit.mantle.BlockBox;
import com.volmit.geometry.BlockBox;
/** Blocks of an area to read: a placement's prepared generation blocks ({@link com.volmit.placement.PlacementContext#blocks()}),
* or, through {@link BlockAccess}, the live blocks of the platform's world. X and Z are world coordinates;
@@ -31,13 +31,12 @@ public interface PackWorld {
/** The settings of the world's dimension and of every region and biome it can reach, as mantle reaches see them. */
PackSettings settings();
/** The platform's Y of the dimension's bottom (-64 in the overworld). Every height the API carries is above that
* bottom; settings that name an absolute world Y, as packs write them for the platform, are converted with it:
* {@code heightAboveBottom = worldY - minHeight()}. Zero unless the host's dimensions begin below Y 0.
/** The Y in the world of the dimension's bottom block, such as {@code -64} in the overworld. Every height the API
* carries is above that bottom; settings that name an absolute world Y, as packs write them for the platform, are
* converted with it: {@code heightAboveBottom = worldY - minWorldY()}. The same number as
* {@link TerrainSampler#minWorldY()}.
*/
default int minHeight() {
return 0;
}
int minWorldY();
/**
* The world's one {@code type} instance, created by {@code create} the first time anyone asks for it. Modules keep
@@ -2,7 +2,7 @@ package com.volmit.world;
import com.volmit.block.BlockState;
import com.volmit.resource.ResourceId;
import com.volmit.mantle.BlockBox;
import com.volmit.geometry.BlockBox;
import java.util.Optional;
import java.util.OptionalInt;
@@ -67,9 +67,7 @@ public interface TerrainSampler {
/** The block an image map of the dimension gives the column's ground, replacing what its biome would put there; empty
* where no map does. Outside the bounds it throws like {@link #column}.
*/
default Optional<BlockState> surfaceBlock(int worldX, int worldZ) {
return Optional.empty();
}
Optional<BlockState> surfaceBlock(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.
@@ -77,7 +75,5 @@ public interface TerrainSampler {
int minWorldY();
/** The dimension stacked above this one, whose ground starts at {@link #upperDimensionY}; empty when nothing sits above. */
default Optional<UpperDimension> upperDimension() {
return Optional.empty();
}
Optional<UpperDimension> upperDimension();
}