mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Document the vanilla structure hook's starts, adjustments and setup
README (the three methods, an example start, the fit value types, the new Reference kinds), DESIGN (why starts are a hook method, why the platform's own starts get a second per-structure method, fit values as value types, setup before a world exists), CONTRACTS (types, adapter requirements; the planner item leaves Open).
This commit is contained in:
1 parent
c90ce5ce47
commit
94be126d25
3 files changed
+67
-9
No files matched your search
+13
-5
@@ -27,8 +27,8 @@ 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`, `BlockPalette`, `BlockSpec` (`BlockRegistry.resolve(BlockSpec)`, `blockEntity`), `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`, `Object` as `ValueKind.AnyKind` |
|
||||
| Decisions over the platform's own structures | `VanillaStructureHook`, `VanillaStructureRule`, `VanillaStructureContext`, `FeatureRegistry.registerVanillaStructureHook`, host `FeatureCatalog.vanillaStructureHooks()` |
|
||||
| Values in settings | `BlockSpec`, `PaletteSpec`, `NoiseStyle`, `StyledRange`, `Range`, `BlockPosition`, `StructureTerrain`, `StructureStilts`, `YBand`, `JigsawOverrides`, `Object` as `ValueKind.AnyKind` |
|
||||
| Decisions over the platform's own structures | `VanillaStructureHook` (`rule`, `adjustment`, `starts`, `setup`), `VanillaStructureRule`, `VanillaStructureContext`, `VanillaStructureAdjustment`, `VanillaStructureFit`, `VanillaStructureStart`, `VanillaStructureStartContext`, `VanillaStructureSetup`, `FeatureRegistry.registerVanillaStructureHook`, host `FeatureCatalog.vanillaStructureHooks()` |
|
||||
| Pack-scoped resolution | `ResourceId`, `ResourceKey<T>`, `PackResources` (`find`, `ids`), `PackBiome`, `PackRegion` |
|
||||
| Module-owned pack resources | `ResourceKind`, `FeatureRegistry.registerResourceKind`, `@ResourceRef`, host `ModuleHost.reservingFolders`, `FeatureCatalog.resourceKinds()`, `ResourceKindSchema`, `ValueKind.ResourceReferenceKind` |
|
||||
| Module-owned pack checks | `Validator`, `ValidationContext`, `Problem`, `Severity`, `Subject`, `FeatureRegistry.registerValidator`, host `FeatureCatalog.validators()` |
|
||||
@@ -192,10 +192,18 @@ running Iris is the pack publisher's responsibility.
|
||||
structures and when it locates one, combine the rules with `VanillaStructureRule.and`, keep the result per world,
|
||||
structure and pack snapshot, and apply it on every platform: block the platform's starts of a blocked
|
||||
structure, and report a structure a module places as that module's. A hook that throws fails naming its module.
|
||||
- Ask `adjustment` per world, structure, underground flag and pack snapshot, compose with
|
||||
`VanillaStructureAdjustment.then` in module id order, and apply it to the platform's own starts: keeping the source
|
||||
height over a band over the host's repositioning, then the shift; fit the terrain before the pieces and build
|
||||
stilts after. Convert API heights (above the bottom) to world Y at the boundary; `YBand` is world Y.
|
||||
- Ask `starts` per chunk, in module id order, refuse a start outside the chunk asked for, keep the first start per
|
||||
structure, let a start take the chunk from a platform start only when it says so or the structure is `REPLACE`d,
|
||||
apply its jigsaw overrides and fit, record its identity with every start the host publishes, and ask again (same
|
||||
answer) when locating or verifying a start found in the world.
|
||||
- Ask `setup` per dimension before its worlds build their structure state and when installing data packs; multiply
|
||||
frequencies per structure set (0.01 to 16), protect the platform's definitions in every installed data pack once
|
||||
any dimension of any loaded pack asks for it.
|
||||
|
||||
## Open
|
||||
|
||||
- Placing the platform's structures where a module chooses (Iris's native structure planner): a hook method
|
||||
returning starts per chunk, with the terrain fitting and foundations the host builds around them.
|
||||
|
||||
- Terrain/biome providers, pack transformations, structure assembly and the runtime family.
|
||||
@@ -795,8 +795,29 @@ platform.
|
||||
- **The context is the world's pack.** `resources()` and `settings()` (`PackSettings`: the dimension and every
|
||||
region and biome it can reach), the same view reaches are worked out from. A hook that needs the world's own
|
||||
state gets it the way stages do.
|
||||
- **Placing starts is not part of it yet.** Where the platform should start a structure a module places, with the
|
||||
terrain fitting and foundations that go with it, comes with the planner's move (see CONTRACTS, Open).
|
||||
- **Placing starts: `starts(chunkX, chunkZ, context)`, a hook method, not a service.** The question is the same
|
||||
hook's (which platform structures does this module own), asked per chunk because the platform generates per chunk,
|
||||
and its answers sit next to the rule a module gives the same structures. A start carries everything the platform
|
||||
needs and nothing it can work out: structure, chunk, height above the bottom, surface or underground, whether it
|
||||
takes the chunk from a platform start, jigsaw overrides, the fit, and an identity the host persists with the start
|
||||
so a start found in a saved world can be traced to its placement. Several placements of one module that start one
|
||||
structure in one chunk are the module's to resolve; across modules the host keeps the first in module id order.
|
||||
The context is the `PackWorld` (seed, state) plus a `TerrainSampler`, not raw seeds: a start that needs heights
|
||||
asks the host's terrain, like a stage does.
|
||||
- **The platform's own starts get an adjustment, a second per-structure method.** `importedStructures`' vertical
|
||||
moves (`yShift`, `yBand`, `preserveSourceY`) and fit apply to starts the platform makes, which no module returns, so
|
||||
they cannot ride on `VanillaStructureStart`. They are a per-structure answer like the rule (cached the same way,
|
||||
with the platform's underground-step flag as the only extra input), so `adjustment(structure, underground,
|
||||
context)`. A separate value rather than a richer rule keeps the rule's order-free `and`; adjustments compose in
|
||||
module id order (`then`), which is what one module's list of matching entries always did.
|
||||
- **Fit values are value types, the host keeps Iris's classes.** `StructureTerrain`, `StructureStilts`, `YBand` and
|
||||
`JigsawOverrides` read the JSON Iris's classes read, so settings can hold them and packs keep their JSON. The host
|
||||
converts them into its own classes for the platform code, which also persists the fit of every start it publishes:
|
||||
the stored JSON stays the same. Modes, shapes and heightmaps are API enums because the host implements each one.
|
||||
- **Setup before a world exists: `setup(context)`.** Structure set frequencies and protecting the platform's
|
||||
definitions from installed data packs are decided when the platform builds its structure state or the host
|
||||
installs data packs, before any world of the dimension runs. The context is the dimension's settings without an
|
||||
engine. Frequencies multiply across modules; protection holds when any module asks for it.
|
||||
|
||||
## Pack resource kinds
|
||||
|
||||
@@ -948,7 +969,7 @@ This is an inventory of where each existing family should land, not a claim that
|
||||
| Cave profiles, carving, cave fluids and decoration | Chunk stages + typed carve layers |
|
||||
| Floating islands and child biomes | Terrain/biome sampling + chunk and placement stages |
|
||||
| Structures, jigsaw pools and foundations | Structure assembly producing placement requests |
|
||||
| Imported/native structures and ownership | `VanillaStructureHook` rules; host native-generation adapter per platform |
|
||||
| Imported/native structures and ownership | `VanillaStructureHook` (rule, adjustment, starts, setup); host native-generation adapter per platform |
|
||||
| Terrain layers, fluids, bedrock, interpolation | Terrain providers + chunk stages |
|
||||
| Region/biome selection | Biome providers + platform biome writer |
|
||||
| Image maps, noise expressions, pack injection | Compiled immutable pack resources |
|
||||
|
||||
@@ -395,7 +395,8 @@ public final class FloraSettings implements IrisFeature {
|
||||
interfaces and abstract classes, inner (non-static) classes, collections without type arguments,
|
||||
concrete collections such as `ArrayList`, and maps with other keys.
|
||||
- `@Ref(Reference.X)` says what a `String` or `ResourceId` names, also on lists, sets and arrays of
|
||||
them, so studio offers the right list: `BLOCK`, `ITEM`, `ENTITY`, `BIOME`, `STRUCTURE`,
|
||||
them, so studio offers the right list: `BLOCK`, `ITEM`, `ENTITY`, `BIOME`, `STRUCTURE`, `STRUCTURE_PREFIX`
|
||||
(a structure or a family prefix such as `minecraft:village`), `STRUCTURE_SET`,
|
||||
`POTION_EFFECT` or `ENCHANTMENT` from the server's registries, `NOISE_STYLE` from the host's noise
|
||||
styles, or `PACK_BIOME`, `PACK_REGION`, `PACK_OBJECT`, `PACK_EXPRESSION` or `PACK_IMAGE_MAP` of the pack.
|
||||
The pack kinds fit `String` only, in the form packs use (`desert/dunes`), never `ResourceId`. `BlockState` fields name blocks without it. `@Ref` on any other field fails
|
||||
@@ -487,6 +488,34 @@ structure and when it locates it, so a hook decides from the pack, never from a
|
||||
structure is blocked when any module blocks it, and placed by a module when any module places it. The host applies
|
||||
the result on every platform it runs on.
|
||||
|
||||
A hook has three more methods, each with a default that changes nothing, so a hook that only rules stays a lambda:
|
||||
|
||||
- `adjustment(structure, underground, context)`: how the platform's own starts of a structure are moved (`shifted`,
|
||||
`withYBand` in world Y, `keepingSourceY`) and fitted (`VanillaStructureFit`: a `StructureTerrain` fitting before
|
||||
the pieces are placed, `StructureStilts` foundation columns after). Asked and kept like the rule; adjustments of
|
||||
several modules apply one after the other in module id order (`then`: shifts add up, a later band or fit part wins).
|
||||
- `starts(chunkX, chunkZ, context)`: the platform structures the module starts in that chunk itself. A
|
||||
`VanillaStructureStart` names the structure, its height above the bottom (`underground()` puts the structure's
|
||||
lowest block there; otherwise it sits on the surface), whether it takes the chunk from a platform start of the same
|
||||
structure, a stable `identity` the host records with it, `JigsawOverrides` for jigsaw structures and a fit. The
|
||||
context gives the world (`PackWorld`) and a `TerrainSampler` over the chunk. Answer from the world and chunk only:
|
||||
the host asks again when it locates structures and when it checks starts it finds in the world.
|
||||
- `setup(context)`: before any world of the dimension exists, how often each structure set starts (`withFrequency`,
|
||||
multipliers of several modules multiply) and whether the data packs the host installs must leave the platform's own
|
||||
structure definitions alone (`protectingVanillaDefinitions`, for every pack once any dimension asks for it).
|
||||
|
||||
```java
|
||||
public List<VanillaStructureStart> starts(int chunkX, int chunkZ, VanillaStructureStartContext context) {
|
||||
if (!castleChunk(context.world().seed(), chunkX, chunkZ)) return List.of();
|
||||
int surface = (int) context.terrain().column((chunkX << 4) + 8, (chunkZ << 4) + 8).surfaceY();
|
||||
return List.of(VanillaStructureStart.at(ResourceId.parse("minecraft:village_plains"), chunkX, chunkZ, surface)
|
||||
.withFit(VanillaStructureFit.SOURCE.withTerrain(StructureTerrain.of(StructureTerrain.Mode.VACUUM))));
|
||||
}
|
||||
```
|
||||
|
||||
`StructureTerrain`, `StructureStilts`, `YBand` and `JigsawOverrides` are value types like `PaletteSpec`: settings may
|
||||
hold them, and packs write them as Iris always read them.
|
||||
|
||||
## Host side
|
||||
|
||||
```java
|
||||
|
||||
Reference in new issue
Block a user