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