From 84bd65fdc475c6adf940f7e8351a0ba0569da907 Mon Sep 17 00:00:00 2001 From: piexel Date: Fri, 6 Nov 2026 06:18:37 +0100 Subject: [PATCH] Give one concept one name The highest block of a column is highest(x, z, ignoreFluid) wherever it is asked, and a sapling's surroundings read a block with get like every other block view. The registry's property change is withPropertyIfAccepted, as it checks the block and keeps a content plugin's block, unlike BlockState.withProperty. BlockView no longer links the removed PlacementContext.blocks(). --- CONTRACTS.md | 4 ++-- README.md | 3 ++- api/src/main/java/com/volmit/block/BlockRegistry.java | 4 ++-- api/src/main/java/com/volmit/service/SaplingGrowth.java | 2 +- api/src/main/java/com/volmit/world/BlockView.java | 3 +-- api/src/main/java/com/volmit/world/RunningWorld.java | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CONTRACTS.md b/CONTRACTS.md index 1b04c2a3e..06651b19a 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -28,7 +28,7 @@ types that carry them and lists what the Iris adapter still owes. | Area a stage writes | `reach(blocks)`, `reach(PackReach)`, `writesMantle(...)` on stage definitions, `PackSettings` (with `resources()`, for a reach that depends on the size of the pack's objects), host `StageReach`, `ResolvedStage.reachBlocks`, `PipelineReach` | | Settings described for studio | `@Desc`, `@Required`, `@MinNumber`, `@MaxNumber`, `@MinItems`, `@Snippet`, `@Ref`/`Reference`, `FeatureRegistry.registerSettings`, host `LoadedPack.schema()` (`PackSchema`, `FeatureSchema`, `ObjectType`, `SchemaOption`, `ValueKind` with `HostKind`), `ModuleHost.describingHostTypesIn` | | Geometry and mantle registration | `FeatureRegistry`, host `ModuleRegistry`, `FeatureCatalog` | -| Block states and palettes | `BlockState`, `BlockRegistry` (`resolve(BlockSpec)`, `find(key)`, `blockEntity`, `hasTrait`, `oreFor`, `rotate(state, BlockTurn)`, `merge`, `withProperty`, `matches`), `BlockTurn`, `BlockTrait` (with `STORAGE`), `BlockSpec`, `PaletteSpec` and `PaletteSampler` (`BlockRegistry.palette`) | +| Block states and palettes | `BlockState`, `BlockRegistry` (`resolve(BlockSpec)`, `find(key)`, `blockEntity`, `hasTrait`, `oreFor`, `rotate(state, BlockTurn)`, `merge`, `withPropertyIfAccepted`, `matches`), `BlockTurn`, `BlockTrait` (with `STORAGE`), `BlockSpec`, `PaletteSpec` and `PaletteSampler` (`BlockRegistry.palette`) | | A pack's objects | `PlaceableObject` (`name`, size, `center`, `geometry`), `PackObjects` (`object`, `sizeOf`, `scaled` with `ScaleMethod`, `smartBored`, `build`), `PackResources.objects()` | | Placing through the pack's placement graph | `Placements.place(PlacementRun)` (`PackWorld.placements()`), `PlacementRun` (request, name, settings JSON, area, terrain, input, seed), `PlacementTerrain` (`recordPlacement` / `placementAt` with a `PlacementRecord`), `StructureVolumes`, `PlacedMarker`, `PlacementOutcome`; stages read `PlacementContext.placementTerrain()` and `input(type)`; mantle stages get a terrain from `MantleGenerationContext.placementTerrain()`; `RunningWorld.placementAt` reads what a placement recorded; `FeatureRegistry.registerPlacementType` names the type packs write placements as (host `FeatureCatalog.placementType()`, `PackSchema.placementType()`) | | Noise from pack-described styles | `NoiseStyle`, `StyledRange`, `PackResources.noise()`, `NoiseFactory`, `NoiseSampler` | @@ -220,7 +220,7 @@ running Iris is the pack publisher's responsibility. whose existing worlds depend on other seeds; the same world and purpose always get the same seed. - Answer `PackWorld.running()` for a world the host runs, empty for a tool's world. Its `layout()` covers every column of the world (not one chunk), with the same values chunk stages read; its `settings()` are the settings at a column and a - biome's declarations as chunk stages see them; `highestBlock` is the platform's highest block now; `caveFloors` are + biome's declarations as chunk stages see them; `highest` is the platform's highest block now; `caveFloors` are the cave floor markers of a chunk, in heights above the bottom; `sky()` is empty until the platform has the world. - Call the hooks with `LifecycleRunner`: `packLoaded` once per pack snapshot before its first world starts, `worldStarted` before the world generates anything, `warmUp` after it (on a thread of your choice, and wait for it before diff --git a/README.md b/README.md index 538fe23d0..8000f99f5 100644 --- a/README.md +++ b/README.md @@ -302,7 +302,8 @@ if (!outcome.isPlaced()) { - A placement commits whole or not at all: blocks, then markers, and only when no stage rejected and none threw. - A rotated object turns its blocks with `BlockRegistry.rotate(state, turn)`: the `BlockTurn` says where the rotation moves a direction, and the platform turns the state's facing, axis or rotation to the nearest it has. `merge`, - `withProperty` and `matches` change and compare states the way the platform does, and the `STORAGE` trait tells a + `withPropertyIfAccepted` and `matches` change and compare states the way the platform does (`BlockState.withProperty` + only sets the text, unchecked), and the `STORAGE` trait tells a container that holds items, such as for loot. ## Validators diff --git a/api/src/main/java/com/volmit/block/BlockRegistry.java b/api/src/main/java/com/volmit/block/BlockRegistry.java index ccf6e4d94..16f8c9b77 100644 --- a/api/src/main/java/com/volmit/block/BlockRegistry.java +++ b/api/src/main/java/com/volmit/block/BlockRegistry.java @@ -14,7 +14,7 @@ import java.util.Optional; * *

A content plugin's block ({@link BlockTrait#CUSTOM}) has the key of the block it is drawn as. The host knows it by * the state instance it handed out, from this registry or from a block it read, so pass that instance on as it is, and - * change it through {@link #withProperty}, {@link #rotate} and {@link #merge}: a state built from the key is the plain + * change it through {@link #withPropertyIfAccepted}, {@link #rotate} and {@link #merge}: a state built from the key is the plain * block. */ public interface BlockRegistry { @@ -79,7 +79,7 @@ public interface BlockRegistry { * {@code state} itself when the block has no property {@code name} or does not accept {@code value}, such as a * {@code facing} of {@code up} for a block that only faces sideways. */ - BlockState withProperty(BlockState state, String name, String value); + BlockState withPropertyIfAccepted(BlockState state, String name, String value); /** Whether {@code state} matches {@code pattern} as the platform compares them: the same block, and every property * {@code pattern} sets equal. diff --git a/api/src/main/java/com/volmit/service/SaplingGrowth.java b/api/src/main/java/com/volmit/service/SaplingGrowth.java index 234d0a0bf..0f2f9aec3 100644 --- a/api/src/main/java/com/volmit/service/SaplingGrowth.java +++ b/api/src/main/java/com/volmit/service/SaplingGrowth.java @@ -49,7 +49,7 @@ public interface SaplingGrowth { /** The height of the topmost block at the column, ignoring fluids when {@code ignoreFluid}. */ int highest(int x, int z, boolean ignoreFluid); - BlockState blockAt(int x, int y, int z); + BlockState get(int x, int y, int z); } /** diff --git a/api/src/main/java/com/volmit/world/BlockView.java b/api/src/main/java/com/volmit/world/BlockView.java index 6c2919d50..35441aed9 100644 --- a/api/src/main/java/com/volmit/world/BlockView.java +++ b/api/src/main/java/com/volmit/world/BlockView.java @@ -3,8 +3,7 @@ package com.volmit.world; import com.volmit.block.BlockState; 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; +/** Blocks of an area to read, such as, through {@link BlockAccess}, the live blocks of the platform's 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 call or invocation that handed them out; access afterwards throws IllegalStateException. diff --git a/api/src/main/java/com/volmit/world/RunningWorld.java b/api/src/main/java/com/volmit/world/RunningWorld.java index a92db8f6c..7f7f1685d 100644 --- a/api/src/main/java/com/volmit/world/RunningWorld.java +++ b/api/src/main/java/com/volmit/world/RunningWorld.java @@ -29,7 +29,7 @@ public interface RunningWorld { /** The height of the highest block in the column now: the terrain with what objects and structures added. * {@code ignoreFluid} skips fluid blocks, so it answers the ground under a sea. */ - int highestBlock(int worldX, int worldZ, boolean ignoreFluid); + int highest(int worldX, int worldZ, boolean ignoreFluid); /** The floors of the caves generation marked in the chunk, as positions of the floor blocks; none on a platform that * cannot read them.