diff --git a/CONTRACTS.md b/CONTRACTS.md index 2ceb7f9ec..2a2bf1fd4 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`, host `StageReach`, `ResolvedStage.reachBlocks`, `PipelineReach` | | Settings described for studio | `@Desc`, `@Required`, `@MinNumber`, `@MaxNumber`, `@MinItems`, `@Snippet`, `@Ref`/`Reference`, `FeatureRegistry.registerSettings`, `FeatureRegistry.registerHeldType`, host `FeatureCatalog.heldTypes()`, 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`, `BlockPalette`, `BlockSpec` (`BlockRegistry.resolve(BlockSpec)`, `blockEntity`), `PaletteSpec` and `PaletteSampler` (`BlockRegistry.palette`) | +| Block states and palettes | `BlockState`, `BlockRegistry` (`resolve(BlockSpec)`, `find(key)`, `blockEntity`, `hasTrait`, `oreFor`), `BlockTrait`, `BlockPalette`, `BlockSpec`, `PaletteSpec` and `PaletteSampler` (`BlockRegistry.palette`) | | Noise from pack-described styles | `NoiseStyle`, `StyledRange`, `PackResources.noise()`, `NoiseFactory`, `NoiseSampler` | | Values in settings | `BlockSpec`, `PaletteSpec`, `NoiseStyle`, `StyledRange`, `Range`, `BlockPosition`, `JigsawOverrides`, `Object` as `ValueKind.AnyKind` | | Decisions over and fit of the platform's own structures | service `VanillaStructures` (`rule`, `starts`, `shift`, `reach`, `beforePieces`, `afterPieces`, `setup`, `startedStructures`, `locatableStarts`, `locateStart`, `ChunkFilter`), `VanillaStructureRule`, `VanillaStructureContext`, `VanillaStructureStart`, `VanillaStructureStartContext`, `VanillaStructureSetup`, `PlatformStart`, `StartMemo`, `StartReach`, `StructureFit` (`Start`, `Piece`, `ColumnVisitor`), `DecorationStep`, `TerrainAdaptation`, `PieceKind`, `TemplateCells`, `world.BlockAccess`, host `FeatureCatalog.registrations(service)` | @@ -39,7 +39,8 @@ types that carry them and lists what the Iris adapter still owes. | Module lifecycle across loads, hotloads and reloads | `ModuleLifecycle`, `PackContext`, `FeatureRegistry.registerLifecycle`, host `FeatureCatalog.lifecycles()`, `LifecycleRunner` | | Host questions answered by modules | `@Service`, `Providers`, `FeatureRegistry.registerService`, host `FeatureCatalog.services(type)` / `service(type)`; services `ObjectsAt`, `StructureLocator` (`LocateResult`), `SaplingGrowth`, `Loot`, `BlockDrops`, `EntitySpawns`, `CaveBiomes`, `AmbientEffects`, `VanillaFeatures` (`DecorationStep`); values `ItemDrop`, `EntitySpec`, `ItemRegistry` (`PackResources.items()`) | | Terrain and settings sampling | `TerrainSampler`, `BiomeSample`, `TerrainSample`, `FeatureSettings` | -| Dense chunk output | `Hunk`, `GenerationContext.hunk`, reference `ArrayHunk` | +| Dense chunk output | `Hunk`, `GenerationContext.blocks`, reference `ArrayHunk` | +| Positions, boxes and faces | `com.volmit.geometry`: `BlockPosition`, `BlockBox`, `BlockFace` | | Sparse geometry and transforms | `ObjectGenerator`, `GeneratedObject`, `ObjectTransform`, `ObjectTransformer` | | Buffered placement writes | `PlacementRequest`, `PlacementAccess`, host-owned `PlacementEdit` | | Typed generation and persistent storage | `mantle` package | @@ -238,7 +239,10 @@ running Iris is the pack publisher's responsibility. has one; the default is `sample * 2 - 1`. Answer `NoiseSampler.scaled(factor)` by building the generator again with the factor folded into its scale, leaving the sampler it is called on untouched (the default multiplies the coordinates, which may round differently). -- Answer `PackWorld.minHeight()` (the platform's Y of the dimension's bottom), `PackResources.idOf(key)` (the ids the host gives +- Answer `PackWorld.minWorldY()` with the platform's Y of the dimension's bottom, the same number `TerrainSampler.minWorldY()`, + `PlatformStart.minWorldY()` and `StructureFit.minWorldY()` give. Answer `BlockRegistry.find(key)` with the platform's block at + its default properties, empty for a block or property the platform lacks. +- Answer `PackResources.idOf(key)` (the ids the host gives its own resources, characters an id cannot hold replaced) and `TerrainSampler.caveBiome(x, y, z)` (the cave biome of a block, without the work of the rest of the sample) when the defaults do not fit the host. - Answer `BlockRegistry.hasTrait` (`VINE` included) and `canPlaceOn` (the support rule decorations need) as the platform diff --git a/DESIGN.md b/DESIGN.md index f4bad890c..779238181 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -539,7 +539,7 @@ the platform's Y at its boundary. ## Chunk invocations `ChunkRunner.generate(inputs, invocationSeed, timings)` runs active chunk stages once each in resolved order. -`GenerationContext.hunk(type)` returns the host-owned local volume of that value type, shared by +`GenerationContext.blocks()` returns the host-owned local volume of the chunk's blocks, shared by 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 @@ -853,7 +853,7 @@ withers return copies, and equality is by value, so the host can cache by them. | `IrisGeneratorStyle` | `com.volmit.noise.NoiseStyle` | `PackResources.noise()`, a `NoiseFactory` building `NoiseSampler`s | | `IrisStyledRange` | `com.volmit.noise.StyledRange` | `at(noise, seed, x, z)` | | `IrisRange` | `com.volmit.config.Range` | none: `contains`, `pick(WorldRandom)` | -| `IrisPosition` | `com.volmit.world.BlockPosition` (existing record, now with a private no-argument constructor) | none | +| `IrisPosition` | `com.volmit.geometry.BlockPosition` (existing record, now with a private no-argument constructor) | none | | `IrisDirection` | none: a module declares its own enum with the same constant names, and maps to `BlockFace` | | | `IrisObjectRotation`, `IrisObjectScale` | none: settings of the module that picks a rotation or scale | `ObjectTransform`, `ObjectTransformer` (existing) | | `ObjectPlaceMode` | none: an enum of the placement modules | | @@ -881,9 +881,20 @@ Why these lines: generates. Earlier the chunk's mantle was read-only and a built-in facade reached past the view to the host's mantle; now the view lets any chunk stage write registered layers inside its own columns and reads the neighbors only, so no stage, built-in or not, needs a way around it. -- **`PackWorld.minHeight()`**: all heights are above the dimension's bottom, but packs write some settings as absolute - world Y (cave biome bands, floating island altitudes, structure bands). Those are converted by the module with the - platform's Y of the bottom, a default method (0) so a fixture without negative Y needs nothing. +- **One `minWorldY()`, never defaulted**: all heights are above the dimension's bottom, but packs write some settings as + absolute world Y (cave biome bands, floating island altitudes, structure bands). Those are converted by the module with + the platform's Y of the bottom. The world, the terrain sampler, platform starts and structure fits once called it + `minHeight`, `minWorldY` and `bottomY`, and the world's defaulted to 0, which is silently wrong in every overworld since + 1.18; now each answers `minWorldY()` and a host must, so forgetting it fails to compile instead of shifting bands. +- **No silently-wrong defaults.** `TerrainSampler.surfaceBlock`/`upperDimension`, `FeatureSettings.declaredBy` and + `BlockRegistry.oreFor` are abstract: their old defaults (empty, empty, empty, the ore unchanged) were answers a host + could ship without noticing they were wrong. Defaults kept are the ones correct for every host (`declaredInChunk`, + `NoiseSampler.signed`/`scaled`, `PackResources.idOf`, `TerrainSampler.caveBiome`). +- **Geometry is its own package.** `BlockPosition`, `BlockBox` and `BlockFace` are used by the world, the mantle, + objects, placement and services alike; living in `world`, `mantle` and `block` made each of those packages import the + others for a coordinate. +- **A chunk has one hunk, `blocks()`.** `hunk(Class)` promised volumes of other value types that no host ever + gave; a stage asking for one failed at run time. - **`NoiseSampler.signed(...)`** is the sample mapped to -1..1 that a host may answer from a per-thread memo of the coordinates it was just asked: a carver adds several fields and tests the sum around zero, and reads the same points of one field again and again, so the memo is the difference between caves that cost what they always did and caves that @@ -900,8 +911,12 @@ Why these lines: A palette without a pickable block throws when the sampler is asked for, where Iris returned `null`: the API has no absent block, and `@MinItems(1)` already says a palette needs one. - **Resolving a `BlockSpec` never throws.** It follows what packs rely on: a custom block of the pack's - `blocks` folder, then the platform's block, then the backup, then air. `resolve(String)` keeps throwing for - an unknown key. + `blocks` folder, then the platform's block, then the backup, then air. A module that names a block in code asks + `find(key)`, which is empty for an unknown key instead of throwing, so the caller decides what absence means. + `resolve(BlockState)` is gone: a state is written as it is, and the host defaults its missing properties. +- **`BlockTrait` lists only what is asked.** `INVENTORY`, `BLOCK_ENTITY` and `NEEDS_UPDATE` had no caller; a host + answering them was work for nothing. `BlockAccess.is` answers every trait the registry answers instead of throwing + for the ones outside the structure fit's set. - **Directions, rotations, scales and place modes stay module types.** They are small enums or settings whose meaning is a feature's (which axes may turn, by which steps; which anchor sampling a mode uses), and applying a rotation is already the host's `ObjectTransformer`. An API type would freeze a feature's choices. diff --git a/README.md b/README.md index 4e8179ad2..9c3020fef 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,10 @@ every API value that carries a height: terrain and biome samples, `BlockBox` bou 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. The one place a module meets the platform's Y is a setting that names an absolute world Y, as packs write them (a cave biome band between Y -64 and 320): it converts -with `world.minHeight()`, the platform's Y of the dimension's bottom. +with `minWorldY()`, the world Y of the dimension's bottom (`heightAboveBottom = worldY - minWorldY()`). The world, +the terrain sampler, platform starts and structure fits all answer it under that one name, and none of them has a +default: a host that forgets it does not compile. `BlockBox`, `BlockPosition` and `BlockFace` live in +`com.volmit.geometry`. ## Random streams @@ -176,7 +179,7 @@ its own chunk's columns; around it, the mantle stays as the mantle stages left i ```java graph.define(INSERT).run(ctx -> { - var blocks = ctx.hunk(BlockState.class); + var blocks = ctx.blocks(); ctx.mantle().blocks().visit(ctx.area(), (x, y, z, block) -> blocks.set(x - ctx.originX(), y, z - ctx.originZ(), block)); }); ``` @@ -898,6 +901,7 @@ Optional clock = pack.catalog().service(Clock.class); // a Pro - `GeneratedObject` is sparse, immutable local geometry. `PlacementRequest` aligns its anchor with a world position using checked arithmetic. - `Hunk` is a dense local volume (`width()`, `height()`, `depth()`); `ArrayHunk` is the bounds-checked reference. + A chunk's blocks are `GenerationContext.blocks()`, a `Hunk`. - A placement stage writes a plain block with `access.set(x, y, z, state)`, without a position, record or `Optional`; a block with a block entity goes through `access.set(PlacedBlock)`. `BlockState.withProperty` copies the properties once. - Invocation views (`ctx.mantle()`, its layers and blocks, a placement's `access().mantle()`) are made once per diff --git a/api/src/main/java/com/volmit/block/BlockFace.java b/api/src/main/java/com/volmit/block/BlockFace.java deleted file mode 100644 index 7e16105ce..000000000 --- a/api/src/main/java/com/volmit/block/BlockFace.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.volmit.block; - -public enum BlockFace { UP, DOWN, NORTH, SOUTH, EAST, WEST } diff --git a/api/src/main/java/com/volmit/block/BlockRegistry.java b/api/src/main/java/com/volmit/block/BlockRegistry.java index 26e5aedc4..d07dd9885 100644 --- a/api/src/main/java/com/volmit/block/BlockRegistry.java +++ b/api/src/main/java/com/volmit/block/BlockRegistry.java @@ -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. + * + *

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 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); diff --git a/api/src/main/java/com/volmit/block/BlockState.java b/api/src/main/java/com/volmit/block/BlockState.java index f8f431ab9..8d607c311 100644 --- a/api/src/main/java/com/volmit/block/BlockState.java +++ b/api/src/main/java/com/volmit/block/BlockState.java @@ -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 properties) { private static final String PROPERTIES_START = "["; diff --git a/api/src/main/java/com/volmit/block/BlockTrait.java b/api/src/main/java/com/volmit/block/BlockTrait.java index d8990f216..a6c41ea62 100644 --- a/api/src/main/java/com/volmit/block/BlockTrait.java +++ b/api/src/main/java/com/volmit/block/BlockTrait.java @@ -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 } diff --git a/api/src/main/java/com/volmit/config/FeatureSettings.java b/api/src/main/java/com/volmit/config/FeatureSettings.java index 76478702e..d62f37ffe 100644 --- a/api/src/main/java/com/volmit/config/FeatureSettings.java +++ b/api/src/main/java/com/volmit/config/FeatureSettings.java @@ -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 Optional declaredBy(ResourceId biome, Class featureType) { - return Optional.empty(); - } + Optional declaredBy(ResourceId biome, Class featureType); /** One level's declaration of the settings. * diff --git a/api/src/main/java/com/volmit/generation/ChunkContext.java b/api/src/main/java/com/volmit/generation/ChunkContext.java index ebb051f8f..ba5f9d62b 100644 --- a/api/src/main/java/com/volmit/generation/ChunkContext.java +++ b/api/src/main/java/com/volmit/generation/ChunkContext.java @@ -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 diff --git a/api/src/main/java/com/volmit/generation/GenerationContext.java b/api/src/main/java/com/volmit/generation/GenerationContext.java index 9ce1d8a87..0db36705b 100644 --- a/api/src/main/java/com/volmit/generation/GenerationContext.java +++ b/api/src/main/java/com/volmit/generation/GenerationContext.java @@ -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. */ - Hunk hunk(Class type); + Hunk blocks(); } diff --git a/api/src/main/java/com/volmit/mantle/BlockBox.java b/api/src/main/java/com/volmit/geometry/BlockBox.java similarity index 97% rename from api/src/main/java/com/volmit/mantle/BlockBox.java rename to api/src/main/java/com/volmit/geometry/BlockBox.java index deb3f1bca..56e5fd624 100644 --- a/api/src/main/java/com/volmit/mantle/BlockBox.java +++ b/api/src/main/java/com/volmit/geometry/BlockBox.java @@ -1,4 +1,4 @@ -package com.volmit.mantle; +package com.volmit.geometry; import java.util.Objects; diff --git a/api/src/main/java/com/volmit/geometry/BlockFace.java b/api/src/main/java/com/volmit/geometry/BlockFace.java new file mode 100644 index 000000000..f7e630894 --- /dev/null +++ b/api/src/main/java/com/volmit/geometry/BlockFace.java @@ -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 } diff --git a/api/src/main/java/com/volmit/world/BlockPosition.java b/api/src/main/java/com/volmit/geometry/BlockPosition.java similarity index 97% rename from api/src/main/java/com/volmit/world/BlockPosition.java rename to api/src/main/java/com/volmit/geometry/BlockPosition.java index ea0f674f2..b252e09c0 100644 --- a/api/src/main/java/com/volmit/world/BlockPosition.java +++ b/api/src/main/java/com/volmit/geometry/BlockPosition.java @@ -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). diff --git a/api/src/main/java/com/volmit/mantle/Mantle.java b/api/src/main/java/com/volmit/mantle/Mantle.java index 3fb6c4d33..80e5dd78c 100644 --- a/api/src/main/java/com/volmit/mantle/Mantle.java +++ b/api/src/main/java/com/volmit/mantle/Mantle.java @@ -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 diff --git a/api/src/main/java/com/volmit/mantle/MantleLayer.java b/api/src/main/java/com/volmit/mantle/MantleLayer.java index dd4411094..8128e228f 100644 --- a/api/src/main/java/com/volmit/mantle/MantleLayer.java +++ b/api/src/main/java/com/volmit/mantle/MantleLayer.java @@ -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. diff --git a/api/src/main/java/com/volmit/object/GeneratedObject.java b/api/src/main/java/com/volmit/object/GeneratedObject.java index 00ced8d3b..8b5386bb1 100644 --- a/api/src/main/java/com/volmit/object/GeneratedObject.java +++ b/api/src/main/java/com/volmit/object/GeneratedObject.java @@ -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; diff --git a/api/src/main/java/com/volmit/object/ObjectBlock.java b/api/src/main/java/com/volmit/object/ObjectBlock.java index 7b9895bfd..8282c63ce 100644 --- a/api/src/main/java/com/volmit/object/ObjectBlock.java +++ b/api/src/main/java/com/volmit/object/ObjectBlock.java @@ -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; diff --git a/api/src/main/java/com/volmit/object/ObjectMarker.java b/api/src/main/java/com/volmit/object/ObjectMarker.java index 0367dd1a4..3e16afcbe 100644 --- a/api/src/main/java/com/volmit/object/ObjectMarker.java +++ b/api/src/main/java/com/volmit/object/ObjectMarker.java @@ -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; diff --git a/api/src/main/java/com/volmit/placement/PlacedBlock.java b/api/src/main/java/com/volmit/placement/PlacedBlock.java index e9b2a9ab6..38d5c09e2 100644 --- a/api/src/main/java/com/volmit/placement/PlacedBlock.java +++ b/api/src/main/java/com/volmit/placement/PlacedBlock.java @@ -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; diff --git a/api/src/main/java/com/volmit/placement/PlacedMarker.java b/api/src/main/java/com/volmit/placement/PlacedMarker.java index 631b62089..9e4cae445 100644 --- a/api/src/main/java/com/volmit/placement/PlacedMarker.java +++ b/api/src/main/java/com/volmit/placement/PlacedMarker.java @@ -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; diff --git a/api/src/main/java/com/volmit/placement/PlacementRequest.java b/api/src/main/java/com/volmit/placement/PlacementRequest.java index 21af84d93..0f6d4afea 100644 --- a/api/src/main/java/com/volmit/placement/PlacementRequest.java +++ b/api/src/main/java/com/volmit/placement/PlacementRequest.java @@ -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 diff --git a/api/src/main/java/com/volmit/service/AmbientEffects.java b/api/src/main/java/com/volmit/service/AmbientEffects.java index 7e8163eec..385e6a4f3 100644 --- a/api/src/main/java/com/volmit/service/AmbientEffects.java +++ b/api/src/main/java/com/volmit/service/AmbientEffects.java @@ -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; diff --git a/api/src/main/java/com/volmit/service/BlockDrops.java b/api/src/main/java/com/volmit/service/BlockDrops.java index b1156b0e8..83cc6908f 100644 --- a/api/src/main/java/com/volmit/service/BlockDrops.java +++ b/api/src/main/java/com/volmit/service/BlockDrops.java @@ -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; diff --git a/api/src/main/java/com/volmit/service/EntitySpawns.java b/api/src/main/java/com/volmit/service/EntitySpawns.java index d13cb2ecf..3f2f1e98e 100644 --- a/api/src/main/java/com/volmit/service/EntitySpawns.java +++ b/api/src/main/java/com/volmit/service/EntitySpawns.java @@ -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; diff --git a/api/src/main/java/com/volmit/service/LocateResult.java b/api/src/main/java/com/volmit/service/LocateResult.java index 03e1c825a..509479648 100644 --- a/api/src/main/java/com/volmit/service/LocateResult.java +++ b/api/src/main/java/com/volmit/service/LocateResult.java @@ -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 diff --git a/api/src/main/java/com/volmit/service/Loot.java b/api/src/main/java/com/volmit/service/Loot.java index b792000d7..2809c1488 100644 --- a/api/src/main/java/com/volmit/service/Loot.java +++ b/api/src/main/java/com/volmit/service/Loot.java @@ -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; diff --git a/api/src/main/java/com/volmit/service/SaplingGrowth.java b/api/src/main/java/com/volmit/service/SaplingGrowth.java index ca85bf92d..6a2205f5b 100644 --- a/api/src/main/java/com/volmit/service/SaplingGrowth.java +++ b/api/src/main/java/com/volmit/service/SaplingGrowth.java @@ -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; diff --git a/api/src/main/java/com/volmit/vanilla/PlatformStart.java b/api/src/main/java/com/volmit/vanilla/PlatformStart.java index bc163a3cc..07805c92d 100644 --- a/api/src/main/java/com/volmit/vanilla/PlatformStart.java +++ b/api/src/main/java/com/volmit/vanilla/PlatformStart.java @@ -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. diff --git a/api/src/main/java/com/volmit/vanilla/StructureFit.java b/api/src/main/java/com/volmit/vanilla/StructureFit.java index e48067439..e73628619 100644 --- a/api/src/main/java/com/volmit/vanilla/StructureFit.java +++ b/api/src/main/java/com/volmit/vanilla/StructureFit.java @@ -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(); diff --git a/api/src/main/java/com/volmit/world/BlockAccess.java b/api/src/main/java/com/volmit/world/BlockAccess.java index 24c656c6a..f7082e21a 100644 --- a/api/src/main/java/com/volmit/world/BlockAccess.java +++ b/api/src/main/java/com/volmit/world/BlockAccess.java @@ -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); diff --git a/api/src/main/java/com/volmit/world/BlockView.java b/api/src/main/java/com/volmit/world/BlockView.java index 7c0e7c60d..6c2919d50 100644 --- a/api/src/main/java/com/volmit/world/BlockView.java +++ b/api/src/main/java/com/volmit/world/BlockView.java @@ -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; diff --git a/api/src/main/java/com/volmit/world/PackWorld.java b/api/src/main/java/com/volmit/world/PackWorld.java index 453c0f23f..cf7af027f 100644 --- a/api/src/main/java/com/volmit/world/PackWorld.java +++ b/api/src/main/java/com/volmit/world/PackWorld.java @@ -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 diff --git a/api/src/main/java/com/volmit/world/TerrainSampler.java b/api/src/main/java/com/volmit/world/TerrainSampler.java index cdc0eb1b0..2a64a8317 100644 --- a/api/src/main/java/com/volmit/world/TerrainSampler.java +++ b/api/src/main/java/com/volmit/world/TerrainSampler.java @@ -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 surfaceBlock(int worldX, int worldZ) { - return Optional.empty(); - } + Optional 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() { - return Optional.empty(); - } + Optional upperDimension(); } diff --git a/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java b/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java index 7f65b9f63..0f7266de4 100644 --- a/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java +++ b/api/src/test/java/com/volmit/ItemAndEntityValuesTest.java @@ -1,13 +1,13 @@ package com.volmit; import com.volmit.entity.EntitySpec; +import com.volmit.geometry.BlockPosition; import com.volmit.item.ItemDrop; import com.volmit.item.ItemEnchantment; import com.volmit.service.AmbientEffects; import com.volmit.service.BlockDrops; import com.volmit.service.EntitySpawns; import com.volmit.service.SaplingGrowth; -import com.volmit.world.BlockPosition; import org.junit.jupiter.api.Test; import java.util.ArrayList; diff --git a/api/src/test/java/com/volmit/generation/ChunkContextTest.java b/api/src/test/java/com/volmit/generation/ChunkContextTest.java index 9c75f51b5..b9a0c99d7 100644 --- a/api/src/test/java/com/volmit/generation/ChunkContextTest.java +++ b/api/src/test/java/com/volmit/generation/ChunkContextTest.java @@ -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.mantle.Mantle; import com.volmit.world.PackWorld; import com.volmit.world.TerrainSampler; diff --git a/api/src/test/java/com/volmit/mantle/MantleValueTest.java b/api/src/test/java/com/volmit/mantle/MantleValueTest.java index 4fea9c395..6e6b678b2 100644 --- a/api/src/test/java/com/volmit/mantle/MantleValueTest.java +++ b/api/src/test/java/com/volmit/mantle/MantleValueTest.java @@ -1,5 +1,6 @@ package com.volmit.mantle; +import com.volmit.geometry.BlockBox; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; diff --git a/host/src/main/java/com/volmit/host/ChunkInvocation.java b/host/src/main/java/com/volmit/host/ChunkInvocation.java index f598e883c..07b1b7de7 100644 --- a/host/src/main/java/com/volmit/host/ChunkInvocation.java +++ b/host/src/main/java/com/volmit/host/ChunkInvocation.java @@ -1,6 +1,7 @@ package com.volmit.host; import com.volmit.IrisFeature; +import com.volmit.block.BlockState; import com.volmit.config.FeatureSettings; import com.volmit.config.SettingsStack; import com.volmit.generation.GenerationContext; @@ -68,8 +69,8 @@ final class ChunkInvocation implements ChunkStageContext { } @Override - public Hunk hunk(Class type) { - return inputs.hunk(type); + public Hunk blocks() { + return inputs.blocks(); } @Override diff --git a/host/src/main/java/com/volmit/host/ChunkMantle.java b/host/src/main/java/com/volmit/host/ChunkMantle.java index 64bc2f911..a44e4184f 100644 --- a/host/src/main/java/com/volmit/host/ChunkMantle.java +++ b/host/src/main/java/com/volmit/host/ChunkMantle.java @@ -2,7 +2,7 @@ package com.volmit.host; import com.volmit.block.BlockState; import com.volmit.generation.ChunkContext; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; import com.volmit.mantle.Mantle; import com.volmit.mantle.MantleEdit; import com.volmit.mantle.MantleKey; diff --git a/host/src/main/java/com/volmit/host/ModuleWorld.java b/host/src/main/java/com/volmit/host/ModuleWorld.java index 0fcc4141f..fcc82bf51 100644 --- a/host/src/main/java/com/volmit/host/ModuleWorld.java +++ b/host/src/main/java/com/volmit/host/ModuleWorld.java @@ -45,8 +45,8 @@ final class ModuleWorld implements PackWorld { } @Override - public int minHeight() { - return world.minHeight(); + public int minWorldY() { + return world.minWorldY(); } @Override diff --git a/host/src/main/java/com/volmit/host/PlacementViews.java b/host/src/main/java/com/volmit/host/PlacementViews.java index 533f3866d..241685c03 100644 --- a/host/src/main/java/com/volmit/host/PlacementViews.java +++ b/host/src/main/java/com/volmit/host/PlacementViews.java @@ -1,7 +1,7 @@ package com.volmit.host; import com.volmit.block.BlockState; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; import com.volmit.mantle.Mantle; import com.volmit.mantle.MantleEdit; import com.volmit.mantle.MantleKey; diff --git a/host/src/test/java/com/volmit/ApiValuesTest.java b/host/src/test/java/com/volmit/ApiValuesTest.java index 1a2ee27a0..8cd873584 100644 --- a/host/src/test/java/com/volmit/ApiValuesTest.java +++ b/host/src/test/java/com/volmit/ApiValuesTest.java @@ -2,7 +2,7 @@ package com.volmit; import com.volmit.block.BlockState; import com.volmit.host.ArrayHunk; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.*; import com.volmit.object.*; import com.volmit.placement.PlacementRequest; import com.volmit.resource.*; diff --git a/host/src/test/java/com/volmit/example/ChunkPipelineTest.java b/host/src/test/java/com/volmit/example/ChunkPipelineTest.java index fed6ce80e..d29ff1056 100644 --- a/host/src/test/java/com/volmit/example/ChunkPipelineTest.java +++ b/host/src/test/java/com/volmit/example/ChunkPipelineTest.java @@ -20,7 +20,7 @@ import com.volmit.host.LoadedModules; import com.volmit.host.MantleRunner; import com.volmit.host.StageTimings; import com.volmit.hunk.Hunk; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; import com.volmit.mantle.MantleLayer; import com.volmit.resource.ResourceId; import com.volmit.stage.ChunkStageContext; @@ -66,7 +66,7 @@ class ChunkPipelineTest { private static Hunk generate(ColumnSettings settings) { var blocks = new ArrayHunk<>(BlockState.class, SIZE, HEIGHT, SIZE, AIR); - runner().generate(TestContexts.generation(Map.of(BlockState.class, blocks), settings, null), TestContexts.SEED, StageTimings.NONE); + runner().generate(TestContexts.generation(blocks, settings, null), TestContexts.SEED, StageTimings.NONE); return blocks; } @@ -128,7 +128,7 @@ class ChunkPipelineTest { var settings = new ColumnSettings((x, z) -> List.of(dimension, x < 8 ? swamp : plains)); new ChunkRunner(TestSetups.stages(module).resolve(Pipeline.CHUNK)) - .generate(TestContexts.generation(Map.of(), settings, null), TestContexts.SEED, StageTimings.NONE); + .generate(TestContexts.generation(null,settings, null), TestContexts.SEED, StageTimings.NONE); assertEquals(List.of(List.of(DIMENSION, SWAMP, PLAINS), List.of(DIMENSION, SWAMP)), received, "the body sees every level of every column, a column read that column's levels"); @@ -150,7 +150,7 @@ class ChunkPipelineTest { var blocks = new ArrayHunk<>(BlockState.class, CHUNK, HEIGHT, CHUNK, AIR); 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, + TestContexts.generation(blocks, ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED, StageTimings.NONE); assertEquals(VeinModule.ORE_BLOCK, blocks.get(7, 4, 7)); assertEquals(VeinModule.ORE_BLOCK, blocks.get(15, 4, 7)); @@ -169,7 +169,7 @@ class ChunkPipelineTest { public ModuleInfo info() { return ModuleInfo.of("test:copy", "Copy", "1"); } public void setup(ModuleSetup setup) { setup.stages().define(copy).run(context -> { - var blocks = context.hunk(BlockState.class); + var blocks = context.blocks(); context.mantle().blocks().visit(chunkArea, (x, y, z, block) -> blocks.set(x, y, z, block)); }); } @@ -177,7 +177,7 @@ class ChunkPipelineTest { var blocks = new ArrayHunk<>(BlockState.class, CHUNK, HEIGHT, CHUNK, GRASS); new ChunkRunner(TestSetups.stages(module).resolve(Pipeline.CHUNK)).generate( - TestContexts.generation(Map.of(BlockState.class, blocks), ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED, + TestContexts.generation(blocks, ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED, StageTimings.NONE); assertEquals(stone, blocks.get(3, 2, 5)); @@ -205,7 +205,7 @@ class ChunkPipelineTest { var blocks = new ArrayHunk<>(BlockState.class, CHUNK, HEIGHT, CHUNK, AIR); new ChunkRunner(TestSetups.stages(module).resolve(Pipeline.CHUNK)).generate( - TestContexts.generation(Map.of(BlockState.class, blocks), ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED, + TestContexts.generation(blocks, ColumnSettings.NONE, mantle.within(chunkArea)), TestContexts.SEED, StageTimings.NONE); assertEquals(List.of("true", "false"), carved); @@ -216,7 +216,7 @@ class ChunkPipelineTest { var timed = new ArrayList(); var blocks = new ArrayHunk<>(BlockState.class, SIZE, HEIGHT, SIZE, AIR); - runner().generate(TestContexts.generation(Map.of(BlockState.class, blocks), ColumnSettings.NONE, null), TestContexts.SEED, + runner().generate(TestContexts.generation(blocks, ColumnSettings.NONE, null), TestContexts.SEED, (stage, nanos) -> timed.add(stage.stage().id() + (nanos >= 0 ? "" : " ran backwards"))); assertEquals(List.of("iris:terrain/surface"), timed, "grass has no settings here, so it does not run and is not reported"); @@ -228,7 +228,7 @@ class ChunkPipelineTest { var aroundTheChunk = new BlockBox(-CHUNK, BOTTOM, -CHUNK, 2 * CHUNK, TOP, 2 * CHUNK); var graph = TestSetups.stages(oreWriter((context, layer) -> layer.set(15, 3, 0, 1))).resolve(Pipeline.CHUNK); - new ChunkRunner(graph).generate(TestContexts.generation(Map.of(), ColumnSettings.NONE, mantle.within(aroundTheChunk)), + new ChunkRunner(graph).generate(TestContexts.generation(null,ColumnSettings.NONE, mantle.within(aroundTheChunk)), TestContexts.SEED, StageTimings.NONE); assertEquals(1, mantle.get(VeinModule.ORE, 15, 3, 0)); @@ -248,7 +248,7 @@ class ChunkPipelineTest { views.add(context.mantle().blocks()); })).resolve(Pipeline.CHUNK); - new ChunkRunner(graph).generate(TestContexts.generation(Map.of(), ColumnSettings.NONE, mantle.within(aroundTheChunk)), + new ChunkRunner(graph).generate(TestContexts.generation(null,ColumnSettings.NONE, mantle.within(aroundTheChunk)), TestContexts.SEED, StageTimings.NONE); assertSame(views.get(0), views.get(1)); @@ -265,7 +265,7 @@ class ChunkPipelineTest { read.add(layer.get(CHUNK, 0, 0)); layer.set(CHUNK, 0, 0, 1); })).resolve(Pipeline.CHUNK); - var inputs = TestContexts.generation(Map.of(), ColumnSettings.NONE, mantle.within(aroundTheChunk)); + var inputs = TestContexts.generation(null,ColumnSettings.NONE, mantle.within(aroundTheChunk)); var failure = assertThrows(UnsupportedOperationException.class, () -> new ChunkRunner(graph).generate(inputs, TestContexts.SEED, StageTimings.NONE)); diff --git a/host/src/test/java/com/volmit/example/PlacementLifecyclePortTest.java b/host/src/test/java/com/volmit/example/PlacementLifecyclePortTest.java index 1d878b132..25bb1976c 100644 --- a/host/src/test/java/com/volmit/example/PlacementLifecyclePortTest.java +++ b/host/src/test/java/com/volmit/example/PlacementLifecyclePortTest.java @@ -11,7 +11,8 @@ import com.volmit.host.PlacementRunner; import com.volmit.host.ResolvedGraph; import com.volmit.host.StageStreams; import com.volmit.host.StageTimings; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; +import com.volmit.geometry.BlockPosition; import com.volmit.object.GeneratedObject; import com.volmit.object.ObjectBlock; import com.volmit.placement.PlacedBlock; @@ -24,7 +25,6 @@ import com.volmit.support.MemoryEdit; import com.volmit.support.TestContexts; import com.volmit.support.TestSetups; import com.volmit.support.TestTerrain; -import com.volmit.world.BlockPosition; import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Collections; diff --git a/host/src/test/java/com/volmit/example/chunk/GrassModule.java b/host/src/test/java/com/volmit/example/chunk/GrassModule.java index ee9987d4e..4eba64642 100644 --- a/host/src/test/java/com/volmit/example/chunk/GrassModule.java +++ b/host/src/test/java/com/volmit/example/chunk/GrassModule.java @@ -30,7 +30,7 @@ public final class GrassModule implements IrisModule { private static void cover(ChunkStageContext context) { var heights = context.output(TerrainModule.SURFACE); - var blocks = context.hunk(BlockState.class); + var blocks = context.blocks(); for (int x = 0; x < blocks.width(); x++) { for (int z = 0; z < blocks.depth(); z++) { var here = context.settings().at(GrassSettings.class, context.originX() + x, context.originZ() + z).mostSpecific(); diff --git a/host/src/test/java/com/volmit/example/chunk/TerrainModule.java b/host/src/test/java/com/volmit/example/chunk/TerrainModule.java index b7390d71e..95f17daa9 100644 --- a/host/src/test/java/com/volmit/example/chunk/TerrainModule.java +++ b/host/src/test/java/com/volmit/example/chunk/TerrainModule.java @@ -30,7 +30,7 @@ public final class TerrainModule implements IrisModule { } private static SurfaceHeights shape(ChunkStageContext context) { - var blocks = context.hunk(BlockState.class); + var blocks = context.blocks(); var heights = new SurfaceHeights(blocks.width(), blocks.depth()); for (int x = 0; x < blocks.width(); x++) { for (int z = 0; z < blocks.depth(); z++) { diff --git a/host/src/test/java/com/volmit/example/chunk/VeinModule.java b/host/src/test/java/com/volmit/example/chunk/VeinModule.java index 8f1355e3f..0e733f9a0 100644 --- a/host/src/test/java/com/volmit/example/chunk/VeinModule.java +++ b/host/src/test/java/com/volmit/example/chunk/VeinModule.java @@ -6,7 +6,7 @@ import com.volmit.ModuleSetup; import com.volmit.block.BlockState; import com.volmit.config.PackSettings; import com.volmit.generation.ChunkContext; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; import com.volmit.mantle.MantleCodec; import com.volmit.mantle.MantleKey; import com.volmit.mantle.MantleLifetime; @@ -62,7 +62,7 @@ public final class VeinModule implements IrisModule { } private static void place(ChunkStageContext context) { - var blocks = context.hunk(BlockState.class); + var blocks = context.blocks(); var chunk = new BlockBox(context.originX(), 0, context.originZ(), context.originX() + blocks.width(), blocks.height(), context.originZ() + blocks.depth()); context.mantle().layer(ORE).visit(chunk, (x, y, z, planned) -> diff --git a/host/src/test/java/com/volmit/example/placement/AnchorModule.java b/host/src/test/java/com/volmit/example/placement/AnchorModule.java index 0bfaab0f3..c6fa4b413 100644 --- a/host/src/test/java/com/volmit/example/placement/AnchorModule.java +++ b/host/src/test/java/com/volmit/example/placement/AnchorModule.java @@ -6,7 +6,7 @@ import com.volmit.ModuleSetup; import com.volmit.stage.PlacementStage; import com.volmit.stage.PlacementStageContext; import com.volmit.stage.Stage; -import com.volmit.world.BlockPosition; +import com.volmit.geometry.BlockPosition; import com.volmit.world.BlockView; /** Port of PlacementModuleAnchor with center-height sampling: rest the anchor on the surface. */ diff --git a/host/src/test/java/com/volmit/example/placement/AnchorResult.java b/host/src/test/java/com/volmit/example/placement/AnchorResult.java index b95d0b9eb..57e40e82a 100644 --- a/host/src/test/java/com/volmit/example/placement/AnchorResult.java +++ b/host/src/test/java/com/volmit/example/placement/AnchorResult.java @@ -1,7 +1,7 @@ package com.volmit.example.placement; import com.volmit.placement.PlacementRequest; -import com.volmit.world.BlockPosition; +import com.volmit.geometry.BlockPosition; /** The world position the object's local anchor is placed at. */ public record AnchorResult(BlockPosition anchor) { diff --git a/host/src/test/java/com/volmit/example/placement/SnowHeights.java b/host/src/test/java/com/volmit/example/placement/SnowHeights.java index d03d5f0f0..454e11f50 100644 --- a/host/src/test/java/com/volmit/example/placement/SnowHeights.java +++ b/host/src/test/java/com/volmit/example/placement/SnowHeights.java @@ -1,6 +1,6 @@ package com.volmit.example.placement; -import com.volmit.world.BlockPosition; +import com.volmit.geometry.BlockPosition; import java.util.List; import java.util.Map; import java.util.TreeMap; diff --git a/host/src/test/java/com/volmit/example/placement/StiltModule.java b/host/src/test/java/com/volmit/example/placement/StiltModule.java index 4b84d587a..bc438823c 100644 --- a/host/src/test/java/com/volmit/example/placement/StiltModule.java +++ b/host/src/test/java/com/volmit/example/placement/StiltModule.java @@ -8,7 +8,7 @@ import com.volmit.stage.BlockStage; import com.volmit.stage.PlacementStage; import com.volmit.stage.PlacementStageContext; import com.volmit.stage.Stage; -import com.volmit.world.BlockPosition; +import com.volmit.geometry.BlockPosition; /** Port of PlacementModuleStilt: collect the lowest layer per block, then fill down after writes. */ public final class StiltModule implements IrisModule { diff --git a/host/src/test/java/com/volmit/example/placement/Transforms.java b/host/src/test/java/com/volmit/example/placement/Transforms.java index 52a0a0158..9a0196f9c 100644 --- a/host/src/test/java/com/volmit/example/placement/Transforms.java +++ b/host/src/test/java/com/volmit/example/placement/Transforms.java @@ -1,6 +1,6 @@ package com.volmit.example.placement; -import com.volmit.world.BlockPosition; +import com.volmit.geometry.BlockPosition; /** Placement-wide rotation chosen once per attempt, like Iris's spin kernel. */ public record Transforms(int quarterTurns) { diff --git a/host/src/test/java/com/volmit/example/world/WorldStateExampleTest.java b/host/src/test/java/com/volmit/example/world/WorldStateExampleTest.java index c7c663535..c4458db9e 100644 --- a/host/src/test/java/com/volmit/example/world/WorldStateExampleTest.java +++ b/host/src/test/java/com/volmit/example/world/WorldStateExampleTest.java @@ -95,7 +95,7 @@ class WorldStateExampleTest { var startedWith = RuinsModule.planted(world); assertEquals(TestContexts.SEED, startedWith.seed); - new ChunkRunner(pack.chunk()).generate(TestContexts.generation(Map.of(), ColumnSettings.NONE, null, world), TestContexts.SEED, + new ChunkRunner(pack.chunk()).generate(TestContexts.generation(null,ColumnSettings.NONE, null, world), TestContexts.SEED, StageTimings.NONE); assertSame(startedWith, RuinsModule.planted(world), "the stage used the state the hook built"); diff --git a/host/src/test/java/com/volmit/host/ExtensionsTest.java b/host/src/test/java/com/volmit/host/ExtensionsTest.java index 4c810549d..3e038867a 100644 --- a/host/src/test/java/com/volmit/host/ExtensionsTest.java +++ b/host/src/test/java/com/volmit/host/ExtensionsTest.java @@ -4,6 +4,7 @@ import com.volmit.IrisModule; import com.volmit.ModuleInfo; import com.volmit.ModuleLog; import com.volmit.ModuleSetup; +import com.volmit.block.BlockState; import com.volmit.config.FeatureSettings; import com.volmit.config.PackSettings; import com.volmit.generation.GenerationContext; @@ -49,7 +50,7 @@ class ExtensionsTest { } }; var world = new OfferingWorld(new WorldOffer("iris")); - var inputs = new OfferingChunk(TestContexts.generation(Map.of(), null, null, world), new ChunkOffer(0)); + var inputs = new OfferingChunk(TestContexts.generation(null, null, null, world), new ChunkOffer(0)); new ChunkRunner(TestSetups.stages(module).resolve(Pipeline.CHUNK)).generate(inputs, TestContexts.SEED, StageTimings.NONE); @@ -81,6 +82,7 @@ class ExtensionsTest { public long seed() { return TestContexts.SEED; } public PackResources resources() { throw new AssertionError("Unused resources"); } public PackSettings settings() { throw new AssertionError("Unused settings"); } + public int minWorldY() { return 0; } public T state(Class type, Function create) { return states.state(type, () -> create.apply(this)); } public ModuleLog log() { return ModuleLogs.discarding(); } @@ -96,7 +98,7 @@ class ExtensionsTest { public TerrainSampler terrain() { return inputs.terrain(); } public FeatureSettings settings() { return inputs.settings(); } public Mantle mantle() { return inputs.mantle(); } - public Hunk hunk(Class type) { return inputs.hunk(type); } + public Hunk blocks() { return inputs.blocks(); } public PackWorld world() { return inputs.world(); } @Override diff --git a/host/src/test/java/com/volmit/host/ModuleLogTest.java b/host/src/test/java/com/volmit/host/ModuleLogTest.java index bc4f1f1ce..7e7b38c77 100644 --- a/host/src/test/java/com/volmit/host/ModuleLogTest.java +++ b/host/src/test/java/com/volmit/host/ModuleLogTest.java @@ -224,7 +224,7 @@ class ModuleLogTest { var runner = new ChunkRunner(builder.resolve(Pipeline.CHUNK)); try (var world = new TestWorld()) { - runner.generate(TestContexts.generation(Map.of(), null, null, world), TestContexts.SEED, StageTimings.NONE); + runner.generate(TestContexts.generation(null, null, null, world), TestContexts.SEED, StageTimings.NONE); } assertEquals(List.of("[test:alpha] context", "[test:alpha] world", "[test:beta] context", "[test:beta] world"), @@ -305,7 +305,7 @@ class ModuleLogTest { try (var first = new TestWorld(); var second = new TestWorld()) { for (var world : List.of(first, first, second)) { - runner.generate(TestContexts.generation(Map.of(), null, null, world), TestContexts.SEED, StageTimings.NONE); + runner.generate(TestContexts.generation(null, null, null, world), TestContexts.SEED, StageTimings.NONE); } } diff --git a/host/src/test/java/com/volmit/host/PackSchemaTest.java b/host/src/test/java/com/volmit/host/PackSchemaTest.java index 09bae8108..0cf7692a5 100644 --- a/host/src/test/java/com/volmit/host/PackSchemaTest.java +++ b/host/src/test/java/com/volmit/host/PackSchemaTest.java @@ -494,7 +494,7 @@ class PackSchemaTest { import com.volmit.config.Range; import com.volmit.noise.NoiseStyle; import com.volmit.noise.StyledRange; - import com.volmit.world.BlockPosition; + import com.volmit.geometry.BlockPosition; import java.util.*; @Feature(id = "example:flora", name = "Flora", key = "flora", targets = Level.BIOME) @@ -520,7 +520,7 @@ class PackSchemaTest { assertEquals(new ObjectKind("com.volmit.noise.StyledRange"), option(settings, "height").kind()); assertEquals(new ObjectKind("com.volmit.config.Range"), option(settings, "light").kind()); assertEquals(Optional.of(Map.of("max", 15.0, "min", 0.0)), option(settings, "light").defaultValue()); - assertEquals(new ObjectKind("com.volmit.world.BlockPosition"), option(settings, "offset").kind()); + assertEquals(new ObjectKind("com.volmit.geometry.BlockPosition"), option(settings, "offset").kind()); assertEquals(Optional.of(Map.of("x", 1L, "y", 2L, "z", 3L)), option(settings, "offset").defaultValue()); assertEquals(new AnyKind(), option(settings, "extra").kind(), "Object holds any JSON value"); diff --git a/host/src/test/java/com/volmit/host/StageGraphTest.java b/host/src/test/java/com/volmit/host/StageGraphTest.java index dd7b1de81..2d38064fe 100644 --- a/host/src/test/java/com/volmit/host/StageGraphTest.java +++ b/host/src/test/java/com/volmit/host/StageGraphTest.java @@ -9,7 +9,8 @@ import com.volmit.ModuleSetup; import com.volmit.block.BlockState; import com.volmit.config.Feature; import com.volmit.config.FeatureSettings.Entry; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; +import com.volmit.geometry.BlockPosition; import com.volmit.mantle.MantleCodec; import com.volmit.mantle.MantleKey; import com.volmit.mantle.MantleLifetime; @@ -33,7 +34,6 @@ import com.volmit.support.MemoryMantle; import com.volmit.support.TestContexts; import com.volmit.support.TestSetups; import com.volmit.support.TestTerrain; -import com.volmit.world.BlockPosition; import com.volmit.example.placement.SnowModule; import com.volmit.example.placement.SnowSettings; import org.junit.jupiter.api.Test; diff --git a/host/src/test/java/com/volmit/host/StageStreamsTest.java b/host/src/test/java/com/volmit/host/StageStreamsTest.java index 3f50b3073..8de7e3f28 100644 --- a/host/src/test/java/com/volmit/host/StageStreamsTest.java +++ b/host/src/test/java/com/volmit/host/StageStreamsTest.java @@ -4,7 +4,8 @@ import com.volmit.IrisModule; import com.volmit.ModuleInfo; import com.volmit.ModuleSetup; import com.volmit.block.BlockState; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; +import com.volmit.geometry.BlockPosition; import com.volmit.object.GeneratedObject; import com.volmit.object.ObjectBlock; import com.volmit.placement.PlacementRequest; @@ -17,7 +18,6 @@ import com.volmit.support.MemoryEdit; import com.volmit.support.TestContexts; import com.volmit.support.TestSetups; import com.volmit.support.TestTerrain; -import com.volmit.world.BlockPosition; import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -131,7 +131,7 @@ class StageStreamsTest { var graph = resolve(Pipeline.CHUNK, module("a:mod", stages -> stages.define(Stage.chunk("a:mod/ores")) .run(context -> drawn.add((long) context.random().nextInt(BOUND))))); - new ChunkRunner(graph).generate(TestContexts.generation(Map.of()), TestContexts.SEED, StageTimings.NONE); + new ChunkRunner(graph).generate(TestContexts.generation(null), TestContexts.SEED, StageTimings.NONE); assertEquals(firstDraws(TestContexts.SEED, "a:mod/ores", 1), drawn); } diff --git a/host/src/test/java/com/volmit/support/ColumnSettings.java b/host/src/test/java/com/volmit/support/ColumnSettings.java index e458a792c..1743dd4ca 100644 --- a/host/src/test/java/com/volmit/support/ColumnSettings.java +++ b/host/src/test/java/com/volmit/support/ColumnSettings.java @@ -3,7 +3,9 @@ package com.volmit.support; import com.volmit.IrisFeature; import com.volmit.config.FeatureSettings; import com.volmit.config.SettingsStack; +import com.volmit.resource.ResourceId; import java.util.List; +import java.util.Optional; import java.util.function.BiFunction; /** Settings declared per world column by a function, for chunk and mantle tests. */ @@ -30,4 +32,9 @@ public final class ColumnSettings implements FeatureSettings { .map(entry -> (Entry) entry) .toList()); } + + @Override + public Optional declaredBy(ResourceId biome, Class featureType) { + return Optional.empty(); + } } diff --git a/host/src/test/java/com/volmit/support/MemoryEdit.java b/host/src/test/java/com/volmit/support/MemoryEdit.java index 65ae009ec..87e2f4df5 100644 --- a/host/src/test/java/com/volmit/support/MemoryEdit.java +++ b/host/src/test/java/com/volmit/support/MemoryEdit.java @@ -1,12 +1,12 @@ package com.volmit.support; import com.volmit.block.BlockState; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; +import com.volmit.geometry.BlockPosition; import com.volmit.mantle.Mantle; import com.volmit.placement.PlacedBlock; import com.volmit.placement.PlacedMarker; import com.volmit.placement.PlacementEdit; -import com.volmit.world.BlockPosition; import com.volmit.world.BlockView; import java.util.ArrayList; import java.util.HashMap; diff --git a/host/src/test/java/com/volmit/support/MemoryMantle.java b/host/src/test/java/com/volmit/support/MemoryMantle.java index 5676b5a0a..1c382a61e 100644 --- a/host/src/test/java/com/volmit/support/MemoryMantle.java +++ b/host/src/test/java/com/volmit/support/MemoryMantle.java @@ -1,13 +1,13 @@ package com.volmit.support; import com.volmit.block.BlockState; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; +import com.volmit.geometry.BlockPosition; import com.volmit.mantle.Mantle; import com.volmit.mantle.MantleEdit; import com.volmit.mantle.MantleKey; import com.volmit.mantle.MantleLayer; import com.volmit.mantle.MantleVisitor; -import com.volmit.world.BlockPosition; import java.util.Comparator; import java.util.HashMap; import java.util.Map; diff --git a/host/src/test/java/com/volmit/support/TestContexts.java b/host/src/test/java/com/volmit/support/TestContexts.java index 74b57704e..ff90a5118 100644 --- a/host/src/test/java/com/volmit/support/TestContexts.java +++ b/host/src/test/java/com/volmit/support/TestContexts.java @@ -1,5 +1,6 @@ package com.volmit.support; +import com.volmit.block.BlockState; import com.volmit.config.FeatureSettings; import com.volmit.generation.GenerationContext; import com.volmit.generation.MantleGenerationContext; @@ -10,7 +11,6 @@ import com.volmit.placement.PlacementContext; import com.volmit.world.TerrainSampler; import com.volmit.world.BlockView; import com.volmit.world.PackWorld; -import java.util.Map; /** Tests needing no platform facilities fail loudly if code starts using one. */ public final class TestContexts { @@ -18,17 +18,20 @@ public final class TestContexts { private TestContexts() {} - public static GenerationContext generation(Map, Hunk> hunks) { - return generation(hunks, null, null); + /** The chunk at the origin; a null {@code blocks} fails when used. */ + public static GenerationContext generation(Hunk blocks) { + return generation(blocks, null, null); } - /** The chunk at the origin; a null {@code settings} or {@code mantle} fails when used. */ - public static GenerationContext generation(Map, Hunk> hunks, FeatureSettings settings, Mantle mantle) { - return generation(hunks, settings, mantle, null); + /** The chunk at the origin; a null {@code blocks}, {@code settings} or {@code mantle} fails when used. */ + public static GenerationContext generation(Hunk blocks, FeatureSettings settings, Mantle mantle) { + return generation(blocks, settings, mantle, null); } - /** The chunk at the origin in {@code world}; a null {@code settings}, {@code mantle} or {@code world} fails when used. */ - public static GenerationContext generation(Map, Hunk> hunks, FeatureSettings settings, Mantle mantle, PackWorld world) { + /** The chunk at the origin in {@code world}; a null {@code blocks}, {@code settings}, {@code mantle} or {@code world} + * fails when used. + */ + public static GenerationContext generation(Hunk blocks, FeatureSettings settings, Mantle mantle, PackWorld world) { return new GenerationContext() { public int originX() { return 0; } public int originZ() { return 0; } @@ -36,12 +39,7 @@ public final class TestContexts { public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); } public FeatureSettings settings() { return used(settings, "settings"); } public Mantle mantle() { return used(mantle, "mantle"); } - @SuppressWarnings("unchecked") - public Hunk hunk(Class type) { - var hunk = hunks.get(type); - if (hunk == null) throw new IllegalArgumentException("No hunk of " + type.getName()); - return (Hunk) hunk; - } + public Hunk blocks() { return used(blocks, "blocks"); } }; } diff --git a/host/src/test/java/com/volmit/support/TestTerrain.java b/host/src/test/java/com/volmit/support/TestTerrain.java index a106df332..ecfd56157 100644 --- a/host/src/test/java/com/volmit/support/TestTerrain.java +++ b/host/src/test/java/com/volmit/support/TestTerrain.java @@ -1,7 +1,7 @@ package com.volmit.support; import com.volmit.block.BlockState; -import com.volmit.mantle.BlockBox; +import com.volmit.geometry.BlockBox; import com.volmit.world.BlockView; import java.util.function.IntBinaryOperator; diff --git a/host/src/test/java/com/volmit/support/TestWorld.java b/host/src/test/java/com/volmit/support/TestWorld.java index 7ff5a4659..af6f63cf5 100644 --- a/host/src/test/java/com/volmit/support/TestWorld.java +++ b/host/src/test/java/com/volmit/support/TestWorld.java @@ -43,6 +43,11 @@ public final class TestWorld implements PackWorld, AutoCloseable { }; } + @Override + public int minWorldY() { + return 0; + } + @Override public T state(Class type, Function create) { return states.state(type, () -> create.apply(this));