From cf07610a0c941cd450007e21747eda36780d26ca Mon Sep 17 00:00:00 2001 From: piexel Date: Tue, 10 Nov 2026 06:33:24 +0100 Subject: [PATCH] Document the tool world, import and service api the structure move added --- api/CONTRACTS.md | 8 ++++---- api/DESIGN.md | 28 +++++++++++++++++++--------- api/README.md | 25 ++++++++++++++++++++++--- module/README.md | 33 ++++++++++++++++----------------- 4 files changed, 61 insertions(+), 33 deletions(-) diff --git a/api/CONTRACTS.md b/api/CONTRACTS.md index d20d1fc34..25d6f01e9 100644 --- a/api/CONTRACTS.md +++ b/api/CONTRACTS.md @@ -35,20 +35,20 @@ types that carry them and lists what the Iris adapter still owes. | 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)` | +| Decisions over and fit of the platform's own structures | service `VanillaStructures` (`rule`, `starts`, `shift`, `reach`, `beforePieces`, `afterPieces`, `setup`), `VanillaStructureRule`, `VanillaStructureContext` (`world()`, empty when the host asks before any world exists), `VanillaStructureStart`, `VanillaStructureStartContext`, `VanillaStructureSetup`, `PlatformStart`, `StartMemo`, `StartReach`, `StructureFit` (`Start`, `Piece`, `ColumnVisitor`), `DecorationStep`, `TerrainAdaptation`, `PieceKind`, `TemplateCells`, `world.BlockAccess`, host `FeatureCatalog.registrations(service)` | | Pack-scoped resolution | `ResourceId` (`ofPackKey`, `ofPlatformKey`), `ContentKey`, `PackResources` (`find(kind, id)`, `require`, `ids(kind)`, `idOf`; kinds `BIOMES`, `REGIONS`, `OBJECTS`, `EXPRESSIONS`, `IMAGE_MAPS`), `PackBiome`, `PackRegion`, `PackExpression`, `PackImageMap` | | 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()` | | Per-world module state | `PackWorld` (`state`), `InvocationContext.world()`, host `WorldStates` | | 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)`; modules ask each other with `PackWorld.services(type)`, `ValidationContext.services(type)` and `ToolPack.services(type)` (host `ModuleWorld` forwards to the host's world); services `ObjectsAt`, `StructureLocator` (`LocateResult`, `startedStructures`, `locatableStarts`, `locateStart`, `ChunkFilter`), `SaplingGrowth`, `Loot` (with `shuffleSeed`), `BlockDrops`, `EntitySpawns`, `CaveBiomes`, `ProtectedFloor`, `AmbientEffects`, `VanillaFeatures` (`DecorationStep`); values `ItemDrop`, `EntitySpec`, `ItemRegistry` (`PackResources.items()`) | +| Host questions answered by modules | `@Service`, `Providers`, `FeatureRegistry.registerService`, host `FeatureCatalog.services(type)` / `service(type)`; modules ask each other with `PackWorld.services(type)`, `ValidationContext.services(type)` and `ToolPack.services(type)` and `PackResources.services(type)` (empty by default; host `ModuleWorld` forwards to the host's world); services `DatapackStructureImport` (`importAll`, `DatapackImportReport`), `ObjectsAt`, `StructureLocator` (`LocateResult`, `startedStructures`, `locatableStarts`, `locateStart`, `ChunkFilter`), `SaplingGrowth`, `Loot` (with `shuffleSeed`), `BlockDrops`, `EntitySpawns`, `CaveBiomes`, `ProtectedFloor`, `AmbientEffects`, `VanillaFeatures` (`DecorationStep`); values `ItemDrop`, `EntitySpec`, `ItemRegistry` (`PackResources.items()`) | | Terrain and settings sampling | `TerrainSampler`, `BiomeSample`, `TerrainSample`, `FeatureSettings` | | Dense chunk output | `Hunk`, `GenerationContext.blocks`, reference `ArrayHunk` | | Positions, boxes and faces | `com.volmit.geometry`: `BlockPosition`, `BlockBox`, `BlockFace` | | Sparse geometry | `GeneratedObject` | | Studio views of what a module builds | `com.volmit.tooling`: `ModuleSetup.tooling()` (`ToolingRegistry.registerView`), sealed `StudioView` (`SceneView` with `SceneEntry`, `PatternView` with `PatternEntry`, `PatternArea`, `BlockPattern`), `EditableSceneView` (`SceneFile`, `NodeGraph`, `GraphNode` with `Link`, `NodeSettings`, `Edits`, `Addition`), `JsonText`, `JsonPath` (`Key`, `Index`), host `StudioViewRegistration` | -| Commands of a module | `com.volmit.tooling`: `ToolingRegistry.registerCommand`, immutable `Command` (`named`, `alias`, `describe`, `child`, `argument`, `runs`, `openToEveryone`), typed `Argument` (`word`, `text`, `integer`, `decimal`, `flag`, `choice`, `resource`, `registered`, `orElse`, `suggesting`), `CommandAction`, `CommandContext` (`get`, `sender`, `pack`, `world`, `platform`, `platformStructures`), plain-text `Sender` (with `player()`), `PlatformStructures` (`templates`, `template` answering `StructureTemplate`, `structures`, `structureSets`, `jigsaw` answering `JigsawStructureInfo`, `pool` answering `TemplatePool` with `Member`, `Element`, `ConnectorSource`, `Connectors` and `JigsawConnector`, `supportsCapture`, `openCaptureArea` answering a closable `CaptureArea` whose `capture` answers `CapturedStructure`; `TemplateBlock`; readers throw `StructureAccessException`), `ToolPack` (`edit` with `PackEdit`, `outputFolder`, `objects` with `ObjectCodec`, `worlds`, `services`), host `CommandRegistration` in `FeatureCatalog.commands()` | -| Worlds a tool opens | `com.volmit.tooling.world`, exposed to pack modules by host `ExposedPackages`: `ToolWorlds` (`open`, `find`) with `ToolWorldSpec`, `ChunkPainter` and `ChunkCanvas`, `ToolWorld` (`players`, `owns`, `run`, `call`, `block`, `blockEntity`, `setBlock`, `loaded`, `repaint`, `close`), `ToolPlayer` (`targetBlock`, `teleport`, `creative`, `message`, `actionBar`, `sound`, `sidebar`, `particles`, `give` answering whether the item fitted, `held`, `openMenu`), `ToolText` with `TextColor` (styled text: item names and lore, menu titles, sidebar, chat and action bar; the host shows each span in its colour and style, an empty sidebar title keeps the platform's, and an item read back has plain text), `ToolItem`, `ToolMenu` with `MenuButton` and `MenuClick`, `Particle`, `ToolWorldListener` (`entered`, `left`, `teleported` for every arrival other than walking, at the time of the teleport, `moved`, `sneakToggled`, `used` with `ToolUse`, `blockChanging` with `BlockChange.Cause` and `BlockChange.changed`, `containerChanged` for a closed container inventory or a furnace or brewing stand that started, `command`, `chunkLoaded`, `closeRefusal`, `closing`, `closed`), `com.volmit.geometry.ChunkPos`; a tool world takes the pack's studio slot, so the host asks `closeRefusal` before it closes the world for another studio, the studio close command or a server stop, and waits for `closing` when another studio replaces it; every Y is the world's own; implemented by each platform adapter (Bukkit; modded adapters answer with a failed `open`) | +| Commands of a module | `com.volmit.tooling`: `ToolingRegistry.registerCommand`, immutable `Command` (`named`, `alias`, `describe`, `child`, `argument`, `runs`, `openToEveryone`), typed `Argument` (`word`, `text`, `integer`, `decimal`, `flag`, `choice`, `resource`, `registered`, `reading` with `Argument.Reader`, `orElse`, `suggesting`), `CommandAction`, `CommandContext` (`get`, `sender`, `pack`, `world`, `platform`, `platformStructures`), plain-text `Sender` (with `player()`), `PlatformStructures` (`templates`, `template` answering `StructureTemplate`, `structures`, `structureSets`, `jigsaw` answering `JigsawStructureInfo`, `pool` answering `TemplatePool` with `Member`, `Element`, `ConnectorSource`, `Connectors` and `JigsawConnector`, `supportsCapture`, `openCaptureArea` answering a closable `CaptureArea` whose `capture` answers `CapturedStructure`; `TemplateBlock`; readers throw `StructureAccessException`), `ToolPack` (`edit` with `PackEdit`, `outputFolder`, `objects` with `ObjectCodec`, `worlds`, `services`), host `CommandRegistration` in `FeatureCatalog.commands()` | +| Worlds a tool opens | `com.volmit.tooling.world`, exposed to pack modules by host `ExposedPackages`: `ToolWorlds` (`open`, `find`) with `ToolWorldSpec`, `ChunkPainter` and `ChunkCanvas`, `ToolWorld` (`players`, `owns`, `run`, `call`, `block`, `blockEntity`, `setBlock`, `loaded`, `repaint`, `close`), `ToolPlayer` (`targetBlock`, `teleport`, `creative`, `message`, `actionBar`, `sound`, `sidebar`, `particles`, `give` answering whether the item fitted, `held`, `openMenu`), `ToolWorldDenied` (what `open` completes with when the host refuses for a reason the user can fix; a tool reports the message and logs no stack trace), `ToolText` with `TextColor` (styled text, spans in a colour with bold, italic and strikethrough: item names and lore, menu titles, sidebar, chat and action bar; the host shows each span in its colour and style, an empty sidebar title keeps the platform's, and an item read back has plain text), `ToolItem`, `ToolMenu` with `MenuButton` and `MenuClick`, `Particle`, `ToolWorldListener` (`entered`, `left`, `teleported` for every arrival other than walking, at the time of the teleport, `moved`, `sneakToggled`, `used` with `ToolUse`, `blockChanging` with `BlockChange.Cause` and `BlockChange.changed`, `containerChanged` for a closed container inventory or a furnace or brewing stand that started, `command`, `chunkLoaded`, `closeRefusal`, `closing`, `closed`), `com.volmit.geometry.ChunkPos`; a tool world takes the pack's studio slot, so the host asks `closeRefusal` before it closes the world for another studio, the studio close command or a server stop, and waits for `closing` when another studio replaces it; every Y is the world's own; implemented by each platform adapter (Bukkit; modded adapters answer with a failed `open`) | | Buffered placement writes | `PlacementRequest`, `PlacementAccess`, host-owned `PlacementEdit` | | Typed generation and persistent storage | `mantle` package | diff --git a/api/DESIGN.md b/api/DESIGN.md index fb1b3b79a..74c14ce5e 100644 --- a/api/DESIGN.md +++ b/api/DESIGN.md @@ -1137,7 +1137,7 @@ each world a state store and tells modules when worlds start and stop. seeds its existing worlds were generated with, and every other id by the specification. - **The running world.** `PackWorld.running()` is the world as it runs now, for services and lifecycle hooks, which have no chunk to ask: the layout over every column as a `TerrainSampler`, the settings at a column and of a biome as - `FeatureSettings`, the highest block now, the cave floors the mantle marked, the sky (time and weather), the platform's + `FeatureSettings`, the highest block now, the cave floors the mantle marked, the void the cave carver planned at a block (`carvedAt`), the sky (time and weather), the platform's loot tables and whether it is a debug world. It reuses the chunk vocabulary instead of a second one: Iris's built-ins read the same through a facade (`LiveWorld`, with its own `Level`, `BiomeKind` and `Sky`), now deleted. Empty for a tool's world, which nothing runs. Which biome a block "is in" (cave below the surface, else surface) stays a module @@ -1241,7 +1241,8 @@ from a sapling, which drops a block has. A module answers such questions through module reaches another module's service without a host extension. It returns the providers only, unscoped: the caller passes the world it holds, and the provider's log is the host's concern when the host calls it, not the caller's. `service(type)` for a `ONE` service is not repeated there, since `services(type).stream().findFirst()` says the same - and the api keeps one lookup. + and the api keeps one lookup. `PackResources.services(type)` is the same for code that holds only the resources (a + locator listing structures asks the modules that own the kinds), and is empty where the host cannot ask. - **Threading.** The host may call a provider from any thread, several at once. A provider that searches long (`StructureLocator.locate`) is called off the server's main thread. - **Loot, drops, entities, trees.** `Loot` (`ALL`) asks in two steps, which tables a container draws from and what a @@ -1316,11 +1317,11 @@ A module jar sees three things besides the JDK and its own pack's jars, and noth question, and none hands out an engine. **The extension point.** A built-in reaches its facade through one door: `PackWorld.extension(type)` for what belongs to -a world (Iris's structure host), `InvocationContext.extension(type)` for what belongs to one invocation (the +a world, `InvocationContext.extension(type)` for what belongs to one invocation (the platform chunk Iris generates), and `PackSettings.extension(type)` for what is worked out from a pack's settings before any world exists (how far a feature reaches). Each returns an `Optional`, empty by default, so a host offers what it has and a module states what it requires: -`world.extension(StructureHost.class).orElseThrow()`. Why one door: +`world.extension(Facade.class).orElseThrow()`. Why one door: - **No thread-locals.** Facades used to be bound to the current thread (`IrisChunk.current()`, `ObjectPlacement.current()`), which only worked while the host's own code had bound them and broke silently on another thread. The context a stage @@ -1343,7 +1344,7 @@ Iris's own built-ins hold to this at compile time: IrisModule is a build of its `com.volmit:iris-api`, VolmLib, Gson and the JDK, never `iris-host` or Iris, and its jar passes `ModuleJarCheck` before Iris bundles it. Iris depends on IrisModule, not the reverse. What the built-ins cannot do through the API they ask through the facades of item 3, which Iris implements; the classes that need Iris itself (the layout model, the -structure placer behind `StructureHost`) are Iris's and live there. +placement service) are Iris's and live there. ### Iris extensions, with the reason each is not api yet @@ -1358,10 +1359,6 @@ API now: `world.running()`, `world.seed(purpose)`, `TerrainSampler`, `FeatureSet the placement's JSON. Iris still reads it when it places an object itself with the pack's rules: the jigsaw placer, the structure place commands and its tests (`ModuleObjectPlacement`). Pasting an object is not one of them: a paste writes the object's blocks turned by a fixed angle (`IrisObject.paste`). It goes when the structures move into their module. -- **`StructureHost`** (world). Iris's structure assembler, locator and placer, and the loot tables of a structure for the - loot of its pieces. The structure model (structures, pools, pieces) is `iris:structure`'s own resource kinds, which Iris - registers with its own modules because its jigsaw studio reads them. Its surface is already API vocabulary; it goes when - the placer can write through the API. - **Random parameters (`RNG`) in these facades and `loot.LootResolver`**. They are the legacy streams existing worlds were generated from. They go when a world format change lets them be stage streams. @@ -1443,6 +1440,19 @@ It exists so the tool lives in a module and runs on every platform: a tool that - **A platform may not have it.** `ToolWorlds.open` then returns a failed future and `Sender.player()` is empty, so a tool tells its user instead of failing at class loading. The package is exposed to pack modules, unlike the platform packages below `com.volmit.tooling`. +- **A refusal is not a fault.** `ToolWorldDenied` is how a host says no for a reason the user can fix (a pack with + blocking errors); a tool prints its message and logs nothing, so a mistake of the pack's author does not look like a bug + of the tool. +- **Answers a tool needs back.** `ToolPlayer.give` says whether the item fitted, because a menu that hands out a tool the + player never got would look like it worked; `targetBlock` exists because only the platform can ray-trace against the + blocks the player sees. `teleported` and `containerChanged` report what no `blockChanging` announces, so a tool that + protects an area hears every way in and every inventory that changed. +- **Importing a datapack is a service.** `DatapackStructureImport` (`FIRST`) lets the host, which installs datapacks and + knows nothing about jigsaw, hand the structures it found to whichever module turns them into pack resources. A pack + without a provider leaves them pending, like a retryable failure, and `DatapackImportReport.retryRequired` tells the + host which kind of failure it saw. +- **Reading a command word.** `Argument.reading` exists for a value that only the command's module can check, such as a + resource of a kind a neighbouring module registered; the built-in argument types cover what the host can check itself. ## Not implemented diff --git a/api/README.md b/api/README.md index 2c6fc1cf7..ae2318701 100644 --- a/api/README.md +++ b/api/README.md @@ -259,6 +259,9 @@ PackBiome dunes = resources.require(PackResources.BIOMES, resources.idOf("desert list, set or array of them, and studio completes the kind's keys. Packs write the key either way; a `ResourceId` field holds the pack's id of it. Built-in kinds may read into a class the host describes itself, as built-in settings may hold one. +- `PackResources.services(type)` gives the providers of a service that the pack's modules registered, for code that holds + only the resources, such as a locator listing structures. It asks the modules that own a kind what the kind means, as + `PackWorld.services` does; it is empty where the host cannot ask, and the list does not change for the snapshot. ``` Resource kind example:castle/keep of module example:castle from modules/castle.jar reads folder 'biomes', which the host reads itself; give the kind a folder of its own @@ -294,6 +297,9 @@ if (!outcome.isPlaced()) { `PlacementRecord`: the object's id, the module's number for this placement of it and, for a piece of a structure, the structure's id. A module may wrap the terrain to hold or filter writes; a mantle stage gets one for its invocation from `MantleGenerationContext.placementTerrain()`. +- `clearBlock(x, y, z)` takes a block a placement wrote back, so the terrain shows through; the block entity, placement + record and markers kept beside it stay until `clearAttached(x, y, z)` takes them back, whether or not a block is still + written there. A terrain that cannot take them back throws `UnsupportedOperationException`. - `name` labels the placement (the object's key). `settings` is the placement as the pack wrote it, a JSON object: the host reads from it the settings other modules declare at `Level.PLACEMENT`, so their stages see them like those of any other level. The module that owns the placement type declares it once in `setup`, with the JSON names of its own @@ -464,7 +470,9 @@ final class RuinsObjects implements ObjectsAt { values in what they return are `Optional`s. - A service that answers about the world as it runs, outside any chunk, reads `world.running()`: the layout over every column (`layout()`, a `TerrainSampler`), the settings at a column and what a biome declares (`settings()`), the - highest block now, the cave floors the mantle marked, the time and weather (`sky()`, empty until the platform has + highest block now, the cave floors the mantle marked, the void the cave carver planned at a block (`carvedAt`, in + heights above the bottom; empty where none was, when the chunk keeps no generation data any more and on a platform + that cannot read it), the time and weather (`sky()`, empty until the platform has the world), the platform's loot tables and whether the world is a debug (studio) world. It is empty for a tool's world, which nothing runs. - Each service says how several providers combine, with `@Service(Providers.X)`: `ALL` (the host asks every provider @@ -488,6 +496,7 @@ final class RuinsObjects implements ObjectsAt { | `ProtectedFloor` | `ONE` | Whether the lowest layer of the world (height 0) belongs to the module that shapes the terrain, such as a bedrock floor it writes itself. The host then discards the blocks other placements and stages write there. Asked once per world; no provider protects nothing. | | `AmbientEffects` | `ALL` | The effects due for a player standing at a position: a `Sound`, `Particles`, `Command`s and a `Potion` per `Effect`, every random choice already made (offsets, scatter, duration). The host asks now and then, carries out the parts the platform has, and keeps a stronger potion effect the player already has. | | `VanillaStructures` | `ALL` | Rules, starts, shifts and reaches for the platform's own structures, fitting the terrain to the starts in one chunk through the `BlockAccess` the host hands over, and finding the starts a module makes of them (see Vanilla structures). | +| `DatapackStructureImport` | `FIRST` | Turns the structures and templates a datapack brought into editable resources of the pack once the host installed it (`importAll`, answering a `DatapackImportReport` of imported, skipped and failed sources, the bundles that landed and whether a failure may pass on a retry). Re-importing a source replaces what an earlier import made of it; with no provider the host leaves the datapack's structures pending. | | `VanillaFeatures` | `ALL` | Whether the platform runs its own placed features (ores, trees, plants, springs) over a world's terrain, and which decoration steps (`DecorationStep`) and features it skips there. Off unless a module turns it on; any module may refuse a step or a feature. Asked once per world, step and feature. | ``` @@ -562,6 +571,9 @@ private void info(CommandContext context) { constant written in lower case with `-`), `resource` (an id of a `ResourceKind` in the pack) and `registered` (an id in one of the platform's registries, by `Reference`). `orElse` makes an argument optional; an optional argument may not come before a required one. `suggesting` adds completions. Read a value with `context.get(argument)`. + `Argument.reading(name, reader)` takes one word and turns it into any value with a `Reader`, which throws + `IllegalArgumentException` saying why it cannot, for a value only the command's module can check, such as a resource of + a kind its neighbour registers; it completes nothing until `suggesting` gives it candidates. - The host resolves the pack before it parses the line: `pack=` taken out of the arguments, else the pack of the sender's world, else the pack of the sender's open studio, else it fails with `Name a pack: pack=`. A command exists only for packs whose jars contain its module. `context.pack()` is that pack, `context.world()` the sender's @@ -584,7 +596,9 @@ private void info(CommandContext context) { loadable templates (`templates`, `template`, `structures`, `structureSets`), reads a registered jigsaw structure and a template pool (`jigsaw` answering `JigsawStructureInfo`, `pool` answering `TemplatePool` with its members, fallback and the connectors of each element), and generates structures that have no template in a throwaway area - (`supportsCapture`, `openCaptureArea`). A template or a captured structure is a list of `TemplateBlock` with + (`supportsCapture`, `openCaptureArea`: a closable `CaptureArea` places one structure after another in a scratch area + and `capture(structure, seed, maxSpan)` reads each back, empty when the box is wider or taller than `maxSpan`, and + `close` removes the area). A template or a captured structure is a list of `TemplateBlock` with `BlockState` and `BlockEntityData`. A reader throws `StructureAccessException` when the platform's registries cannot be read, and says whether asking again may help. @@ -593,6 +607,8 @@ private void info(CommandContext context) { A tool that shows or edits what it builds in a world, such as a jigsaw studio, opens a tool world through `ToolPack.worlds()`, in `com.volmit.tooling.world`. The package is neutral, so the same tool runs on every platform that implements it; a platform without tool worlds answers with a failed future. +A host that refuses to open a world for a reason the user or the pack's author can fix, such as a pack with blocking +errors, completes `open` with `ToolWorldDenied`; its message is for the user, so a tool reports it and logs no stack trace. ```java ToolWorlds worlds = context.pack().worlds(); @@ -629,7 +645,8 @@ worlds.open(new ToolWorldSpec("scratch", painter, new ToolWorldListener() { })) changing methods are safe from any thread. - `ToolPlayer` also gives items (`ToolItem`, whose payload the host keeps on the item), a chest-style menu (`ToolMenu` of `MenuButton`s), chat messages, an action bar, a sidebar, sounds and dust `Particle`s. `give` answers whether the item - fitted; one that did not is neither given nor dropped. `ToolWorld.close()` sends every player back to where they came + fitted; one that did not is neither given nor dropped. `targetBlock(maxDistance)` is the block the player looks at, + fluids not counting. `ToolWorld.close()` sends every player back to where they came from and deletes the world. - Styled text is `ToolText`, a list of spans with a `TextColor` (the sixteen named colours; none keeps the platform's default) and bold, italic and strikethrough. Build it with `ToolText.builder().gray("Size: ").white("16x16x16").build()` @@ -940,6 +957,8 @@ Every method has a default that changes nothing, so a provider implements only w structure, `JigsawOverrides` for jigsaw structures and a `StartMemo`. 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. + `VanillaStructureContext.world()` is the world a rule decides for, empty when the host asks before any world exists, + such as for the setup of a dimension; a rule that needs the world answers its default then. - `shift(start, context)`: how many blocks one of the platform's own starts moves up or down before the host publishes it. A `PlatformStart` gives its bounds, whether the platform generates it underground, whether the host aligns it itself (ocean monuments to the sea, desert and jungle temples to the terrain; a shift then applies on top), diff --git a/module/README.md b/module/README.md index 111f9cbe8..926f1e29f 100644 --- a/module/README.md +++ b/module/README.md @@ -29,24 +29,24 @@ service or hook, `setup.log()` during setup), which labels each line with the mo use `IrisLogging`. Classes of the host's object model (the host-classes list) and code that only has an engine or pack data still log as Iris itself. -Modules also own pack resources and checks of their own. `iris:structure` (`StructureModule`) reads structures, jigsaw -pools and jigsaw pieces as resource kinds (`StructureResources`, `iris:structure/structure`, `/pool`, `/piece`), from the -folders and files packs have always used, and declares the structure placement settings and the mantle stage. Its -definitions (`IrisStructure`, `IrisJigsawPiece`, `IrisJigsawPool` and their parts in `engine/object/structure`) live -here and build against the API. It is not in the built-ins jar: Iris registers it with its own modules, because Iris's -jigsaw studio, importers and exporters read the structures it registers as the same classes, which a jar's own copy of -a class is not. Iris's own module `iris:structure-model` (core `StructureModelModule`) checks them with its validator -(`StructureValidator`: assembly samples and vanilla structure replacement) wherever Iris validates a pack. The -assembler, locator, fitting and placing are still Iris's, and `iris:structure` places through the `StructureHost` -facade (`art.arcane.iris.builtin.structure`). +Structures are two modules of the built-ins jar. `iris:structure` (`StructureModule`) is where structures go and how they +meet the terrain: it declares the structure placement settings and the mantle stage, validates the placements +(`StructureValidator`), provides `StructureLocator` and `VanillaStructures`, and brings the `/iris module structure` +commands. It gets the pieces of a structure only from the `StructureAssembly` providers of the pack's modules and knows +none of them. `iris:jigsaw` (`JigsawModule`) is what a structure is made of: it reads structures, jigsaw pools and jigsaw +pieces as resource kinds (`StructureResources`, from the folders and files packs have always used), validates them +(`JigsawValidator`), provides `StructureAssembly` (`JigsawStructureAssembly`), and brings the tools that make them: the +importers of the platform's structures and of a datapack's (`DatapackStructureImport`) and the `/iris module jigsaw` +commands with the in-world Jigsaw Studio. The studio runs only on IrisApi's tool world api and `PlatformStructures`, so +it runs on every platform that implements them. Built-in modules answer Iris through IrisApi services instead of Iris reading their features: `iris:objects` -provides `ObjectsAt` (the objects a chunk would get, for the object search and studio tools) and `iris:structure-model` +provides `ObjectsAt` (the objects a chunk would get, for the object search and studio tools) and `iris:structure` provides `StructureLocator` (`StructureLocating`: the pack's structure keys for Iris's structure index, the ones a world places, and their nearest start for the find commands). A world's structure index lives in the world's state (`engine.getGeneration().state(...)`), so every reload of the pack's structure files, which starts a new world, builds it again. -`iris:structure-model` also provides `VanillaStructures` (`StructureVanillaStructures`) for the platform's own structures: +`iris:structure` also provides `VanillaStructures` (`StructureVanillaStructures`) for the platform's own structures: which ones its placements replace or the dimension's `importedStructures` disables, the starts its `nativeStructures` placements make (`startedStructures`, `locatableStarts`, `locateStart`), the shift and band of the platform's starts, and the whole terrain fit of every start (SOURCE, PRESERVE, VACUUM, ENCASE, BORE, FORCE_CARVE, stilts) in `engine/framework/structure/fit`, written against IrisApi's @@ -164,9 +164,8 @@ compiled these sources itself. Iris includes this build (`includeBuild('module')` in its `settings.gradle`) and depends on its classes: Iris core and its adapters still name many of them (the cut-over that ends this comes later). Classes that need Iris itself are Iris's and live in Iris core: the layout model (`IrisBiome`, `IrisRegion`, `IrisDimension`, generators, noise -styles, expressions, images), the pack's objects and blocks, the structure assembler, locator, fitting and placer -(behind `StructureHost`), and the placement service behind `PackWorld.placements()`. A module this build holds -but the jar does not, such as `iris:structure`, is one Iris registers with its own modules (`IrisModuleHost`): its +styles, expressions, images), the pack's objects and blocks, and the placement service behind `PackWorld.placements()`. +A module this build holds but the jar does not is one Iris registers with its own modules (`IrisModuleHost`): its classes are then the ones Iris's own code sees. `./gradlew check` compiles every source and builds the built-ins jar below, which runs the pack class checks. @@ -187,7 +186,7 @@ packages fails the task naming the class and what it uses. Iris checks the jar o VolmLib classes its Bukkit jar strips (`core/volmlib-left-out-of-bukkit-jar.txt`), which only Iris knows. The jar holds `iris:post`, `iris:perfection`, `iris:matter`, `iris:loot`, `iris:spawn`, `iris:vanilla-features` and -`iris:carve`, and the object placement stages `iris:prepare`, `iris:anchor`, `iris:validate`, `iris:bore`, `iris:blocks`, `iris:stilt`, `iris:vacuum` and `iris:snow`. They are +`iris:carve`, `iris:structure`, `iris:jigsaw`, and the object placement stages `iris:prepare`, `iris:anchor`, `iris:validate`, `iris:bore`, `iris:blocks`, `iris:stilt`, `iris:vacuum` and `iris:snow`. They are written against IrisApi and `art.arcane.iris.builtin` alone: the chunk's `BlockState` hunk, the block registry's traits and `canPlaceOn`, the terrain sampler (heights around the chunk, slope, fluid height, where the upper dimension begins) and the mantle's planned blocks; the placement stages read the placement being run through the `ObjectPlacement` facade, and the loot and @@ -201,7 +200,7 @@ none of the jar's modules (`IrisModuleHost.JAR_MODULE_IDS`, which a test keeps e `art.arcane.iris.builtin` also holds what the compiled-in built-ins and the jar must share, because each sees its own copy of every other class. The facades among them are interfaces Iris implements and offers through IrisApi's extension point, never -through the thread or a cast: a module asks `world.extension(X.class)` for what belongs to a world (`StructureHost`), +through the thread or a cast: a module asks `world.extension(X.class)` for what belongs to a world, `context.extension(X.class)` for what belongs to one invocation (`IrisChunk` in a chunk stage, `IrisMantleChunk` in a mantle stage) and `settings.extension(X.class)` for a reach worked out before any world exists, each with `.orElseThrow()`, since a built-in runs only where Iris offers them. Iris's per-feature world seeds are