mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 09:15:27 +00:00
Place and locate structures through the api instead of the engine
Structure placement, its locator, the cave anchor resolver and the native start planner now take the pack world and its running world, and StructurePlacing writes through the mantle stage context and the placement graph. Terrain carving draws its noise from the pack's noise factory. The api gains clearBlock/clearAttached on PlacementTerrain, RunningWorld.carvedAt and VanillaStructureContext.world; modules get the host's seed purposes through their world view.
This commit is contained in:
1 parent
5ab99210b2
commit
3d209b393c
47 files changed
+1957
-1127
No files matched your search
+3
-2
@@ -32,7 +32,7 @@ types that carry them and lists what the Iris adapter still owes.
|
||||
| Geometry and mantle registration | `FeatureRegistry`, host `ModuleRegistry`, `FeatureCatalog` |
|
||||
| Block states and palettes | `BlockState`, `BlockRegistry` (`resolve(BlockSpec)`, `find(key)`, `blockEntity`, `hasTrait`, `oreFor`, `rotate(state, BlockTurn)`, `tryRotate(state, BlockTurn)` (empty for a block that cannot face the turn, where `rotate` answers air), `merge`, `withPropertyIfAccepted`, `matches`), `BlockTurn`, `BlockTrait` (with `STORAGE`), `BlockSpec`, `PaletteSpec` and `PaletteSampler` (`BlockRegistry.palette`) |
|
||||
| A pack's objects | `PlaceableObject` (`name`, size, `center`, `geometry`), `PackObjects` (`object`, `sizeOf`, `scaled` with `ScaleMethod`, `smartBored`, `build`), `PackResources.objects()` |
|
||||
| Placing through the pack's placement graph | `Placements.place(PlacementRun)` (`PackWorld.placements()`), `PlacementRun` (request, name, settings JSON, area, terrain, input, seed), `PlacementTerrain` (`recordPlacement` / `placementAt` with a `PlacementRecord`), `StructureVolumes`, `PlacedMarker`, `PlacementOutcome`; stages read `PlacementContext.placementTerrain()` and `input(type)`; mantle stages get a terrain from `MantleGenerationContext.placementTerrain()`; `RunningWorld.placementAt` reads what a placement recorded; `FeatureRegistry.registerPlacementType` names the type packs write placements as (host `FeatureCatalog.placementType()`, `PackSchema.placementType()`) |
|
||||
| Placing through the pack's placement graph | `Placements.place(PlacementRun)` (`PackWorld.placements()`), `PlacementRun` (request, name, settings JSON, area, terrain, input, seed), `PlacementTerrain` (`recordPlacement` / `placementAt` with a `PlacementRecord`; `clearBlock` / `clearAttached` take a block, or its block entity, record and markers, back), `StructureVolumes`, `PlacedMarker`, `PlacementOutcome`; stages read `PlacementContext.placementTerrain()` and `input(type)`; mantle stages get a terrain from `MantleGenerationContext.placementTerrain()`; `RunningWorld.placementAt` reads what a placement recorded; `FeatureRegistry.registerPlacementType` names the type packs write placements as (host `FeatureCatalog.placementType()`, `PackSchema.placementType()`) |
|
||||
| Noise from pack-described styles | `NoiseStyle`, `StyledRange`, `PackResources.noise()`, `NoiseFactory`, `NoiseSampler` |
|
||||
| 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)` |
|
||||
@@ -240,7 +240,8 @@ running Iris is the pack publisher's responsibility.
|
||||
- Answer `PackWorld.running()` for a world the host runs, empty for a tool's world. Its `layout()` covers every column of
|
||||
the world (not one chunk), with the same values chunk stages read; its `settings()` are the settings at a column and a
|
||||
biome's declarations as chunk stages see them; `highest` is the platform's highest block now; `caveFloors` are
|
||||
the cave floor markers of a chunk, in heights above the bottom; `sky()` is empty until the platform has the world.
|
||||
the cave floor markers of a chunk, in heights above the bottom; `carvedAt` is the void the cave carver planned at a
|
||||
block, empty where none was or when the host cannot read it; `sky()` is empty until the platform has the world.
|
||||
- Call the hooks with `LifecycleRunner`: `packLoaded` once per pack snapshot before its first world starts,
|
||||
`worldStarted` before the world generates anything, `warmUp` after it (on a thread of your choice, and wait for it before
|
||||
the world's first generation; report a failure naming the module and carry on), `worldStopped` when it stops. On a hotload, and when the pack's
|
||||
|
||||
@@ -48,6 +48,26 @@ public interface PlacementTerrain {
|
||||
*/
|
||||
void recordPlacement(int x, int y, int z, PlacementRecord placement);
|
||||
|
||||
/**
|
||||
* Takes back the block written at the position, so the terrain shows through there. The block entity, placement
|
||||
* record and markers kept beside it stay ({@link #clearAttached}).
|
||||
*
|
||||
* @throws UnsupportedOperationException when this terrain cannot take blocks back
|
||||
*/
|
||||
default void clearBlock(int x, int y, int z) {
|
||||
throw new UnsupportedOperationException("This terrain cannot take blocks back");
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes back the block entity, placement record and markers the host kept beside the block, whether or not a block
|
||||
* is still written there.
|
||||
*
|
||||
* @throws UnsupportedOperationException when this terrain cannot take them back
|
||||
*/
|
||||
default void clearAttached(int x, int y, int z) {
|
||||
throw new UnsupportedOperationException("This terrain cannot take what is kept beside a block back");
|
||||
}
|
||||
|
||||
/** The placement recorded at the block ({@link #recordPlacement}); empty when none is. */
|
||||
Optional<PlacementRecord> placementAt(int x, int y, int z);
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.volmit.vanilla;
|
||||
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/** The world a {@link com.volmit.service.VanillaStructures} provider decides for. Valid only while the provider runs. */
|
||||
public interface VanillaStructureContext {
|
||||
@@ -10,4 +13,9 @@ public interface VanillaStructureContext {
|
||||
|
||||
/** The module settings the world's dimension declares: its own, and every region and biome it can reach. */
|
||||
PackSettings settings();
|
||||
|
||||
/** The world the provider decides for; empty when it decides before any world exists, such as for the setup of a dimension. */
|
||||
default Optional<PackWorld> world() {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.volmit.world;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.data.SavedKey;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.mantle.CarvedVoid;
|
||||
import com.volmit.placement.PlacementRecord;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.List;
|
||||
@@ -43,6 +44,15 @@ public interface RunningWorld {
|
||||
*/
|
||||
Optional<PlacementRecord> placementAt(int worldX, int y, int worldZ);
|
||||
|
||||
/**
|
||||
* The void the cave carver planned at the block, as the world holds it now; empty where none was, or when the block's
|
||||
* chunk keeps no generation data any more, and on a platform that cannot read it. Y is the height above the
|
||||
* dimension's bottom.
|
||||
*/
|
||||
default Optional<CarvedVoid> carvedAt(int worldX, int y, int worldZ) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* The value the module keeps with this world across restarts under {@code key}: the host's one instance of it for
|
||||
* the world, read from the world's storage the first time anyone asks (or {@code key.initial()} when none was
|
||||
|
||||
@@ -4,6 +4,7 @@ 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;
|
||||
import com.volmit.world.RunningWorld;
|
||||
import java.util.List;
|
||||
@@ -37,6 +38,11 @@ final class ModuleWorld implements PackWorld {
|
||||
return world.seed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long seed(ResourceId purpose) {
|
||||
return world.seed(purpose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources resources() {
|
||||
return world.resources();
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.volmit.hunk.Hunk;
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.placement.Placements;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.stage.Pipeline;
|
||||
import com.volmit.stage.Stage;
|
||||
import com.volmit.support.TestContexts;
|
||||
@@ -73,6 +74,18 @@ class ExtensionsTest {
|
||||
assertEquals(Optional.of(new WorldOffer("iris")), view.extension(WorldOffer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aModulesViewOfAWorldAnswersTheSeedPurposesTheHostAnswers() {
|
||||
var world = new OfferingWorld(new WorldOffer("iris"));
|
||||
PackWorld view = ModuleWorld.of(world, ModuleLogs.discarding());
|
||||
|
||||
assertEquals(HOST_SEED, view.seed(HOST_SEED_PURPOSE), "the host decides the seed of a purpose it knows");
|
||||
assertEquals(world.seed(ResourceId.parse("test:other")), view.seed(ResourceId.parse("test:other")));
|
||||
}
|
||||
|
||||
private static final ResourceId HOST_SEED_PURPOSE = ResourceId.parse("test:host-seed");
|
||||
private static final long HOST_SEED = 31337L;
|
||||
|
||||
private static final class OfferingWorld implements PackWorld {
|
||||
private final WorldStates states = new WorldStates();
|
||||
private final WorldOffer offer;
|
||||
@@ -82,6 +95,7 @@ class ExtensionsTest {
|
||||
}
|
||||
|
||||
public long seed() { return TestContexts.SEED; }
|
||||
@Override public long seed(ResourceId purpose) { return purpose.equals(HOST_SEED_PURPOSE) ? HOST_SEED : PackWorld.super.seed(purpose); }
|
||||
public PackResources resources() { throw new AssertionError("Unused resources"); }
|
||||
public PackSettings settings() { throw new AssertionError("Unused settings"); }
|
||||
public int minWorldY() { return 0; }
|
||||
|
||||
Reference in new issue
Block a user