mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Docs: how a module reaches the host, shared libraries a host exposes, planned blocks, the chunk sampler's reach, fluid height and upper dimension, VINE and canPlaceOn, stage timings, the missing-key message
This commit is contained in:
1 parent
6c0c072afe
commit
e92de3b38a
3 files changed
+80
-14
No files matched your search
+13
-4
@@ -66,7 +66,8 @@ JSON fields. The description is in a fixed order and holds module entries only.
|
||||
|
||||
Modules compile against the API `compileOnly` and never ship it. At runtime they can use the API
|
||||
(`com.volmit.*`), the host packages the host chooses to expose, the JDK and the classes in their
|
||||
own pack's jars. They may use any library they ship in the pack, never Iris's copy. JDK modules
|
||||
own pack's jars. A host may expose libraries it shares with modules (Iris exposes VolmLib and Gson); any other
|
||||
library a module ships in the pack, never borrowing the host's copy. JDK modules
|
||||
outside the platform class loader, such as `jdk.compiler`, are not available, and neither are JDK
|
||||
packages not exported to unnamed modules, such as `jdk.internal.misc`, unless the server is started
|
||||
with `--add-exports <module>/<package>=ALL-UNNAMED`. `sun.misc.Unsafe` from `jdk.unsupported` is the
|
||||
@@ -121,7 +122,13 @@ running Iris is the pack publisher's responsibility.
|
||||
- Run each mantle stage (`MantleRunner.generate(stage, ...)`) as its own pass, in resolved order: for
|
||||
every chunk within that stage's reach plus the reach of every later stage of a chunk, each chunk once,
|
||||
before the next stage and before that chunk generates, with the mantle widened by the stage's reach.
|
||||
Give chunk stages that chunk's mantle; `ChunkRunner` makes it read-only.
|
||||
Give chunk stages that chunk's mantle; `ChunkRunner` makes it read-only. Give chunk stages a `TerrainSampler` over the
|
||||
chunk and the 16 blocks around it.
|
||||
- Serve `Mantle.blocks()` in every invocation: the blocks placements wrote into the mantle, read-only, none where the
|
||||
dimension keeps no mantle or the chunk generates without it. A block a stage reads and writes back unchanged keeps
|
||||
the host's own identity of it (a custom block of a content plugin stays one).
|
||||
- Answer `TerrainSampler.fluidHeight()` (the height the host fills with fluid below) and `upperDimensionY(x, z)` (where a
|
||||
dimension stacked above begins; empty when none does).
|
||||
- Make placement edits atomic across blocks, block entities, markers and mantle in generation
|
||||
storage. Abort chunk publication when any stage fails.
|
||||
- Preserve unknown persisted mantle layers or fail explicitly.
|
||||
@@ -134,8 +141,8 @@ running Iris is the pack publisher's responsibility.
|
||||
to `ModuleHost.copyingJarsTo(...)` for the jar copies.
|
||||
- Provide the API at runtime from the plugin's class loader, for example by shading it into the
|
||||
Iris plugin jar. Pack jars must not ship it.
|
||||
- Pass the packages of built-in modules whose stages packs may require to
|
||||
`ModuleHost.exposing(...)`. They must be on the loader that defines the
|
||||
- Pass the packages of built-in modules whose stages packs may require, and of libraries the host shares with
|
||||
modules, to `ModuleHost.exposing(...)`. They must be on the loader that defines the
|
||||
API. Keep them narrow: everything in an exposed package and its subpackages becomes visible to
|
||||
packs and is part of what packs can break on. Stage output types and settings types that pack
|
||||
code uses through those stages must be in exposed packages too. The API is always exposed.
|
||||
@@ -192,6 +199,8 @@ running Iris is the pack publisher's responsibility.
|
||||
- Serve `PackResources.noise()`: build each style's noise from the host's generators, expressions and image maps,
|
||||
the same values for the same style and seed, cached per pack snapshot; an unknown style name is flat, a missing
|
||||
expression falls back to the base style, and a missing image map fails.
|
||||
- Answer `BlockRegistry.hasTrait` (`VINE` included) and `canPlaceOn` (the support rule decorations need) as the platform
|
||||
does; stages ask per block, so answer from memory once a state was seen.
|
||||
- Resolve `BlockSpec`s in `BlockRegistry` as packs expect (pack block, platform block, backup, air) and turn their
|
||||
`tileData` into the host's block entity format.
|
||||
- Build `BlockRegistry.palette(spec, seed)` pickers: blocks expanded by weight, the style's noise at (x, y, z) over
|
||||
|
||||
@@ -159,9 +159,13 @@ definition of the id. Names match whole packages: `com.volmit` does not expose `
|
||||
trailing dot is accepted; anything that is not a package name, such as a blank string or a
|
||||
wildcard, is rejected. `PackageName` holds these rules; module optional packages use them too.
|
||||
|
||||
A module may use any library, but it ships that library itself, inside its own jar or as another
|
||||
jar of the pack. It never borrows Iris's copy: Iris's libraries can change with any Iris update,
|
||||
and two modules would otherwise depend on whatever version Iris happens to bundle.
|
||||
A module may use any library. A library the host does not expose it ships itself, inside its own jar or as another
|
||||
jar of the pack, and never borrows the host's hidden copy: those can change with any host update, and two modules would
|
||||
otherwise depend on whatever version the host happens to bundle. A host may instead expose a library it promises to
|
||||
keep, by passing its packages to `ModuleHost.exposing`; the pack loader then gives modules the host's classes of it,
|
||||
like the API's. Iris exposes VolmLib (`art.arcane.volmlib`, its utility library, shaded unrelocated) and Gson
|
||||
(`com.google.gson`, which every platform it runs on provides), so Iris's built-ins and pack modules share one copy of
|
||||
each. A module jar may not contain classes of an exposed library, as it may not contain API classes.
|
||||
|
||||
Resources follow the same rule by path: `com/volmit/...` and the paths of other exposed packages
|
||||
from the host's loader, everything else from the platform loader, then the pack's jars. A class
|
||||
@@ -491,6 +495,15 @@ world X and Z, and Y as the height above the dimension's bottom. A chunk stage w
|
||||
whose writes throw. The runner does no neighbor scheduling or rollback. A failed invocation must stop
|
||||
the host from publishing the chunk.
|
||||
|
||||
A chunk stage writes only its chunk but may look around it: its `TerrainSampler` covers the chunk and the 16 blocks
|
||||
around it, so a stage that smooths a surface reads its neighbors' heights. The sampler also gives the dimension's
|
||||
`fluidHeight()` and, per column, `upperDimensionY` where a dimension stacked above begins; a stage writes nothing at or
|
||||
above it. The mantle's `blocks()` are the blocks placements wrote into the mantle for chunks to take over (objects,
|
||||
structures): a chunk stage copies them into its chunk, as Iris's `iris:matter` does. They are the host's layer, so they
|
||||
need no registration, and stages only read them; placements keep writing blocks through `PlacementAccess.set`.
|
||||
`ChunkRunner.generate(inputs, seed, timings)` reports how long each stage that ran took, so the host times modules
|
||||
instead of modules timing themselves.
|
||||
|
||||
## Mantle invocations
|
||||
|
||||
Some work writes beyond its chunk: a carver whose tunnels cross chunk borders, a vein running on into
|
||||
@@ -592,6 +605,13 @@ shorthand wave 2 removed (a bare value accepted as an alternative to the object,
|
||||
the class chooses its one shape once, and the decoder, the studio schema and the pack author see only that shape.
|
||||
A `@Snippet` class may still be written as a `"snippet/..."` string instead of its object.
|
||||
|
||||
*A class built before keys existed.* A settings class compiled against an API whose `@Feature` had no `key` has an
|
||||
incomplete annotation; reading it would throw `IncompleteAnnotationException`, which names neither module nor class.
|
||||
`FeatureDescriptor.of` turns it into a load error that names the module and its jar, the class, and the key to add,
|
||||
suggested from the id: `Module old:flora from modules/old.jar: The @Feature of settings class pack.old.Old$Patch has no
|
||||
key, the JSON field packs write the settings under; add key = "floraWildPatch" (or another plain field name) to it and
|
||||
rebuild the jar`.
|
||||
|
||||
`GeneratedObject` is sparse, immutable local geometry with bounds, an anchor, sorted blocks,
|
||||
optional block entity payloads and markers. `ObjectGenerator` produces it from settings and a
|
||||
`WorldRandom`. `ObjectTransformer` is host-owned.
|
||||
@@ -979,6 +999,26 @@ from a sapling, which drops a block has. A module answers such questions through
|
||||
question without a world. Passing the world keeps providers stateless like stage bodies and puts all per-world data
|
||||
in one place.
|
||||
|
||||
## How a module reaches the host
|
||||
|
||||
A module jar sees three things besides the JDK and its own pack's jars, and nothing else of the host:
|
||||
|
||||
1. **The API** for everything a worldgen module needs: blocks (`BlockState`, `BlockRegistry` traits, tags, support and
|
||||
specs), noise (`NoiseFactory`), randomness (`WorldRandom`, stage streams), the layout as values (`TerrainSampler`,
|
||||
`BiomeSample`, `PackBiome`, `PackRegion`, settings per column), the chunk's hunk and mantle (layers and planned
|
||||
blocks), pack resources and module resource kinds, per-world state, lifecycle hooks, services and validation.
|
||||
Whatever a second module could want goes here, host-neutral and tested without Iris.
|
||||
2. **Packages the host exposes**: libraries it shares (VolmLib, Gson) and the public face of its built-in modules
|
||||
(`art.arcane.iris.builtin`: stage constants, settings and output types packs may read).
|
||||
3. **Narrow facades for the host's own built-ins**, in that same exposed package: interfaces the host's worlds
|
||||
implement, for what only the host's own features need from its internals, such as Iris's per-feature world seeds
|
||||
(`IrisSeed`), which existing worlds depend on. A pack module never needs one. Every such type is a promise the host
|
||||
keeps, so there are few, each answers one question, and none hands out an engine.
|
||||
|
||||
A module never reaches the host's engine, its data loader or its layout classes; it reads the layout through the API's
|
||||
values and its settings through `FeatureSettings`. Iris's mapping from its internals to this surface, with the
|
||||
utilities that move into VolmLib, is in its notes (context.md, "How a module reaches the host").
|
||||
|
||||
## Not implemented
|
||||
|
||||
- Host wiring, which lives in Iris: JSON decoding and validation, rendering `PackSchema` into Iris's schema and
|
||||
|
||||
@@ -120,6 +120,19 @@ graph.define(CARVE).when(CaveSettings.class).reach(32).writesMantle(CAVES).run(C
|
||||
graph.define(APPLY).run(CaveModule::apply); // reads its own chunk's CAVES and writes blocks
|
||||
```
|
||||
|
||||
A chunk stage writes only its own chunk but may look around it: `ctx.terrain()` covers the chunk and the 16 blocks
|
||||
around it, gives the dimension's `fluidHeight()` and, per column, `upperDimensionY(x, z)` where a dimension stacked above
|
||||
begins (write nothing there). `ctx.mantle().blocks()` holds the blocks placements wrote into the mantle for the chunks to
|
||||
take over, such as objects and structures; a chunk stage copies them in (Iris's `iris:matter`). Stages only read them.
|
||||
|
||||
```java
|
||||
graph.define(INSERT).run(ctx -> {
|
||||
var blocks = ctx.hunk(BlockState.class);
|
||||
var chunk = new BlockBox(ctx.originX(), 0, ctx.originZ(), ctx.originX() + 16, blocks.getHeight(), ctx.originZ() + 16);
|
||||
ctx.mantle().blocks().visit(chunk, (x, y, z, block) -> blocks.set(x - ctx.originX(), y, z - ctx.originZ(), block));
|
||||
});
|
||||
```
|
||||
|
||||
`reach(blocks)` is the distance in blocks along X and Z beyond the stage's footprint: the chunk for a
|
||||
mantle stage, the X/Z bounds of the placed object for a placement stage, whole columns in both cases.
|
||||
It defaults to 0. `writesMantle(...)` names the mantle layers the stage writes; each must be
|
||||
@@ -333,12 +346,13 @@ refuse.
|
||||
|
||||
A module compiles against the Iris API as `compileOnly` (Maven: `provided`) and never ships it;
|
||||
Iris provides the API at runtime. At runtime a module can use the Iris API (`com.volmit.*`), the
|
||||
packages the host exposes besides it (meant for built-in modules, so packs can require their
|
||||
stages), the JDK and the classes in its pack's module jars. Iris internals and the libraries Iris
|
||||
bundles are hidden.
|
||||
packages the host exposes besides it (the built-in modules' stages and types, so packs can require
|
||||
their stages, and the libraries the host shares: Iris exposes VolmLib, `art.arcane.volmlib`, and Gson,
|
||||
`com.google.gson`), the JDK and the classes in its pack's module jars. Iris internals and the other
|
||||
libraries Iris bundles are hidden.
|
||||
|
||||
A module may use any library. It ships the library inside its own jar or as another jar of the
|
||||
pack, and never borrows Iris's copy. A class may appear in only one jar of a pack, so two jars that
|
||||
A module may use any library. One the host does not expose it ships inside its own jar or as another
|
||||
jar of the pack, and never borrows Iris's copy. A class may appear in only one jar of a pack, so two jars that
|
||||
shade the same library must relocate it. The API's package and the other exposed packages belong
|
||||
to Iris: module classes, and the libraries they shade, must not use them.
|
||||
|
||||
@@ -446,6 +460,7 @@ A load error names the field, the settings and the module:
|
||||
Field com.example.flora.FloraSettings.id of settings example:flora (module example:flora from modules/flora.jar) uses java.util.UUID, a JDK class settings cannot use; settings fields can be booleans, numbers, String, ResourceId, BlockState, enums, lists, sets and arrays of these, Map with String keys and classes with a no-argument constructor
|
||||
Field com.example.flora.FloraSettings.count of settings example:flora (module example:flora from modules/flora.jar) has @Ref(BLOCK) on int, but @Ref fits only String and ResourceId and lists, sets and arrays of them
|
||||
Class com.example.flora.Shape of settings example:flora (module example:flora from modules/flora.jar) has no no-argument constructor; the host creates settings with it and reads their defaults from it, so declare one, private if nothing else should use it
|
||||
Module old:flora from modules/old.jar: The @Feature of settings class com.example.flora.Patch has no key, the JSON field packs write the settings under; add key = "floraPatch" (or another plain field name) to it and rebuild the jar
|
||||
Snippet name 'patch' of com.example.flora.Patch of settings example:flora (module example:flora from modules/flora.jar) is not under a module of the pack; snippets of pack modules start with their module's id as a folder path, such as 'example/flora/patch' (folder snippet/example/flora/patch/)
|
||||
```
|
||||
|
||||
@@ -592,7 +607,7 @@ try (var pack = LoadedPack.load(packRoot, host)) {
|
||||
for (var stage : pack.mantle().stages()) { // each stage its own pass, first
|
||||
mantle.generate(stage.stage(), mantleContext, chunkSeed); // for each chunk it reaches
|
||||
}
|
||||
new ChunkRunner(pack.chunk()).generate(generationContext, chunkSeed);
|
||||
new ChunkRunner(pack.chunk()).generate(generationContext, chunkSeed, (stage, nanos) -> metrics.time(stage, nanos));
|
||||
} // stop using the runners before the pack closes
|
||||
```
|
||||
|
||||
@@ -749,7 +764,9 @@ Optional<Clock> clock = pack.catalog().service(Clock.class); // a Pro
|
||||
resource kind; the requested type selects the kind, so `BiomeSample` ids look up directly. `ids(type)` lists
|
||||
a kind.
|
||||
- `BlockState` has value equality and sorted properties; `BlockRegistry` checks it against the
|
||||
platform and resolves `BlockSpec`s. `BlockPalette` and `NoiseSampler` are typed resources (`PaletteSampler` is the noise-picked palette of settings);
|
||||
platform and resolves `BlockSpec`s. It answers a state's traits (`AIR`, `SOLID`, `FLUID`, `FOLIAGE`, `DECORATION`,
|
||||
`VINE`, ...), tags, whether it attaches to a face (`canAttach`) and whether it can stand on a block (`canPlaceOn`, the
|
||||
rule decorations need), as the platform does. `BlockPalette` and `NoiseSampler` are typed resources (`PaletteSampler` is the noise-picked palette of settings);
|
||||
`PackResources.noise()` builds noise samplers from `NoiseStyle`s.
|
||||
- `GeneratedObject` is sparse, immutable local geometry. `PlacementRequest` aligns its anchor
|
||||
with a world position using checked arithmetic.
|
||||
|
||||
Reference in new issue
Block a user