From f1eb619344157e3a86635be82f4f796bc4b5f877 Mon Sep 17 00:00:00 2001 From: piexel Date: Wed, 28 Oct 2026 01:25:41 +0100 Subject: [PATCH] Batch 7 stage 3: objects and placement through the api The api describes a pack's objects and lets a module place one through the pack's placement graph: PlaceableObject, PackObjects (PackResources.objects()), ScaleMethod, and Placements.place(PlacementRun) on PackWorld with PlacementTerrain, StructureVolumes and PlacementOutcome, which moves here from the host. Stages read PlacementContext.placementTerrain() and input(type); mantle stages get MantleGenerationContext.placementTerrain(). BlockRegistry gains rotate (BlockTurn), merge, withProperty and matches; BlockTrait gains STORAGE; ModuleLog gains debugging(); PackSettings gains resources(); RunningWorld gains placementAt. README, DESIGN and CONTRACTS describe them, and the extension ledger drops ObjectHost and ObjectPlacement. --- CONTRACTS.md | 8 ++- DESIGN.md | 40 ++++++----- README.md | 36 +++++++++- api/src/main/java/com/volmit/ModuleLog.java | 6 +- .../java/com/volmit/block/BlockRegistry.java | 28 ++++++++ .../java/com/volmit/block/BlockTrait.java | 5 +- .../main/java/com/volmit/block/BlockTurn.java | 15 +++++ .../java/com/volmit/config/PackSettings.java | 4 ++ .../generation/MantleGenerationContext.java | 7 ++ .../java/com/volmit/object/PackObjects.java | 35 ++++++++++ .../com/volmit/object/PlaceableObject.java | 28 ++++++++ .../java/com/volmit/object/ScaleMethod.java | 13 ++++ .../volmit/placement/PlacementContext.java | 12 ++++ .../volmit/placement}/PlacementOutcome.java | 9 +-- .../com/volmit/placement/PlacementRun.java | 26 ++++++++ .../volmit/placement/PlacementTerrain.java | 66 +++++++++++++++++++ .../java/com/volmit/placement/Placements.java | 15 +++++ .../volmit/placement/StructureVolumes.java | 15 +++++ .../com/volmit/resource/PackResources.java | 4 ++ .../main/java/com/volmit/world/PackWorld.java | 4 ++ .../java/com/volmit/world/RunningWorld.java | 6 ++ .../volmit/generation/ChunkContextTest.java | 2 + .../com/volmit/host/LabelledModuleLog.java | 7 +- .../com/volmit/host/MantleInvocation.java | 6 ++ .../main/java/com/volmit/host/ModuleLogs.java | 5 ++ .../java/com/volmit/host/ModuleWorld.java | 6 ++ .../com/volmit/host/PlacementInvocation.java | 11 ++++ .../java/com/volmit/host/PlacementRunner.java | 1 + .../java/com/volmit/host/ExtensionsTest.java | 2 + .../java/com/volmit/host/StageGraphTest.java | 1 + .../com/volmit/support/DeclaredSettings.java | 6 ++ .../com/volmit/support/EmptyResources.java | 6 ++ .../java/com/volmit/support/TestContexts.java | 5 ++ .../java/com/volmit/support/TestWorld.java | 10 +++ 34 files changed, 423 insertions(+), 27 deletions(-) create mode 100644 api/src/main/java/com/volmit/block/BlockTurn.java create mode 100644 api/src/main/java/com/volmit/object/PackObjects.java create mode 100644 api/src/main/java/com/volmit/object/PlaceableObject.java create mode 100644 api/src/main/java/com/volmit/object/ScaleMethod.java rename {host/src/main/java/com/volmit/host => api/src/main/java/com/volmit/placement}/PlacementOutcome.java (69%) create mode 100644 api/src/main/java/com/volmit/placement/PlacementRun.java create mode 100644 api/src/main/java/com/volmit/placement/PlacementTerrain.java create mode 100644 api/src/main/java/com/volmit/placement/Placements.java create mode 100644 api/src/main/java/com/volmit/placement/StructureVolumes.java diff --git a/CONTRACTS.md b/CONTRACTS.md index c917f026b..c17956219 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -21,14 +21,16 @@ types that carry them and lists what the Iris adapter still owes. | Typed results between modules | stage outputs, `StageContext.output` | | Per-block work with single-pass cost | `BlockStage`, fused block passes | | Pack-load validation and diagnostics | host `StageGraphBuilder`, `ResolvedGraph`, `LoadedModules` | -| Reference execution | host `PlacementRunner`, `ChunkRunner`, `MantleRunner`, each timed through host `StageTimings` | +| Reference execution | host `PlacementRunner` (returns the API `PlacementOutcome`), `ChunkRunner`, `MantleRunner`, each timed through host `StageTimings` | | Work across chunks and mantle writes | `Stage.mantle`, `MantleStage`, `MantleStageContext`, `MantleGenerationContext`; chunk stages write registered layers in their own chunk only and read the neighbors | | Annotated settings | `IrisFeature`, `@Feature` (id, short JSON `key`, optional `root`), config annotations, host `OptionsMetadata`, `LinkedBiomes` (`treeBiomes`, `usedBiomes`: pack biomes the settings bring into the layout) | | Host facades for the host's own modules | `PackWorld.extension(type)`, `InvocationContext.extension(type)`, `PackSettings.extension(type)` (each an `Optional`, empty by default) | -| Area a stage writes | `reach(blocks)`, `reach(PackReach)`, `writesMantle(...)` on stage definitions, `PackSettings`, host `StageReach`, `ResolvedStage.reachBlocks`, `PipelineReach` | +| 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`), `BlockTrait`, `BlockPalette`, `BlockSpec`, `PaletteSpec` and `PaletteSampler` (`BlockRegistry.palette`) | +| Block states and palettes | `BlockState`, `BlockRegistry` (`resolve(BlockSpec)`, `find(key)`, `blockEntity`, `hasTrait`, `oreFor`, `rotate(state, BlockTurn)`, `merge`, `withProperty`, `matches`), `BlockTurn`, `BlockTrait` (with `STORAGE`), `BlockPalette`, `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, area, terrain, input, seed), `PlacementTerrain`, `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 | | 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`), `VanillaStructureRule`, `VanillaStructureContext`, `VanillaStructureStart`, `VanillaStructureStartContext`, `VanillaStructureSetup`, `PlatformStart`, `StartMemo`, `StartReach`, `StructureFit` (`Start`, `Piece`, `ColumnVisitor`), `DecorationStep`, `TerrainAdaptation`, `PieceKind`, `TemplateCells`, `world.BlockAccess`, host `FeatureCatalog.registrations(service)` | diff --git a/DESIGN.md b/DESIGN.md index 8df04b037..1b3b1cdc6 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -438,6 +438,14 @@ are ordered only by the tie-break, so they are where two modules can silently co ## Placement attempts +A module places an object through the pack's placement graph with `PackWorld.placements().place(PlacementRun)`; the +host runs `PlacementRunner` over an edit that buffers into the run's `PlacementTerrain`, and returns the API +`PlacementOutcome`. One service, one request and one outcome: the run carries the object, the area, the terrain, the +placing module's own input and the seed, and nothing names a host. The terrain is an interface so a module can hold +writes (an island that only accepts blocks over itself, a cave that keeps an object inside it) and commit or drop them +as one; the host's terrain for a mantle invocation is `MantleGenerationContext.placementTerrain()`. Objects come from +`PackResources.objects()` (`PackObjects`), which loads, scales and builds them per pack snapshot. + `PlacementRunner.place(request, edit, inputs, invocationSeed, settings, timings)` owns the edit. It runs active stages in order, stops after the current stage or block once a stage calls `reject(reason)`, commits only when nothing rejected or threw, and closes the edit in every case. A producer that rejects may @@ -1229,11 +1237,11 @@ A module jar sees three things besides the JDK and its own pack's jars, and noth question, and none hands out an engine. **The extension point.** A built-in reaches its facade through one door: `PackWorld.extension(type)` for what belongs to -a world (the object system, spawner cooldowns Iris persists), `InvocationContext.extension(type)` for what belongs to one invocation (the -platform chunk Iris generates, the placement being attempted), and `PackSettings.extension(type)` for what is worked out +a world (Iris's legacy random streams, spawner cooldowns Iris persists), `InvocationContext.extension(type)` for what belongs to one invocation (the +platform chunk Iris generates), and `PackSettings.extension(type)` for what is worked out from a pack's settings before any world exists (how far a feature reaches). Each returns an `Optional`, empty by default, so a host offers what it has and a module states what it requires: -`world.extension(ObjectHost.class).orElseThrow()`. Why one door: +`world.extension(LegacyStreams.class).orElseThrow()`. Why one door: - **No thread-locals.** Facades used to be bound to the current thread (`IrisChunk.current()`, `ObjectPlacement.current()`), which only worked while the host's own code had bound them and broke silently on another thread. The context a stage @@ -1252,7 +1260,7 @@ Iris's own built-ins hold to this at compile time: IrisModule is a build of its `com.volmit:iris-api`, VolmLib, Gson and the JDK, never `iris-host` or Iris, and its jar passes `ModuleJarCheck` before Iris bundles it. Iris depends on IrisModule, not the reverse. What the built-ins cannot do through the API they ask through the facades of item 3, which Iris implements; the classes that need Iris itself (the layout model, the -structure placer behind `StructureHost`, the object placers behind `ObjectHost`) are Iris's and live there. +structure placer behind `StructureHost`) are Iris's and live there. ### Iris extensions, with the reason each is not api yet @@ -1264,18 +1272,20 @@ API now: `world.running()`, `world.seed(purpose)`, `TerrainSampler`, `FeatureSet - **`MatterMantle`** (invocation). Carve plans its caves as VolmLib matter slices (`MatterCavern`, markers) that Iris and the platform read back as slices. The API mantle has typed layers but no cavern layer; it goes when carve writes a layer the API defines and Iris reads that instead. -- **`ObjectHost`** (world). Iris's object system: loading and scaling a pack's objects, picking one by density, placing it - through Iris's placers, and the loot of what was placed. Objects are named by the string keys placements hold, and the API - has no object model. It goes when the API describes a placeable object and its placement. -- **`ObjectPlacement`** with `ObjectShape`, `PlacementSettings` and `PlacementTerrain` (invocation). The object being placed, - read from the module's own `objects.ObjectPlacement` settings, and the terrain questions of Iris's placers (carved, structure volumes, the object - already at a block). Its surface noise (`PlaneNoise`, `SurfaceWarp`) is Iris's own simplex and warp with a cache, which no - API noise reproduces value for value, so existing worlds would move. It goes with `ObjectHost`. +- **`LegacyStreams`** (world). Iris's object chunk random, and the noise of a placement's density style and virtual + heightmap, which decide where existing worlds have their objects and which no API noise reproduces value for value. It + goes when a world format change lets object placing draw from stage streams and API noise. +- **`objects.ObjectRun`** (the input of a placement run, `PlacementRun.input`). The object and the module's own + `objects.ObjectPlacement` settings that Iris's built-in placement stages read, and what they report back (the anchor + height, which written blocks are the object's). Iris reads it in two places: for the placement-level module settings of + the run, and when Iris places an object itself (its studio and commands, the jigsaw placer). It goes when those settings + are part of the run the API describes and Iris no longer places objects itself. - **`FloatingHost`** (world). Island height comes from Iris's biome generators and island tops are painted by Iris's biome - palettes, which the API layout does not describe; its object placing goes through `ObjectHost`. -- **`StructureHost`** (world). Iris's structure assembler, locator and placer. The structure model (structures, pools, - pieces) is `iris:structure`'s own resource kinds, which Iris registers with its own modules because its jigsaw studio - reads them. Its surface is already API vocabulary; it goes when the placer can write through the API. + palettes, which the API layout does not describe. Its objects are placed through `PackWorld.placements()`. +- **`StructureHost`** (world). Iris's structure assembler, locator and placer, and the loot tables of a structure for the + loot of its pieces. The structure model (structures, pools, pieces) is `iris:structure`'s own resource kinds, which Iris + registers with its own modules because its jigsaw studio reads them. Its surface is already API vocabulary; it goes when + the placer can write through the API. - **`spawn.SpawnCooldowns`** (world). Spawner cooldowns Iris saves with a world's engine data, so they survive a restart; API per-world state is in memory only. It goes when the API can persist per-world state. - **Random parameters (`RNG`) in these facades and `loot.LootResolver`**. They are the legacy streams existing worlds were diff --git a/README.md b/README.md index 4d1893b8a..9f7b63b69 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,39 @@ PackBiome dunes = resources.require(PackResources.BIOMES, resources.idOf("desert Resource kind example:castle/keep of module example:castle from modules/castle.jar reads folder 'biomes', which the host reads itself; give the kind a folder of its own ``` +## Placing objects + +A module that places objects itself, such as the objects of a biome or a growing tree, takes them from the pack's +objects and places them through the pack's placement stages, so every module's placement stages (anchoring, stilts, +snow) run for them as they do for any placement: + +```java +PackObjects objects = world.resources().objects(); +PlaceableObject tower = objects.object(world.resources().idOf("towers/north")).orElseThrow(); +PlaceableObject large = objects.scaled(tower, 2, ScaleMethod.TRILINEAR); // kept per pack snapshot + +PlacementTerrain terrain = context.placementTerrain(); // in a mantle stage +PlacementRun run = new PlacementRun(new PlacementRequest(large.geometry(), anchor), area, terrain, mySettings, seed); +PlacementOutcome outcome = world.placements().place(run); +if (!outcome.isPlaced()) { + context.log().debug("tower rejected: " + outcome.rejection().orElseThrow()); +} +``` + +- `PackObjects` gives an object of the pack by id, its size without loading it (`sizeOf`, for a reach), a scaled or + smart-bored copy, and objects a module builds block by block (`build`). The host keeps them per pack snapshot. +- `PlacementTerrain` is the world the placement reads and the host writes into once it commits: heights, blocks, + carved space, fluid, the structures nearby and the placement recorded at a block (`recordPlacement`, `placementAt`; + `RunningWorld.placementAt` reads it back later, such as for the loot of a placed object). A module may wrap it to hold + or filter writes; a mantle stage gets one for its invocation from `MantleGenerationContext.placementTerrain()`. +- `input` is what the module hands its own placement stages (`PlacementContext.input(type)`); other modules' stages do + not know its type. The area bounds what the placement may write, widened by the reach of the pack's placement stages. +- 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 + container that holds items, such as for loot. + ## Validators A module checks the pack for problems it cares about with a `Validator`. The host runs every validator of the @@ -348,7 +381,8 @@ private static void decorate(ChunkStageContext context) { | Method | Use | | --- | --- | -| `debug(message)` | Detail for people debugging the module. Written only when the host's debug setting is on. Building the message still costs, so keep it cheap or guard it. | +| `debug(message)` | Detail for people debugging the module. Written only when the host's debug setting is on. Building the message still costs, so keep it cheap or guard it with `debugging()`. | +| `debugging()` | Whether `debug` writes anything now: the guard for a message that is costly to build. | | `info(message)` | What a server owner may want to see once, such as what the module did at startup. | | `warn(message)` | Something is wrong or unusual and the module carries on. | | `warnOnce(key, message)` | `warn` the first time the key is used on this module's log, `debug` every time after. For a condition met per block or per chunk. Keys belong to the module, so another module's identical key does not hide yours; keep the key space small (a biome name, never a coordinate). | diff --git a/api/src/main/java/com/volmit/ModuleLog.java b/api/src/main/java/com/volmit/ModuleLog.java index 79b9e4e80..fc09bae9d 100644 --- a/api/src/main/java/com/volmit/ModuleLog.java +++ b/api/src/main/java/com/volmit/ModuleLog.java @@ -10,10 +10,14 @@ package com.volmit; */ public interface ModuleLog { /** Detail for people debugging the module. The host writes it only when its debug setting is on, so building the - * message costs time even when nobody reads it: guard a message that is expensive to build, or leave it out. + * message costs time even when nobody reads it: guard a message that is expensive to build with {@link #debugging()}, + * or leave it out. */ void debug(String message); + /** Whether {@link #debug} lines are written now, so a module can skip building them, or skip work done only to trace. */ + boolean debugging(); + /** Something worth telling the server owner once in a while, such as what the module did at startup. */ void info(String message); diff --git a/api/src/main/java/com/volmit/block/BlockRegistry.java b/api/src/main/java/com/volmit/block/BlockRegistry.java index d07dd9885..52d0228bf 100644 --- a/api/src/main/java/com/volmit/block/BlockRegistry.java +++ b/api/src/main/java/com/volmit/block/BlockRegistry.java @@ -11,6 +11,11 @@ import java.util.Optional; *

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. + * + *

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 + * block. */ public interface BlockRegistry { /** The state {@code spec} names, resolved the way packs expect, so it never throws for a block the platform lacks: @@ -55,4 +60,27 @@ public interface BlockRegistry { * decoration, such as a flower on grass but not on stone. Only the kinds of block count, not their properties. */ boolean canPlaceOn(BlockState state, BlockState below); + + /** + * {@code state} turned with an object: every direction the block faces (its facing, axis, connections, or the + * sixteen directions of a sign) is moved by {@code turn}, as the platform turns stairs, logs, walls and wires. A + * block without directions comes back unchanged; air when the block cannot face the way it is turned. + */ + BlockState rotate(BlockState state, BlockTurn turn); + + /** {@code update} laid over {@code base}: the platform's merge of two states of one block, such as the sides of a + * fence, wall or pane; {@code update} when the platform does not merge them. + */ + BlockState merge(BlockState base, BlockState update); + + /** {@code state} with the property {@code name} set to {@code value}, as the platform sets it. Unlike + * {@link BlockState#withProperty} it keeps a content plugin's block itself ({@link BlockTrait#CUSTOM}): such a block + * shares its key with the block it is drawn as, so only the state instance the registry handed out knows it. + */ + BlockState withProperty(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. + */ + boolean matches(BlockState state, BlockState pattern); } diff --git a/api/src/main/java/com/volmit/block/BlockTrait.java b/api/src/main/java/com/volmit/block/BlockTrait.java index a6c41ea62..8ff17cb03 100644 --- a/api/src/main/java/com/volmit/block/BlockTrait.java +++ b/api/src/main/java/com/volmit/block/BlockTrait.java @@ -2,8 +2,9 @@ package com.volmit.block; /** 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. + * vines and glow lichen; {@code STORAGE} a chest-like container that keeps items, such as a chest or a barrel; + * {@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, CUSTOM + AIR, SOLID, OCCLUDING, FLUID, WATER, GRAVITY, FOLIAGE, DECORATION, VINE, LOG, LEAVES, ORE, STORAGE, CUSTOM } diff --git a/api/src/main/java/com/volmit/block/BlockTurn.java b/api/src/main/java/com/volmit/block/BlockTurn.java new file mode 100644 index 000000000..f53e508ea --- /dev/null +++ b/api/src/main/java/com/volmit/block/BlockTurn.java @@ -0,0 +1,15 @@ +package com.volmit.block; + +/** + * How an object's rotation moves a direction its blocks face ({@link BlockRegistry#rotate}). A direction is a vector + * such as (0, 0, -1) for north, or (1, 0, -2) for one of a sign's sixteen; the turned vector need not be whole, and the + * platform takes the direction closest to it. + */ +@FunctionalInterface +public interface BlockTurn { + Direction turn(double x, double y, double z); + + /** A direction vector. */ + record Direction(double x, double y, double z) { + } +} diff --git a/api/src/main/java/com/volmit/config/PackSettings.java b/api/src/main/java/com/volmit/config/PackSettings.java index 313add7dc..d80390577 100644 --- a/api/src/main/java/com/volmit/config/PackSettings.java +++ b/api/src/main/java/com/volmit/config/PackSettings.java @@ -1,6 +1,7 @@ package com.volmit.config; import com.volmit.IrisFeature; +import com.volmit.resource.PackResources; import java.util.Optional; /** Every settings declaration of the pack the host is loading, for what depends on the whole pack rather @@ -16,6 +17,9 @@ public interface PackSettings { */ SettingsStack declared(Class featureType); + /** The pack snapshot the settings were read from, such as for a reach that depends on the size of the pack's objects. */ + PackResources resources(); + /** * What the host offers for the pack it is loading beyond the API, as an object of {@code type}: empty when it offers * no such thing. The same door as {@link com.volmit.world.PackWorld#extension}, for what is worked out from the diff --git a/api/src/main/java/com/volmit/generation/MantleGenerationContext.java b/api/src/main/java/com/volmit/generation/MantleGenerationContext.java index 254671e34..46ff11803 100644 --- a/api/src/main/java/com/volmit/generation/MantleGenerationContext.java +++ b/api/src/main/java/com/volmit/generation/MantleGenerationContext.java @@ -1,6 +1,7 @@ package com.volmit.generation; import com.volmit.mantle.Mantle; +import com.volmit.placement.PlacementTerrain; import com.volmit.world.TerrainSampler; /** Per-invocation inputs of the mantle pipeline for one chunk. Must not be retained after execution. */ @@ -14,4 +15,10 @@ public interface MantleGenerationContext extends ChunkContext { /** The mantle of the chunk widened by the pipeline's reach, full height (heights 0 up to the dimension height). Writes outside it throw. */ Mantle mantle(); + + /** + * The mantle of the chunk and its reach as a world to place objects in ({@link com.volmit.placement.Placements}): + * its blocks are the mantle's planned blocks, and placements write theirs into the mantle. + */ + PlacementTerrain placementTerrain(); } diff --git a/api/src/main/java/com/volmit/object/PackObjects.java b/api/src/main/java/com/volmit/object/PackObjects.java new file mode 100644 index 000000000..4d39cae7b --- /dev/null +++ b/api/src/main/java/com/volmit/object/PackObjects.java @@ -0,0 +1,35 @@ +package com.volmit.object; + +import com.volmit.geometry.BlockBox; +import com.volmit.resource.ResourceId; + +import java.util.List; +import java.util.Optional; + +/** + * The pack's objects, ready to place, and the objects made from them: scaled variants and objects a module builds block + * by block. The host loads, scales and keeps them for the pack snapshot, so asking again is cheap. Reached through + * {@link com.volmit.resource.PackResources#objects()}; safe for concurrent calls. + */ +public interface PackObjects { + /** The pack object {@code id} names, as {@link com.volmit.resource.PackResources#idOf} gives it for the key; empty when the pack has none. */ + Optional object(ResourceId id); + + /** The pack object's size, read without loading its blocks: from the origin to its width, height and depth; empty when the pack has none. */ + Optional sizeOf(ResourceId id); + + /** + * {@code object} resized by {@code factor}, filling between its blocks with {@code method}. Built once per object, + * factor and method, and kept within a memory budget. + */ + PlaceableObject scaled(PlaceableObject object, double factor, ScaleMethod method); + + /** + * {@code object} with air in the rooms and pockets a placement should clear, found by casting rays through it. Done + * once per object; the object itself keeps the air, so later placements of it see it too. + */ + PlaceableObject smartBored(PlaceableObject object); + + /** An object of {@code blocks}, at their offsets from its center, declared {@code width} by {@code height} by {@code depth} with its center in the middle; placeable like the pack's. */ + PlaceableObject build(String name, int width, int height, int depth, List blocks); +} diff --git a/api/src/main/java/com/volmit/object/PlaceableObject.java b/api/src/main/java/com/volmit/object/PlaceableObject.java new file mode 100644 index 000000000..1fca2658f --- /dev/null +++ b/api/src/main/java/com/volmit/object/PlaceableObject.java @@ -0,0 +1,28 @@ +package com.volmit.object; + +import com.volmit.geometry.BlockPosition; + +/** + * An object ready to be placed: one of the pack's, a scaled variant of one, or one a module built + * ({@link PackObjects}). Its size is the size it was declared with, which boring and terrain bends cover even where it + * has no block. Immutable; safe to share between threads. + */ +public interface PlaceableObject { + /** + * The object's name: the key the pack's files name it by, such as {@code trees/oak}, also for its scaled variants, or + * the name the module that built it gave it. + */ + String name(); + + int width(); + + int height(); + + int depth(); + + /** The block the object's offsets count from, relative to its corner. */ + BlockPosition center(); + + /** The object's blocks at their offsets from {@link #center()}, so the geometry's anchor is the origin. */ + GeneratedObject geometry(); +} diff --git a/api/src/main/java/com/volmit/object/ScaleMethod.java b/api/src/main/java/com/volmit/object/ScaleMethod.java new file mode 100644 index 000000000..0c104ee8f --- /dev/null +++ b/api/src/main/java/com/volmit/object/ScaleMethod.java @@ -0,0 +1,13 @@ +package com.volmit.object; + +/** How a scaled object fills the blocks between its source blocks when it grows ({@link PackObjects#scaled}). */ +public enum ScaleMethod { + /** Each source block becomes a box of blocks. */ + NONE, + /** Linear interpolation in three dimensions. */ + TRILINEAR, + /** Cubic spline interpolation in three dimensions; smoother, much slower. */ + TRICUBIC, + /** Hermite spline interpolation in three dimensions; smoother, much slower. */ + TRIHERMITE +} diff --git a/api/src/main/java/com/volmit/placement/PlacementContext.java b/api/src/main/java/com/volmit/placement/PlacementContext.java index bc9d53722..42801b89e 100644 --- a/api/src/main/java/com/volmit/placement/PlacementContext.java +++ b/api/src/main/java/com/volmit/placement/PlacementContext.java @@ -6,6 +6,8 @@ import com.volmit.object.ObjectTransformer; import com.volmit.world.TerrainSampler; import com.volmit.world.BlockView; +import java.util.Optional; + /** Host-supplied, read-only inputs of one placement attempt. Working state is carried by stage * outputs, never stored on a module or stage body. Context lifetime ends with the placement. */ @@ -15,4 +17,14 @@ public interface PlacementContext extends InvocationContext { ObjectTransformer objects(); /** Prepared blocks before this placement. Use stage access for reads of buffered changes. */ BlockView blocks(); + /** + * The world the placement is made in, for the questions about a column the stages ask. Its blocks are the ones before + * this placement, like {@link #blocks()}; stages write through their access, never into it. + */ + PlacementTerrain placementTerrain(); + /** + * What the module that asked for this placement handed its stages ({@link PlacementRun#input}), when it is a + * {@code type}; empty otherwise, such as for a placement the host itself started. + */ + Optional input(Class type); } diff --git a/host/src/main/java/com/volmit/host/PlacementOutcome.java b/api/src/main/java/com/volmit/placement/PlacementOutcome.java similarity index 69% rename from host/src/main/java/com/volmit/host/PlacementOutcome.java rename to api/src/main/java/com/volmit/placement/PlacementOutcome.java index d2f02e996..4867f33d6 100644 --- a/host/src/main/java/com/volmit/host/PlacementOutcome.java +++ b/api/src/main/java/com/volmit/placement/PlacementOutcome.java @@ -1,9 +1,9 @@ -package com.volmit.host; +package com.volmit.placement; import java.util.Objects; import java.util.Optional; -/** Result of one placement attempt. A rejected attempt committed nothing. */ +/** Result of one placement attempt ({@link Placements#place}). A rejected attempt committed nothing. */ public record PlacementOutcome(Status status, Optional rejection) { public enum Status { PLACED, REJECTED } @@ -15,11 +15,12 @@ public record PlacementOutcome(Status status, Optional rejection) { } } - static PlacementOutcome placed() { + public static PlacementOutcome placed() { return new PlacementOutcome(Status.PLACED, Optional.empty()); } - static PlacementOutcome rejected(String reason) { + /** Rejected with the reason the stage gave, such as {@code slope}. */ + public static PlacementOutcome rejected(String reason) { return new PlacementOutcome(Status.REJECTED, Optional.of(reason)); } diff --git a/api/src/main/java/com/volmit/placement/PlacementRun.java b/api/src/main/java/com/volmit/placement/PlacementRun.java new file mode 100644 index 000000000..db3722168 --- /dev/null +++ b/api/src/main/java/com/volmit/placement/PlacementRun.java @@ -0,0 +1,26 @@ +package com.volmit.placement; + +import com.volmit.geometry.BlockBox; + +import java.util.Objects; + +/** + * One object a module asks the host to place through the pack's placement stages ({@link Placements#place}). + * + * @param request the object and where it goes + * @param area the blocks the object may reach around its anchor in any way it is placed; the host widens it by the + * reach the pack's placement stages declare, and the result bounds the placement's {@link PlacementAccess}. + * Reaching outside fails the placement + * @param terrain the world the placement reads, and where the host writes the blocks when the placement commits + * @param input what the placing module hands its own stages, such as its placement settings; stages read it with + * {@link PlacementContext#input}, and stages of other modules do not know its type + * @param seed the seed the stages' random streams derive from; the same seed, stages and inputs give the same placement + */ +public record PlacementRun(PlacementRequest request, BlockBox area, PlacementTerrain terrain, Object input, long seed) { + public PlacementRun { + Objects.requireNonNull(request, "request"); + Objects.requireNonNull(area, "area"); + Objects.requireNonNull(terrain, "terrain"); + Objects.requireNonNull(input, "input"); + } +} diff --git a/api/src/main/java/com/volmit/placement/PlacementTerrain.java b/api/src/main/java/com/volmit/placement/PlacementTerrain.java new file mode 100644 index 000000000..c0722d783 --- /dev/null +++ b/api/src/main/java/com/volmit/placement/PlacementTerrain.java @@ -0,0 +1,66 @@ +package com.volmit.placement; + +import com.volmit.block.BlockState; +import com.volmit.object.BlockEntityData; + +import java.util.Optional; + +/** + * The world a placement is made in, as its stages and the module that asked for it see it: blocks, the questions about a + * column the stages ask, and what the host keeps beside each block. X and Z are world coordinates; Y is the height above + * the dimension's bottom. + * + *

A module that places objects hands one to {@link Placements#place}: the terrain of its mantle invocation + * ({@link com.volmit.generation.MantleGenerationContext#placementTerrain()}), or its own, such as one that collects a + * growing tree's blocks. It may wrap another to change what it answers or to hold writes back. Stages read it through + * {@link PlacementContext#placementTerrain()} and write through {@link PlacementAccess}; the host writes a placement's + * blocks into it when the placement commits. Not thread-safe; it lives as long as the invocation it came from. + */ +public interface PlacementTerrain { + /** The height of the highest block of the column; {@code ignoreFluid} leaves out the fluid above the ground. */ + int highest(int x, int z, boolean ignoreFluid); + + BlockState get(int x, int y, int z); + + /** Writes the block without a block entity. */ + void set(int x, int y, int z, BlockState state); + + /** Writes the block with its block entity, such as a chest's contents. */ + void set(int x, int y, int z, BlockState state, BlockEntityData blockEntity); + + /** Whether the cave carver emptied the block. */ + boolean isCarved(int x, int y, int z); + + /** Whether the block is real, solid ground, which the terrain's heights alone cannot tell before the chunk is built. */ + boolean isSurfaceSolid(int x, int y, int z); + + boolean isUnderwater(int x, int z); + + /** The height up to which the dimension is filled with fluid. */ + int fluidHeight(); + + /** Whether leaves written here never decay. */ + boolean preventsDecay(); + + /** + * Records that the block belongs to {@code placement}, the name the placing module gives one placed object, so a + * later placement can tell what is already there ({@link #placementAt}). The host keeps the name as it is. + */ + void recordPlacement(int x, int y, int z, String placement); + + /** The placement recorded at the block ({@link #recordPlacement}); empty when none is. */ + Optional placementAt(int x, int y, int z); + + /** The bounds of the platform's structure pieces planned around the columns, for placements that keep out of them. */ + StructureVolumes structureVolumes(int minX, int minZ, int maxX, int maxZ); + + /** + * Keeps {@code marker} beside its block in the world's generation storage: a stage's marker when the placement + * commits ({@link PlacementAccess#marker}), or one the placing module adds to a placed block. Its type is something the + * module that writes it and the module or host that reads it agree on, such as a spawn marker. The host keeps the + * types it knows in its own form. + * + * @throws IllegalArgumentException when the host keeps no marker of this type + */ + void mark(PlacedMarker marker); +} diff --git a/api/src/main/java/com/volmit/placement/Placements.java b/api/src/main/java/com/volmit/placement/Placements.java new file mode 100644 index 000000000..0656d70c9 --- /dev/null +++ b/api/src/main/java/com/volmit/placement/Placements.java @@ -0,0 +1,15 @@ +package com.volmit.placement; + +/** + * Runs the pack's placement stages for an object a module places itself, such as the objects of a biome or a growing + * tree. The host offers it for every world ({@link com.volmit.world.PackWorld#placements()}); the stages are every + * module's placement stages of the pack, in the order the stage graph gives them. + */ +public interface Placements { + /** + * Places {@code run}'s object: the stages run with buffered writes, and the host writes the blocks, then the markers, + * into the run's terrain only when no stage rejects the placement and none throws. A stage that throws fails the call and nothing + * is written. Call it from the invocation the terrain belongs to. + */ + PlacementOutcome place(PlacementRun run); +} diff --git a/api/src/main/java/com/volmit/placement/StructureVolumes.java b/api/src/main/java/com/volmit/placement/StructureVolumes.java new file mode 100644 index 000000000..6d4a44473 --- /dev/null +++ b/api/src/main/java/com/volmit/placement/StructureVolumes.java @@ -0,0 +1,15 @@ +package com.volmit.placement; + +/** + * The bounds of the platform's structure pieces planned around a placement ({@link PlacementTerrain#structureVolumes}). + * X and Z are world coordinates; Y is the height above the dimension's bottom. + */ +public interface StructureVolumes { + boolean isEmpty(); + + /** Whether any piece meets the box, bounds inclusive. */ + boolean intersects(int minX, int minY, int minZ, int maxX, int maxY, int maxZ); + + /** Whether any piece contains the block or comes within {@code margin} blocks of it. */ + boolean containsWithin(int x, int y, int z, int margin); +} diff --git a/api/src/main/java/com/volmit/resource/PackResources.java b/api/src/main/java/com/volmit/resource/PackResources.java index 319dc8aa9..5215ba9d9 100644 --- a/api/src/main/java/com/volmit/resource/PackResources.java +++ b/api/src/main/java/com/volmit/resource/PackResources.java @@ -6,6 +6,7 @@ import com.volmit.noise.NoiseFactory; import com.volmit.noise.PackExpression; import com.volmit.noise.PackImageMap; import com.volmit.object.GeneratedObject; +import com.volmit.object.PackObjects; import com.volmit.world.PackBiome; import com.volmit.world.PackRegion; import java.util.List; @@ -47,6 +48,9 @@ public interface PackResources { /** Builds the noise of the {@link com.volmit.noise.NoiseStyle}s the pack's settings describe. */ NoiseFactory noise(); + /** The pack's objects ready to place, their scaled variants, and the objects modules build. */ + PackObjects objects(); + /** The resource of {@code kind} the pack has under {@code id}; empty when it has none. */ Optional find(ResourceKind kind, ResourceId id); diff --git a/api/src/main/java/com/volmit/world/PackWorld.java b/api/src/main/java/com/volmit/world/PackWorld.java index d5c53999e..419fd2b2e 100644 --- a/api/src/main/java/com/volmit/world/PackWorld.java +++ b/api/src/main/java/com/volmit/world/PackWorld.java @@ -2,6 +2,7 @@ package com.volmit.world; import com.volmit.ModuleLog; import com.volmit.config.PackSettings; +import com.volmit.placement.Placements; import com.volmit.resource.PackResources; import com.volmit.resource.ResourceId; import java.util.Optional; @@ -65,6 +66,9 @@ public interface PackWorld { */ T state(Class type, Function create); + /** Runs the pack's placement stages for the objects a module places in this world. */ + Placements placements(); + /** The log of the module this world was handed to: every service call, lifecycle hook and stage body gets a view of * the world whose log is that module's own, so a line is labelled with the module that wrote it. */ diff --git a/api/src/main/java/com/volmit/world/RunningWorld.java b/api/src/main/java/com/volmit/world/RunningWorld.java index b9b669c38..b221279c0 100644 --- a/api/src/main/java/com/volmit/world/RunningWorld.java +++ b/api/src/main/java/com/volmit/world/RunningWorld.java @@ -35,6 +35,12 @@ public interface RunningWorld { */ List caveFloors(int chunkX, int chunkZ); + /** The placement a module recorded at the block when it generated it + * ({@link com.volmit.placement.PlacementTerrain#recordPlacement}); empty when none was, or when the block's chunk + * keeps no generation data any more. Y is the height above the dimension's bottom. + */ + Optional placementAt(int worldX, int y, int worldZ); + /** The time and weather of the world; empty while the platform has not loaded the world. */ Optional sky(); diff --git a/api/src/test/java/com/volmit/generation/ChunkContextTest.java b/api/src/test/java/com/volmit/generation/ChunkContextTest.java index b9a0c99d7..ebd358da4 100644 --- a/api/src/test/java/com/volmit/generation/ChunkContextTest.java +++ b/api/src/test/java/com/volmit/generation/ChunkContextTest.java @@ -3,6 +3,7 @@ package com.volmit.generation; import com.volmit.config.FeatureSettings; import com.volmit.geometry.BlockBox; import com.volmit.mantle.Mantle; +import com.volmit.placement.PlacementTerrain; import com.volmit.world.PackWorld; import com.volmit.world.TerrainSampler; import java.lang.reflect.Proxy; @@ -33,6 +34,7 @@ class ChunkContextTest { public TerrainSampler terrain() { return terrain; } public FeatureSettings settings() { throw new AssertionError("Unused settings"); } public Mantle mantle() { throw new AssertionError("Unused mantle"); } + public PlacementTerrain placementTerrain() { throw new AssertionError("Unused placement terrain"); } }; } diff --git a/host/src/main/java/com/volmit/host/LabelledModuleLog.java b/host/src/main/java/com/volmit/host/LabelledModuleLog.java index f10ab9e7d..0dbf8a5f4 100644 --- a/host/src/main/java/com/volmit/host/LabelledModuleLog.java +++ b/host/src/main/java/com/volmit/host/LabelledModuleLog.java @@ -21,12 +21,17 @@ final class LabelledModuleLog implements ModuleLog { @Override public void debug(String message) { - if (!logger.isLoggable(Level.DEBUG)) { + if (!debugging()) { return; } logger.log(Level.DEBUG, label + message); } + @Override + public boolean debugging() { + return logger.isLoggable(Level.DEBUG); + } + @Override public void info(String message) { logger.log(Level.INFO, label + message); diff --git a/host/src/main/java/com/volmit/host/MantleInvocation.java b/host/src/main/java/com/volmit/host/MantleInvocation.java index 5703159ec..3dfeba7f4 100644 --- a/host/src/main/java/com/volmit/host/MantleInvocation.java +++ b/host/src/main/java/com/volmit/host/MantleInvocation.java @@ -5,6 +5,7 @@ import com.volmit.config.FeatureSettings; import com.volmit.config.SettingsStack; import com.volmit.generation.MantleGenerationContext; import com.volmit.mantle.Mantle; +import com.volmit.placement.PlacementTerrain; import com.volmit.random.WorldRandom; import com.volmit.world.PackWorld; import com.volmit.stage.MantleStageContext; @@ -62,6 +63,11 @@ final class MantleInvocation implements MantleStageContext { return inputs.mantle(); } + @Override + public PlacementTerrain placementTerrain() { + return inputs.placementTerrain(); + } + @Override public PackWorld world() { return stages.world(inputs.world()); diff --git a/host/src/main/java/com/volmit/host/ModuleLogs.java b/host/src/main/java/com/volmit/host/ModuleLogs.java index 99c19984e..f2dd9b15b 100644 --- a/host/src/main/java/com/volmit/host/ModuleLogs.java +++ b/host/src/main/java/com/volmit/host/ModuleLogs.java @@ -30,6 +30,11 @@ public final class ModuleLogs { public void debug(String message) { } + @Override + public boolean debugging() { + return false; + } + @Override public void info(String message) { } diff --git a/host/src/main/java/com/volmit/host/ModuleWorld.java b/host/src/main/java/com/volmit/host/ModuleWorld.java index 0d94c9a1e..988ecc6c4 100644 --- a/host/src/main/java/com/volmit/host/ModuleWorld.java +++ b/host/src/main/java/com/volmit/host/ModuleWorld.java @@ -2,6 +2,7 @@ package com.volmit.host; import com.volmit.ModuleLog; import com.volmit.config.PackSettings; +import com.volmit.placement.Placements; import com.volmit.resource.PackResources; import com.volmit.resource.ResourceId; import com.volmit.world.PackWorld; @@ -61,6 +62,11 @@ final class ModuleWorld implements PackWorld { return world.running(); } + @Override + public Placements placements() { + return world.placements(); + } + @Override public T state(Class type, Function create) { Objects.requireNonNull(create, "create"); diff --git a/host/src/main/java/com/volmit/host/PlacementInvocation.java b/host/src/main/java/com/volmit/host/PlacementInvocation.java index 79686deed..fd339f641 100644 --- a/host/src/main/java/com/volmit/host/PlacementInvocation.java +++ b/host/src/main/java/com/volmit/host/PlacementInvocation.java @@ -8,6 +8,7 @@ import com.volmit.object.ObjectTransformer; import com.volmit.placement.PlacementAccess; import com.volmit.placement.PlacementContext; import com.volmit.placement.PlacementRequest; +import com.volmit.placement.PlacementTerrain; import com.volmit.random.WorldRandom; import com.volmit.world.PackWorld; import com.volmit.stage.BlockStageContext; @@ -149,6 +150,16 @@ final class PlacementInvocation implements BlockStageContext { return inputs.blocks(); } + @Override + public PlacementTerrain placementTerrain() { + return inputs.placementTerrain(); + } + + @Override + public Optional input(Class type) { + return inputs.input(type); + } + private void requireBlockPass() { if (blockStatus == BlockStatus.OUTSIDE_PASS) { throw new IllegalStateException("The current block is only available to block stages"); diff --git a/host/src/main/java/com/volmit/host/PlacementRunner.java b/host/src/main/java/com/volmit/host/PlacementRunner.java index 809c9dd08..81d71d847 100644 --- a/host/src/main/java/com/volmit/host/PlacementRunner.java +++ b/host/src/main/java/com/volmit/host/PlacementRunner.java @@ -2,6 +2,7 @@ package com.volmit.host; import com.volmit.placement.PlacementContext; import com.volmit.placement.PlacementEdit; +import com.volmit.placement.PlacementOutcome; import com.volmit.placement.PlacementRequest; import com.volmit.stage.Pipeline; import java.util.Objects; diff --git a/host/src/test/java/com/volmit/host/ExtensionsTest.java b/host/src/test/java/com/volmit/host/ExtensionsTest.java index 9c4109402..df350507a 100644 --- a/host/src/test/java/com/volmit/host/ExtensionsTest.java +++ b/host/src/test/java/com/volmit/host/ExtensionsTest.java @@ -10,6 +10,7 @@ import com.volmit.config.PackSettings; import com.volmit.generation.GenerationContext; import com.volmit.hunk.Hunk; import com.volmit.mantle.Mantle; +import com.volmit.placement.Placements; import com.volmit.random.WorldRandom; import com.volmit.resource.PackResources; import com.volmit.resource.ResourceId; @@ -88,6 +89,7 @@ class ExtensionsTest { public PackSettings settings() { throw new AssertionError("Unused settings"); } public int minWorldY() { return 0; } public Optional running() { return Optional.empty(); } + public Placements placements() { throw new AssertionError("Unused placements"); } public T state(Class type, Function create) { return states.state(type, () -> create.apply(this)); } public ModuleLog log() { return ModuleLogs.discarding(); } diff --git a/host/src/test/java/com/volmit/host/StageGraphTest.java b/host/src/test/java/com/volmit/host/StageGraphTest.java index 428de6d2a..c41d64c4b 100644 --- a/host/src/test/java/com/volmit/host/StageGraphTest.java +++ b/host/src/test/java/com/volmit/host/StageGraphTest.java @@ -18,6 +18,7 @@ import com.volmit.object.GeneratedObject; import com.volmit.object.ObjectBlock; import com.volmit.placement.PlacedBlock; import com.volmit.placement.PlacementEdit; +import com.volmit.placement.PlacementOutcome; import com.volmit.placement.PlacementRequest; import com.volmit.resource.ResourceId; import com.volmit.stage.BlockStageContext; diff --git a/host/src/test/java/com/volmit/support/DeclaredSettings.java b/host/src/test/java/com/volmit/support/DeclaredSettings.java index c49154945..59792d54d 100644 --- a/host/src/test/java/com/volmit/support/DeclaredSettings.java +++ b/host/src/test/java/com/volmit/support/DeclaredSettings.java @@ -4,6 +4,7 @@ import com.volmit.IrisFeature; import com.volmit.config.FeatureSettings.Entry; import com.volmit.config.PackSettings; import com.volmit.config.SettingsStack; +import com.volmit.resource.PackResources; import java.util.List; /** A pack's settings as a fixed list of declarations, for reach tests. */ @@ -24,4 +25,9 @@ public final class DeclaredSettings implements PackSettings { .map(entry -> (Entry) entry) .toList()); } + + @Override + public PackResources resources() { + return new EmptyResources(); + } } diff --git a/host/src/test/java/com/volmit/support/EmptyResources.java b/host/src/test/java/com/volmit/support/EmptyResources.java index 7b5610ee2..728795ca9 100644 --- a/host/src/test/java/com/volmit/support/EmptyResources.java +++ b/host/src/test/java/com/volmit/support/EmptyResources.java @@ -3,6 +3,7 @@ package com.volmit.support; import com.volmit.block.BlockRegistry; import com.volmit.item.ItemRegistry; import com.volmit.noise.NoiseFactory; +import com.volmit.object.PackObjects; import com.volmit.resource.PackResources; import com.volmit.resource.ResourceId; import com.volmit.resource.ResourceKind; @@ -39,6 +40,11 @@ public final class EmptyResources implements PackResources { throw new AssertionError("Unused noise"); } + @Override + public PackObjects objects() { + throw new AssertionError("Unused objects"); + } + @Override public Optional find(ResourceKind kind, ResourceId id) { return Optional.empty(); diff --git a/host/src/test/java/com/volmit/support/TestContexts.java b/host/src/test/java/com/volmit/support/TestContexts.java index ff90a5118..a741ff4ed 100644 --- a/host/src/test/java/com/volmit/support/TestContexts.java +++ b/host/src/test/java/com/volmit/support/TestContexts.java @@ -8,6 +8,8 @@ import com.volmit.hunk.Hunk; import com.volmit.mantle.Mantle; import com.volmit.object.ObjectTransformer; import com.volmit.placement.PlacementContext; +import com.volmit.placement.PlacementTerrain; +import java.util.Optional; import com.volmit.world.TerrainSampler; import com.volmit.world.BlockView; import com.volmit.world.PackWorld; @@ -52,6 +54,7 @@ public final class TestContexts { public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); } public FeatureSettings settings() { return settings; } public Mantle mantle() { return mantle; } + public PlacementTerrain placementTerrain() { throw new AssertionError("Unused placement terrain"); } }; } @@ -69,6 +72,8 @@ public final class TestContexts { if (blocks == null) throw new AssertionError("Unused blocks"); return blocks; } + public PlacementTerrain placementTerrain() { throw new AssertionError("Unused placement terrain"); } + public Optional input(Class type) { return Optional.empty(); } }; } diff --git a/host/src/test/java/com/volmit/support/TestWorld.java b/host/src/test/java/com/volmit/support/TestWorld.java index c64771024..7fe31d0ed 100644 --- a/host/src/test/java/com/volmit/support/TestWorld.java +++ b/host/src/test/java/com/volmit/support/TestWorld.java @@ -7,6 +7,7 @@ import com.volmit.config.SettingsStack; import com.volmit.host.ModuleLogs; import com.volmit.host.WorldStates; import com.volmit.random.WorldRandom; +import com.volmit.placement.Placements; import com.volmit.resource.PackResources; import com.volmit.resource.ResourceId; import com.volmit.world.PackWorld; @@ -49,6 +50,10 @@ public final class TestWorld implements PackWorld, AutoCloseable { public SettingsStack declared(Class featureType) { return SettingsStack.empty(); } + + public PackResources resources() { + return TestWorld.this.resources(); + } }; } @@ -62,6 +67,11 @@ public final class TestWorld implements PackWorld, AutoCloseable { return Optional.empty(); } + @Override + public Placements placements() { + throw new AssertionError("Unused placements"); + } + @Override public T state(Class type, Function create) { return states.state(type, () -> create.apply(this));