From 2fa109026c48bcce1841606b409d297355d8b48e Mon Sep 17 00:00:00 2001 From: Paula Date: Sun, 15 Nov 2026 16:49:13 -0300 Subject: [PATCH] Structures plan --- STRUCTURES.md | 941 +++++--------------------------------------------- deno.json | 1 + deno.lock | 18 +- 3 files changed, 99 insertions(+), 861 deletions(-) diff --git a/STRUCTURES.md b/STRUCTURES.md index 3e763f9..d9752e2 100644 --- a/STRUCTURES.md +++ b/STRUCTURES.md @@ -1,891 +1,116 @@ -# Structures and Features +# Structures -A plan for generating structures (villages, ruins, towers) and data-driven features (fossils, boulders, springs) in -bworld, in bworld's data style, while reading Minecraft Java's datapack formats closely enough that datapacks and mods -like [Trek](ports/trek) can be imported with a tool instead of rewritten. +## Schematics -Nothing here is built yet. Numbers about Trek come from reading every file in `ports/trek`. +Schematics are pre-defined block patterns to be placed somewhere in the world -## Where We Are +### Schematic format -What world generation has today (see [World Generation](docs/modding/worldgen/index.md)): +Schematics are json data, encoded and decoded with MessagePack (@std/msgpack), they are saved in .cbsm files -- **The server generates every chunk** (`server/game/world.ts`, `common/generation.ts`). Players only get finished - chunks, so generation code and data never have to reach clients. -- **Three passes per chunk:** terrain (data, see [terrain.md](docs/modding/worldgen/terrain.md)), then ores - (`worldgen/ores.json`), then features, code or data, by step. The base game's trees are a code feature in - `vegetal_decoration`. -- **Chunks generate alone.** A feature may write up to one chunk away. Those writes are "spills" that only fill air in - the neighbor, so the result doesn't depend on which chunk generates first. -- **Determinism matters at chunk borders.** Every chunk generated is saved whole, like Minecraft, so a change to - generation only shows in chunks never generated before. A chunk generated next to a saved one still takes the saved - one's spills from generation, so features cross the border the same way only when generation hasn't changed. -- **Heights and biomes for any column**, without generating its chunk: `NoiseTerrain.column` and `estimate_biome`. The - biome is exact away from coasts and cliffs. The height is the height before 3D noise, so it isn't the real surface. -- **Blocks:** numeric states (up to 16 bits), `variants`, `parts`, shapes, tile data, containers, components and shared - rules. Tags exist for blocks, items and entities. Biomes are a registry of data (`worldgen/biomes/` in a mod), but - which one a column gets is data too, a biome source's rules (see [biomes.md](docs/modding/worldgen/biomes.md)). -- **Loot:** a block's `drops` is one item id. There are no loot tables. +On the schematic the objects have `i`, `s` and `p` keys, these correspond to `index`, `state` and `position`, they are +shorten to save on bytes on msgpack -What's missing for structures: +The data on palette.palette[number].data is from BlockComponent.export_data -- anything planned before blocks exist, or that spans more than three chunks; -- a block template format, and turning blocks when a piece is turned; -- terrain shaped around what's placed on it; -- a way to read Minecraft's content: NBT, `minecraft:` ids, string block states. - -## Features and Structures - -The same split as Minecraft's. A **feature** is a small thing placed while a chunk is decorated, like a boulder, a -spring or a fossil. It's decided from that chunk alone and forgotten once it's written. A **structure** is planned -before any block exists: a grid picks where structures start, the start is assembled into pieces with bounding boxes, -and every chunk a piece overlaps writes its own part of it. Structures can be large, made of many pieces, kept apart -from each other, and found again (`/locate`). - -The order a chunk generates in becomes: - -``` -1. structure starts which structures overlap this chunk, assembled into pieces (cached, never saved) -2. terrain the overworld, shaped around pieces that adapt the terrain -3. ores as now -4. structures each overlapping piece writes the blocks inside this chunk, by step -5. features data features and script features, by step -``` - -Steps order structures and features the way Minecraft's decoration steps do, so a village is placed before trees and -flowers decorate around it: `raw_generation`, `lakes`, `local_modifications`, `underground_structures`, -`surface_structures`, `strongholds`, `underground_ores`, `underground_decoration`, `fluid_springs`, -`vegetal_decoration`, `top_layer_modification`. Script features from `register_feature` keep running last, as now. - -## Principles - -1. **bworld's data style.** Every JSON file has `format_version`, a wrapper key and an `id`, lives in a plural folder, - and is checked by `check-mods`. Inside the wrapper, fields keep **Minecraft's names and meanings**, so the Minecraft - Wiki's documentation applies, and importing a datapack is mostly renaming ids. -2. **Templates stay `.nbt`.** Minecraft's structure template format, unchanged. Templates can be built in Minecraft with - structure blocks and saved, read by existing NBT tools, and imported without converting them. -3. **One mapping from Minecraft to bworld, written once.** The base game ships what each `minecraft:` block, item, biome - and entity is in bworld. A template can keep vanilla ids in its palette and the mapping is applied when it loads, so - every imported pack gets better when a block is added to bworld. -4. **Deterministic, nothing saved.** Starts and pieces are recomputed from the seed whenever they're needed, like - everything else generation makes. No structure data goes into saves. -5. **Server only.** Templates, pools, structures, features and loot tables are server data, left out of the copy of a - `.cubi` players download, like worldgen scripts are now. The only thing clients need is the blocks. -6. **No goal of matching Minecraft's positions.** bworld's seeds and random numbers aren't Java's, and its terrain is - its own, so structures land in different places than in Minecraft with the same seed. What has to match is how pieces - fit together and what each field means. - -## Data Formats - -### Mod Folders - -New folders, next to the ones a mod has now (see [Mod Files](docs/modding/gettingstarted/modfiles.md)): - -``` -copper_tools/ - structures/.nbt # templates, Minecraft's structure format - worldgen/structures/.json # what a structure is: its start pool, size, biomes, terrain adaptation - worldgen/structure_sets/.json # where structures start - worldgen/template_pools/.json # pieces to choose from - worldgen/processor_lists/.json # changes made to template blocks as they're placed - worldgen/features/.json # data features: what, where, which biomes - loot_tables/.json # what chests from templates are filled with - tags/biomes//.json # biome tags, like tags/blocks - remaps/.json # what another game's ids are here, in the base game: remaps/minecraft.json -``` - -Ids are the mod's namespace and the path, like `trek:village/plains/town_centers`. Paths can have folders, as in -Minecraft. Templates take their id from their path (`structures/ruins/ruin_1.nbt` is `copper_tools:ruins/ruin_1`). JSON -files also state it in `id`, and `check-mods` checks that it matches the path. - -`check-mods` checks every reference: pools, templates, processor lists, structures, sets, loot tables, tags, blocks and -biomes. Missing references are errors, except the ones in an import's report (see [The Importer](#the-importer)). - -### Named State Values - -Blocks' states get optional value names, in Minecraft's order: - -```json -"states": [ - { "name": "facing", "bits": 2, "default": 0, "values": ["north", "east", "south", "west"] }, - { "name": "half", "bits": 1, "default": 0, "values": ["bottom", "top"] }, - { "name": "shape", "bits": 3, "default": 0, "values": ["straight", "inner_left", "inner_right", "outer_left", "outer_right"] } -] -``` - -- `bits` can be left out when `values` is given: it's the fewest bits that fit them. -- Variant and part conditions can use names: `"facing=east,half=top"`, the same as `"facing=1,half=1"`. -- Existing blocks keep working unchanged. The base game's blocks get names that match Minecraft's (trapdoors and fences - already use Minecraft's state names and orders). -- Named values are what the remap and turning below are built on. - -### Turning Blocks - -Jigsaw turns pieces by 90, 180 or 270 degrees, so every block's states have to turn with the piece, like Minecraft's -`BlockState.rotate`. With named values, turning works out from the names: - -| State | Turned clockwise by 90° | -| ------------------------------------------------------ | ------------------------------------------------------------- | -| values are directions (`north`, `east`, `south`, ...) | each value turns: `north` → `east`, `up` stays `up` | -| values are `x`, `y`, `z` (`axis`) | `x` ↔ `z` | -| the state's name is a direction (`north`, `east`, ...) | values move between states: `north=1` becomes `east=1` | -| `rotation` with 16 values (signs, banners, heads) | +4 | -| anything else (`half`, `open`, `shape` of stairs) | unchanged, like Minecraft (a stair's shape is relative to it) | - -Odd cases, like rails' `shape` (`north_south` ↔ `east_west`, `ascending_east` → `ascending_south`), name their turns -explicitly: - -```json -{ - "name": "shape", - "values": ["north_south", "east_west", "ascending_east", "..."], - "turns": { "north_south": "east_west", "...": "..." } -} -``` - -Mirroring (Minecraft's `Mirror`) uses the same rules plus `left` ↔ `right` in values. Jigsaw never mirrors, so it can -wait. - -Unit tests turn a few of each kind four times and check they're back where they started, and that turning a fence -connected north and east gives one connected east and south. - -### Remaps - -What another game's ids are in bworld. The base game ships `mods/bworld/remaps/minecraft.json`; any mod can add one for -its own blocks, like Trek's, or for another mod's namespace, like `remaps/waystones.json`. +Example: ```json { "format_version": 1, - "remap": { - "namespace": "minecraft", - "blocks": { - "grass_block": "bworld:grass", - "farmland": "bworld:hoed_dirt", - "snow_block": "bworld:snow_block", - "spruce_stairs": "bworld:spruce_stairs", - "chest": { "id": "bworld:chest", "states": { "facing": "facing" } }, - "oak_wall_sign": { - "id": "bworld:oak_sign", - "states": { "facing": "facing" }, - "set": { "on_wall": "true" } - }, - "short_grass": "bworld:short_grass", - "grass": "bworld:short_grass", - "structure_void": null - }, - "items": { "wheat_seeds": "bworld:wheat_seeds" }, - "biomes": { - "plains": "bworld:plains", - "sunflower_plains": "bworld:plains", - "old_growth_pine_taiga": "bworld:taiga" - }, - "entities": { "chicken": "bworld:chicken" }, - "block_tags": { "features_cannot_replace": "#bworld:features_cannot_replace" } - } -} -``` - -- A string maps to that id, carrying over every state whose name and value names match. That's most blocks once their - states are named like Minecraft's. -- `{ id, states, set }` renames states and sets fixed ones. Properties bworld doesn't model (`waterlogged`, `powered`) - are dropped. -- `null` means known, and nothing there. Ids not in the map at all are reported as unmapped and, while generating, - treated as nothing: the template keeps whatever the world had in that spot. -- Old and new names both go in, since templates from different Minecraft versions use both. Trek's templates were saved - by 1.19 to 1.21 (DataVersion 3105 to 3953), so `grass` and `short_grass` both appear. -- Remaps apply when data loads: to template palettes, and to ids in processor lists, pools, loot tables and tags that - still use a `minecraft:` id. The engine only ever deals with bworld ids. - -### Templates - -`.nbt` files exactly as Minecraft saves them (gzipped, big endian): - -``` -{ DataVersion, size: [x, y, z], palette: [{ Name, Properties }], blocks: [{ pos, state, nbt? }], entities: [{ pos, blockPos, nbt }] } -``` - -`palettes` (several palettes, one picked at random) is read too. Meanings that matter: - -- **A position missing from `blocks` keeps what the world has there** (Minecraft's structure void). Air in `blocks` - clears what was there, except in `legacy_single_pool_element` pieces, which skip air. -- **`nbt` is a block entity:** - - `minecraft:chest` and `minecraft:barrel` with `LootTable` become tile data that fills the container the first time - it's opened. - - `minecraft:jigsaw` holds `name`, `target`, `pool`, `joint` and `final_state`, used by assembly. - - Anything else (signs, spawners, banners) is ignored until bworld has a use for it. -- **`entities`** are spawned the first time their chunk is generated, mapped through the remap. Unmapped ones are - skipped. - -An NBT reader (`common/nbt.ts`) is about 60 lines. Templates are parsed once and kept as the remapped palette and -compact arrays: positions and palette indexes as typed arrays, block entities in a map. They're packed into `.cubi` -files as they are, like textures, and only the server copy keeps them. - -### Processor Lists - -```json -{ - "format_version": 1, - "processor_list": { - "id": "trek:stone/mossify_20", - "processors": [{ - "processor_type": "minecraft:rule", - "rules": [{ - "location_predicate": { "predicate_type": "minecraft:always_true" }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "minecraft:stone_bricks", - "probability": 0.2 - }, - "output_state": { "Name": "minecraft:mossy_stone_bricks" } - }] - }] - } -} -``` - -One of the two rules in Trek's `stone/mossify_20`, as imported: its `minecraft:` ids stay as they are and the remap -turns them into `bworld:stone_bricks` and `bworld:mossy_stone_bricks` when it loads. - -What Trek uses, which is the first set to support: - -- **`rule`**, with input and location predicates `always_true`, `block_match`, `blockstate_match`, `random_block_match`, - `random_blockstate_match` and `tag_match`, and position predicates `linear_pos` and `axis_aligned_linear_pos`. The - output is `output_state` (`{ Name, Properties }`, remapped like palettes). -- **`protected_blocks`**: never replace blocks in a tag. - -Random predicates are seeded from the block's world position and the world's seed, so a block always comes out the same -whichever chunk places it. `minecraft:empty` is a list with no processors. Processor types are open: worldgen scripts -can register more with `register_processor`. - -### Template Pools - -```json -{ - "format_version": 1, - "template_pool": { - "id": "trek:village/plains/town_centers", - "fallback": "minecraft:empty", - "elements": [ + "schematic": { + "id": "bworld:my_schematic", + "size": [2, 2, 1], + "palette": [ + { "id": "bworld:stone" }, + { "id": "bworld:dirt" }, { - "weight": 49, - "element": { - "element_type": "minecraft:single_pool_element", - "location": "trek:village/plains/town_centers/plains_market_1", - "processors": "minecraft:empty", - "projection": "rigid" - } + "id": "bworld:furnace", + "s": { "facing": 1 } + } + ], + "blocks": [ + { + "i": 0, + "p": [0, 0, 0] + }, + { + "i": 1, + "p": [1, 0, 0] + }, + { + "i": 2, + "p": [1, 1, 0], + "data": { "items": [] } + } + ], + "entities": [ + { + "p": [0.5, 1.0, 0.5], + "id": "bworld:chicken", + "data": {} } ] } } ``` -Element types: `single_pool_element`, `legacy_single_pool_element` (skips the template's air), `list_pool_element` -(several elements in the same spot), `feature_pool_element` (a data feature at the jigsaw's position) and -`empty_pool_element`. `projection` is `rigid` (placed as built) or `terrain_matching` (each column follows the ground, -for paths). Element types keep their `minecraft:` names: they're types, not content, so remaps don't apply to them. +Schematics will come from the schematics directory inside mods or through ctx.schematics.register() function -### Structures +## Block data serialization -```json -{ - "format_version": 1, - "structure": { - "id": "trek:overworld/very_common/rocks", - "type": "minecraft:jigsaw", - "biomes": "#trek:combination/plains_forest_desert_no_snow_jungle", - "start_pool": "trek:overworld/very_common/rocks", - "size": 1, - "start_height": { "absolute": 0 }, - "project_start_to_heightmap": "WORLD_SURFACE_WG", - "max_distance_from_center": 64, - "terrain_adaptation": "none", - "step": "surface_structures" - } -} +BlockComponent will have new methods: + +```typescript +// the block's data as it's kept outside the world, with its containers' items written in +export_data?(block: BlockRef, params: P): unknown; +// the other way, for a block placed from a structure: creates its containers from those items +import_data?(block: BlockRef, params: P, data: unknown): void; ``` -- `type` is `minecraft:jigsaw` for now. Other types, like Undergarden's `bigger_jigsaw` (jigsaw with a higher `size` - limit), map onto it with different limits. Mods can register types written in code from a worldgen script with - `register_structure_type`, for structures made in code instead of from templates. -- `size` is how many connections deep assembly goes. Minecraft allows up to 20. -- `project_start_to_heightmap` is `WORLD_SURFACE_WG` (the surface, or the water's surface) or `OCEAN_FLOOR_WG` (the - ground under water). -- `terrain_adaptation` is `none`, `beard_thin`, `beard_box`, `bury` or `encapsulate`. See - [Terrain Adaptation](#terrain-adaptation). -- `spawn_overrides` replaces which mobs spawn inside the structure. It can wait until natural spawning reads it. +Blocks without the hooks just copy data unchanged, which is fine for plain fields. -### Structure Sets +### Placing schematics -```json -{ - "format_version": 1, - "structure_set": { - "id": "trek:overworld/medium", - "structures": [{ "structure": "trek:overworld/medium/oasis", "weight": 1 }], - "placement": { - "type": "minecraft:random_spread", - "spacing": 30, - "separation": 12, - "spread_type": "linear", - "salt": 98700002, - "frequency": 1, - "exclusion_zone": { "chunk_count": 6, "other_set": "trek:village" } - } - } -} +```typescript +ctx.schematics.place(id, { position, dimension, position_pivot, rotation, mirror }); ``` -**`random_spread`:** the world is split into cells of `spacing` × `spacing` chunks. Each cell has at most one start, in -a chunk picked inside its first `spacing - separation` chunks on each axis. `linear` picks evenly, `triangular` leans -towards the middle. The random generator is seeded from the world's seed, the set's id, `salt` and the cell, so sets -don't move each other, and any chunk can find the starts near it without generating anything. Then: +### Rotation and mirroring -1. `frequency` skips some starts. -2. One of `structures` is picked by weight. A structure whose biome check fails is removed and another is picked, as in - Minecraft. -3. The start is skipped if a start of `exclusion_zone.other_set` is within `chunk_count` chunks. +- `rotation` is `0`, `90`, `180` or `270` degrees clockwise seen from above, the same as the `"y"` of a block variant +- `mirror` is `"x"` or `"z"`, the axis that gets flipped, or left out for none +- the mirror is applied first, then the rotation, both around `position_pivot` -**`concentric_rings`** (strongholds) comes later. Trek only uses it to change vanilla's strongholds. +Positions, relative to the pivot: -### Data Features +- mirror `"x"`: `x` becomes `-x` +- mirror `"z"`: `z` becomes `-z` +- each 90 degrees: `[x, z]` becomes `[-z, x]` -Minecraft splits a feature into a configured feature (what) and a placed feature (where), and adds features to biomes in -the biome's own file (NeoForge adds biome modifiers so mods can add to biomes they don't own). bworld's biomes aren't -data, so a feature says where it goes itself, in one file: +The only state that changes is one named `facing`, the standard one. Its values are always `0` north, `1` east, `2` +south, `3` west, then `4` up and `5` down for a 3 bit one (see `FACINGS` in `common/block_rules.ts` and the importer's +`ORDERS`): -```json -{ - "format_version": 1, - "feature": { - "id": "trek:monster_room/upper/default", - "type": "minecraft:fossil", - "config": { - "max_empty_corners_allowed": 4, - "fossil_structures": ["trek:monster_room/default"], - "overlay_structures": ["trek:monster_room/empty"], - "fossil_processors": "trek:monster_room/upper/default", - "overlay_processors": "minecraft:empty" - }, - "placement": [ - { "type": "minecraft:count", "count": 10 }, - { "type": "minecraft:rarity_filter", "chance": 800 }, - { "type": "minecraft:in_square" }, - { - "type": "minecraft:height_range", - "height": { - "type": "minecraft:very_biased_to_bottom", - "min_inclusive": { "absolute": 24 }, - "max_inclusive": { "below_top": 0 }, - "inner": 10 - } - } - ], - "biomes": "#bworld:is_overworld", - "step": "underground_structures" - } -} +- mirror `"x"` swaps east and west (`1` and `3`) +- mirror `"z"` swaps north and south (`0` and `2`) +- each 90 degrees adds 1 to a value under 4, wrapping around (`(facing + 1) % 4`) +- up and down never change + +Every other state (`axis`, door hinges, stair shapes) is copied as it is, so those blocks can come out wrong in a turned +or mirrored schematic. A hook for them can come later if it's needed. + +Entities get their position turned the same way as blocks, and their yaw with it (yaw 0 looks north, east is `-π/2`): + +- mirror `"x"`: `yaw` becomes `-yaw` +- mirror `"z"`: `yaw` becomes `π - yaw` +- each 90 degrees: `yaw` becomes `yaw - π/2` + +### Saving schematics + +```typescript +ctx.schematics.export(dimension, from, to); // saves the schematic file to a temporary directory and prints the location on the chat for the player ``` -That's Trek's `monster_room/upper/default`, its configured and placed feature joined, with `biomes` and `step` added. - -- Height providers (in `height_range` and structures' `start_height`): `constant` (and a bare `{ "absolute": y }`), - `uniform`, `trapezoid`, `biased_to_bottom` and `very_biased_to_bottom`. Heights are `absolute`, `above_bottom` or - `below_top`. -- `type` and `config` are Minecraft's configured feature. `placement` is Minecraft's placed feature modifiers: `count`, - `rarity_filter`, `in_square`, `height_range`, `heightmap`, `biome`, `surface_relative_threshold_filter`, - `block_predicate_filter`. -- First feature types, from what Trek uses: `fossil` (a template, which covers Trek's monster rooms), `simple_block`, - `block_column`, `disk` and `spring_feature`, and `ore` and `random_patch` for the base game. Its trees stay code. The - format, `simple_block`, `block_column`, the first placement modifiers and `register_feature_type` are built already, - see [Data Features](docs/modding/worldgen/index.md#data-features). -- Worldgen scripts register more types with `register_feature_type(id, (chunk, config, origin) => ...)`, so a data - feature can use a type a mod wrote in code. `register_feature` stays for features that are only code. -- **Features that reach into other chunks are evaluated from each chunk they touch.** Where a feature starts is decided - from its own chunk's random numbers and heights, which neighbors can recompute. A template feature like a fossil then - writes its part in each chunk like a structure piece does. That lifts the "spills only fill air" limit for everything - placed from templates. Placement that needs to read a neighbor's blocks (not just heights) stays limited to its own - chunk. - -### Biome Tags - -`tags/biomes//.json`, like block tags, with `"biomes"` as a tag registry in `ctx.tags`. The base game -ships tags for its biomes under Minecraft's names (`#bworld:is_forest`, `#bworld:is_ocean`, -`#bworld:has_structure/...`), and `remaps/minecraft.json` maps `#minecraft:is_forest` to them, so imported structures -that use vanilla's biome tags work. A biome id or tag in a structure that maps to nothing is reported, and that -structure never generates. - -### Loot Tables - -A subset of Minecraft's format: `pools` with `rolls` (a number or `{ min, max }`), entries of type `item`, `tag`, -`loot_table` and `empty` with `weight`, and the functions `set_count` and `set_damage`, enough for chest loot. Item ids -are remapped. Missing items are skipped and reported. - -A chest placed from a template keeps `{ loot_table, loot_seed }` in its tile data. `bworld:storage` fills the container -the first time it's opened, then forgets the table, like Minecraft. The roll is seeded by `loot_seed`, so the same chest -always gets the same loot. The server API gets `ctx.loot.roll(id, seed)` for mods that want loot elsewhere. - -## Engine - -### Finding Starts - -`common/structures/starts.ts`: for a chunk, every start whose structure could reach it. A structure's reach is -`max_distance_from_center` plus its largest template, capped at 128 blocks like Minecraft's jigsaw, so each set checks -the cells within 8 chunks. That's cheap: it's random numbers, plus biome and height lookups at the few candidate starts. - -### Heights and Biomes Outside the Chunk - -Assembly needs the surface at columns in chunks that don't exist yet: at the start, and for every `terrain_matching` -piece. Add `surface_at(x, z)` to the overworld, the exact surface the terrain pass would make, found by sampling the -column's 3D density downward from its rough height. Same for `ocean_floor_at`. Biomes come from `estimate_biome`, made -exact where it isn't. These need to be fast and must never disagree with the terrain pass. A test compares them against -generated chunks for many columns. - -### Assembly - -`common/structures/jigsaw.ts`, following Minecraft's `JigsawPlacement`. This is the part to compare most carefully -against Minecraft's source (decompiled through a NeoForge workspace; `ports/neoforge` only has patches): - -1. Pick the start element from `start_pool` by weight, and a random rotation. Put it at the start chunk's corner, at - `start_height`, plus the surface at the middle of its box when `project_start_to_heightmap` is set. -2. Keep a queue of placed pieces with their depth, highest `placement_priority` first. For each piece, its jigsaw blocks - are shuffled, then sorted by `selection_priority`. -3. For a jigsaw block pointing out of its piece: the candidates are its pool's elements in weighted random order (or - only the `fallback` pool's at the last depth), each in its 4 rotations, in random order. An element connects when it - has a jigsaw that faces back towards this one, whose `name` is this one's `target`, and, for jigsaws facing up or - down with `aligned` joints, whose top points the same way. -4. The candidate's box must fit: inside the box `max_distance_from_center` around the start, and not overlapping placed - pieces. A jigsaw pointing into its own piece (like a house's door into its room) only has to fit inside that piece's - free space. `terrain_matching` candidates get the ground height at the jigsaw. -5. The first candidate that fits is placed and queued with depth + 1, if that's within `size`. An `empty` element ends - that jigsaw. -6. Jigsaw blocks become their `final_state` when placed. - -Everything random comes from one generator seeded by the world's seed and the start's chunk, so a start assembles the -same in any chunk that asks. The result is a list of pieces: element, position, rotation, box. Starts are kept in an LRU -cache in the world, since every chunk a start reaches asks for it. - -`use_expansion_hack` (Minecraft widening rigid villages' boxes for old templates) is read and ignored until something -looks wrong without it. - -### Placing a Piece - -`common/structures/place.ts`, for each piece box that overlaps the chunk: - -1. Go through the template's blocks inside the chunk, turned by the piece's rotation (position and states, see - [Turning Blocks](#turning-blocks)). -2. Run the piece's processors. Air from `legacy_single_pool_element` pieces and unmapped blocks are skipped, and - `protected_blocks` blocks in the world are kept. -3. `terrain_matching` pieces move each column to the ground there. -4. Write it, overwriting whatever the terrain pass put there (unlike spills). -5. Block entities that matter become tile data. Entities are queued to spawn (see [Entities](#entities)). - -Only the chunk's own blocks are written, so the result doesn't depend on which chunk generates first. That's the same -promise spills keep now, in a different way. - -### Terrain Adaptation - -Minecraft's `beard` options change the terrain's density near pieces. bworld's terrain is heights plus 3D density too, -so it's the same idea. The terrain pass gets the boxes of every piece in or near the chunk: - -- **`beard_thin`:** under each rigid piece, fill solid down to the ground, fading out over about 8 blocks around the - box. Above its floor, inside its box, clear what the terrain put there. -- **`beard_box`:** the same, without fading at the edges. -- **`bury` and `encapsulate`:** fill around the piece instead. Trek doesn't use them, so they can come later. -- **Trees:** the base game's trees feature doesn't grow trees whose trunk is inside a piece's box (grown out a few - blocks), using `chunk.structures`, so villages don't get trees through their roofs. Trees still grow around them. - -Like Minecraft, `terrain_matching` pieces (paths) don't adapt the terrain: they follow it. - -### Entities - -Generation only makes blocks now. Template entities and anything else generation spawns need "this chunk was generated -for the first time": the world keeps a set of chunks whose generation spawns already happened, saved with the world. -When a chunk is built and isn't in it, its structure entities are spawned and it's added. Mods' natural spawning can use -the same hook later. - -### Determinism and Saves - -- Starts and pieces are recomputed whenever needed and never saved: a chunk with a piece in it is saved with its blocks - like any other, and pieces reaching into chunks not generated yet need the same start. -- Adding or removing a mod with structures changes only chunks not generated yet, the same as features do now. Saved - chunks stay as they were, so there can be seams. -- Tests generate the same chunks in different orders and compare every block. A golden test records a few chunks with - structures in them, so changes to generation show up. - -### Performance - -Starts are cached. Templates are parsed once into typed arrays. A chunk only looks at pieces whose boxes overlap it. -Assembling a large village is the expensive part: a few milliseconds is fine, since it happens once per start and the -server only builds chunks for a limited time each tick. Profile with Trek's villages before optimizing. - -### Script API - -- **Worldgen:** `register_feature_type`, `register_processor` and `register_structure_type`, and `chunk.structures`: the - pieces overlapping the chunk, so a script feature can avoid them or decorate them. -- **Server:** `ctx.world.structures_at(x, y, z)` (which structures a position is in, for advancements and spawning) and - `ctx.world.find_structure(id, x, z, radius)`. -- **Commands:** `/locate structure ` and `/place structure `, `/place template ` and `/place feature `, - like Minecraft's `/place`. They're the fastest way to look at what an import made. - -## The Importer - -`deno task import-datapack ports/trek mods/trek` turns a datapack (or a mod's `data/` folder) into a bworld mod: - -1. **Copy and wrap.** `/structure/**/*.nbt` goes to `structures/`. Each `worldgen/*` JSON gets bworld's wrapper, an - `id` from its path, and plural folders. Configured and placed features are joined into one data feature per placed - feature. -2. **Rename ids.** Ids in the pack's own namespace stay. `minecraft:` content ids (blocks, items, biomes, tags) are left - for the remaps to resolve when loading, so the import stays close to the original and updates easily. Types - (`minecraft:jigsaw`, `minecraft:rule`) are untouched. -3. **Heights.** Minecraft's world goes from -64 to 320 with the sea at 63. bworld's goes from 0 to 256 with the sea at - 64. Heights relative to the surface (almost everything) need nothing. Absolute heights are moved: y 63 and up gets - +1, and -64 to 63 is squeezed into 1 to 64. -4. **Skip what can't work here.** Anything under a `minecraft/` folder that changes vanilla's own structures - (strongholds, mansions, end cities) and Nether and End content is left out, and listed. -5. **Report.** `IMPORT_REPORT.md` in the new mod: - - blocks, items, biomes and entities that don't map yet, with how many templates use each; - - references to content the pack doesn't include; - - structures that can't generate (no biome maps, or the start pool is missing). - - Run it again after adding blocks: the report shrinks while the mod stays the same. -6. **Credits.** The pack's license and authors go into the mod's `CREDITS.md`. Trek is MIT. - -The importer is the only code that knows datapacks' folder layout. The engine only reads bworld mods. - -## Trek - -Trek has 133 structures in 17 sets, 398 template pools, 45 processor lists, 777 templates (126 more change vanilla's -structures) and 32 configured features. - -- **45 structures are always one piece:** their start templates have no jigsaw blocks. 42 are in the overworld, among - them `rocks`, `plains`, `ruins`, the ice spikes, `oasis`, `graveyard`, `stonehedge` and `pyramide_of_anubis`. These - need everything except assembly. -- **88 are assembled from pieces,** including every village. 699 templates contain jigsaw blocks (2,920 of them). -- **Terrain adaptation:** 75 structures use `beard_thin`, 5 use `beard_box` and 53 use `none`. -- **References outside the pack:** 20 templates and about 50 processor lists and fallback pools are vanilla's - (`minecraft:street_plains`, `minecraft:zombie_plains`, `minecraft:village/plains/terminators`), and 8 templates are - from the Waystones mod. Jigsaw blocks inside templates also name vanilla pools that aren't included, like - `minecraft:village/plains/villagers` and `minecraft:village/common/cats`. The mushroom village refers to - `minecraft:village/mushroom/houses`, which Trek doesn't define. Following Minecraft, a missing pool or processor list - is empty, so those spots stay plain. The base game can add bworld versions of the vanilla street processors later. -- **Not for bworld:** the 3 Nether structures, the End ones, and the `minecraft/` changes to vanilla's structures. - -## Phases - -Each phase ends with every test passing and something to look at in a world. - -**Phase 1: blocks for templates.** - -- Named state values, `values` in conditions, and turning states. -- `common/nbt.ts` and template loading. -- `remaps/` and `mods/bworld/remaps/minecraft.json` for the blocks bworld has. -- The importer's first version, which writes the report. - -Check: `deno task import-datapack ports/trek mods/trek` makes a mod that passes `check-mods`. Every template loads, and -the report lists every unmapped block. - -**Phase 2: single-piece structures.** - -- Structures, structure sets (`random_spread`, frequency, exclusion zones), pools with single elements, processor lists, - and placing pieces per chunk. -- `surface_at` and `ocean_floor_at`. -- Biome tags and remapped biomes. -- `/place` and `/locate`. - -Check: Trek's rocks, ruins and ice spikes generate in a world. The same chunks come out identical in any generation -order. `/locate structure trek:overworld/very_common/rocks` finds one. - -**Phase 3: terrain adaptation and trees.** `beard_thin` and `beard_box`, and no trees inside pieces. - -Check: `stonehedge` and `destroyed_house` sit on filled ground on slopes, with nothing growing through them. - -**Phase 4: jigsaw.** - -- Assembly, every pool element type, `terrain_matching`, fallbacks and priorities. -- The start cache. - -Check: Trek's plains village generates with streets following the ground and no overlapping houses. Assembling the same -start twice gives the same pieces. - -**Phase 5: what's inside.** - -- Loot tables and chest tile data. -- Spawning template entities once per chunk. -- `structures_at`. - -Check: a village chest has loot the first time it's opened and not the second. - -**Phase 6: data features.** - -- `worldgen/features/`: `fossil`, `simple_block`, `block_column`, `disk`, `spring_feature`. -- `register_feature_type`, and template features written per chunk. - -Check: Trek's monster rooms generate underground. - -**Phase 7: the rest, as it's needed.** `concentric_rings`, `bury` and `encapsulate`, `spawn_overrides`, mirroring, -structure types from scripts, and the base game's ores as data features. Meanwhile blocks keep being added, and each one -lets more of Trek's templates generate whole. - -## Open Questions - -- **Starts across mod updates.** Changing a pool's weights moves every structure assembled from it in existing worlds. - That's the same as features now, but structures are bigger. Should a world keep the starts it has seen (like Minecraft - saves them), so updating a mod only changes chunks that were never generated? -- **The `minecraft` namespace.** Packs that change vanilla content (`minecraft:village/plains/...`) could become changes - to the base game's own villages, once the base game has some. Until then they're skipped. -- **Mapping close enough.** Is a block that looks similar (`polished_andesite` → `andesite` → `stone`) better than - leaving the spot empty? Remaps can do either. Start with exact matches only, so the report stays honest. -- **Waterlogging.** Templates mark many blocks `waterlogged` (stairs and slabs under water). bworld has no waterlogging, - so underwater structures will have air pockets in them until it does. - -## Blocks Trek Uses - - - -Counted over the 743 trek templates bworld could generate (overworld, villages, monster rooms; not Nether or End): 748 -distinct blocks, 58 already in bworld. - -### Already in bworld - -`dirt`, `chest`, `spruce_trapdoor`, `grass_block` → `bworld:grass`, `spruce_fence`, `cobblestone`, `spruce_planks`, -`stone_bricks`, `water`, `oak_planks`, `oak_trapdoor`, `stone`, `dark_oak_fence`, `oak_log`, `oak_leaves`, -`dark_oak_planks`, `spruce_log`, `coal_ore`, `oak_fence`, `farmland` → `bworld:hoed_dirt`, `spruce_leaves`, -`birch_leaves`, `iron_ore`, `dark_oak_trapdoor`, `smooth_stone`, `dark_oak_log`, `furnace`, `jungle_fence`, `sand`, -`wheat`, `acacia_leaves`, `smithing_table`, `birch_planks`, `snow_block` → `bworld:snow`, `acacia_fence`, -`acacia_planks`, `cracked_stone_bricks`, `jungle_planks`, `cherry_fence`, `jungle_leaves`, `mossy_stone_bricks`, -`acacia_trapdoor`, `carrots`, `potatoes`, `acacia_log`, `cherry_log`, `jungle_trapdoor`, `cherry_trapdoor`, -`cherry_leaves`, `birch_log`, `birch_trapdoor`, `jungle_log`, `glass`, `dark_oak_leaves`, `cherry_planks`, `copper_ore`, -`birch_fence`, `gold_ore` - -### Missing, used in 20 or more templates - -Templates is how many templates use the block, placed is how many times it's placed across all of them. States are the -vanilla properties the templates use (`waterlogged` left out, bworld has no waterlogging). - -| # | Block | Templates | Placed | States used | -| --: | -------------------------- | --------: | -----: | ---------------------------------------------- | -| 1 | `lantern` | 302 | 1610 | `hanging` | -| 2 | `spruce_slab` | 192 | 10415 | `type` | -| 3 | `spruce_stairs` | 189 | 11049 | `facing`, `half`, `shape` | -| 4 | `coarse_dirt` | 186 | 48024 | | -| 5 | `dirt_path` | 134 | 5495 | | -| 6 | `spruce_door` | 115 | 446 | `facing`, `half`, `hinge`, `open`, `powered` | -| 7 | `dark_oak_stairs` | 109 | 4487 | `facing`, `half`, `shape` | -| 8 | `cobblestone_wall` | 108 | 1620 | `east`, `north`, `south`, `up`, `west` | -| 9 | `dark_oak_slab` | 103 | 4302 | `type` | -| 10 | `spruce_fence_gate` | 103 | 1250 | `facing`, `in_wall`, `open`, `powered` | -| 11 | `ladder` | 97 | 1108 | `facing` | -| 12 | `stone_brick_stairs` | 93 | 2924 | `facing`, `half`, `shape` | -| 13 | `andesite` | 91 | 305242 | | -| 14 | `barrel` | 91 | 1249 | `facing`, `open` | -| 15 | `campfire` | 90 | 558 | `facing`, `lit`, `signal_fire` | -| 16 | `cobblestone_stairs` | 88 | 1609 | `facing`, `half`, `shape` | -| 17 | `oak_slab` | 88 | 2791 | `type` | -| 18 | `rooted_dirt` | 84 | 3547 | | -| 19 | `glass_pane` | 82 | 724 | `east`, `north`, `south`, `west` | -| 20 | `grass` | 80 | 8109 | | -| 21 | `oak_stairs` | 77 | 2840 | `facing`, `half`, `shape` | -| 22 | `chain` | 75 | 506 | `axis` | -| 23 | `stone_brick_slab` | 75 | 1556 | `type` | -| 24 | `stripped_spruce_log` | 71 | 5580 | `axis` | -| 25 | `cobblestone_slab` | 61 | 789 | `type` | -| 26 | `hay_block` | 58 | 992 | `axis` | -| 27 | `crafting_table` | 56 | 204 | | -| 28 | `soul_lantern` | 56 | 138 | `hanging` | -| 29 | `light_gray_wool` | 55 | 246768 | | -| 30 | `stone_brick_wall` | 53 | 682 | `east`, `north`, `south`, `up`, `west` | -| 31 | `dandelion` | 53 | 342 | | -| 32 | `player_head` | 51 | 418 | `rotation` | -| 33 | `tall_grass` | 51 | 3518 | `half` | -| 34 | `light_gray_concrete` | 51 | 260268 | | -| 35 | `vine` | 49 | 3759 | `east`, `north`, `south`, `up`, `west` | -| 36 | `iron_bars` | 49 | 1318 | `east`, `north`, `south`, `west` | -| 37 | `podzol` | 48 | 1362 | `snowy` | -| 38 | `oak_door` | 47 | 166 | `facing`, `half`, `hinge`, `open`, `powered` | -| 39 | `bookshelf` | 46 | 706 | | -| 40 | `white_wool` | 45 | 1711 | | -| 41 | `lime_terracotta` | 45 | 6981 | | -| 42 | `composter` | 44 | 174 | `level` | -| 43 | `rail` | 43 | 270 | `shape` | -| 44 | `stone_button` | 43 | 641 | `face`, `facing`, `powered` | -| 45 | `stone_slab` | 41 | 710 | `type` | -| 46 | `bell` | 41 | 50 | `attachment`, `facing`, `powered` | -| 47 | `grindstone` | 40 | 63 | `face`, `facing` | -| 48 | `mycelium` | 39 | 6911 | `snowy` | -| 49 | `water_cauldron` | 38 | 69 | `level` | -| 50 | `poppy` | 38 | 190 | | -| 51 | `dark_oak_fence_gate` | 37 | 457 | `facing`, `in_wall`, `open`, `powered` | -| 52 | `white_wall_banner` | 37 | 143 | `facing` | -| 53 | `mossy_cobblestone_slab` | 37 | 560 | `type` | -| 54 | `stripped_oak_log` | 37 | 1747 | `axis` | -| 55 | `smoker` | 36 | 60 | `facing`, `lit` | -| 56 | `blast_furnace` | 36 | 54 | `facing`, `lit` | -| 57 | `smooth_sandstone` | 36 | 2689 | | -| 58 | `spruce_pressure_plate` | 36 | 75 | `powered` | -| 59 | `stone_stairs` | 35 | 366 | `facing`, `half`, `shape` | -| 60 | `oak_wall_sign` | 35 | 353 | `facing` | -| 61 | `red_bed` | 35 | 170 | `facing`, `occupied`, `part` | -| 62 | `moss_block` | 35 | 8669 | | -| 63 | `candle` | 35 | 84 | `candles`, `lit` | -| 64 | `snow` | 34 | 2508 | `layers` | -| 65 | `spruce_wall_sign` | 34 | 532 | `facing` | -| 66 | `stripped_dark_oak_log` | 33 | 861 | `axis` | -| 67 | `diorite` | 33 | 4578 | | -| 68 | `calcite` | 32 | 2964 | | -| 69 | `birch_slab` | 32 | 630 | `type` | -| 70 | `jungle_stairs` | 32 | 426 | `facing`, `half`, `shape` | -| 71 | `smooth_sandstone_stairs` | 32 | 560 | `facing`, `half`, `shape` | -| 72 | `cut_sandstone` | 32 | 1722 | | -| 73 | `mossy_cobblestone` | 32 | 3850 | | -| 74 | `melon` | 32 | 686 | | -| 75 | `scaffolding` | 31 | 214 | `bottom`, `distance` | -| 76 | `birch_wood` | 31 | 356 | `axis` | -| 77 | `acacia_wood` | 30 | 1033 | `axis` | -| 78 | `polished_diorite` | 30 | 653 | | -| 79 | `flowering_azalea_leaves` | 30 | 531 | `distance`, `persistent` | -| 80 | `light_blue_bed` | 30 | 96 | `facing`, `occupied`, `part` | -| 81 | `wall_torch` | 29 | 221 | `facing` | -| 82 | `flower_pot` | 29 | 113 | | -| 83 | `terracotta` | 29 | 707 | | -| 84 | `red_mushroom_block` | 29 | 679 | `down`, `east`, `north`, `south`, `up`, `west` | -| 85 | `acacia_stairs` | 29 | 896 | `facing`, `half`, `shape` | -| 86 | `stripped_spruce_wood` | 28 | 3415 | `axis` | -| 87 | `potted_blue_orchid` | 28 | 43 | | -| 88 | `polished_andesite` | 27 | 1021 | | -| 89 | `mud_brick_wall` | 27 | 898 | `east`, `north`, `south`, `up`, `west` | -| 90 | `sandstone` | 27 | 10819 | | -| 91 | `end_rod` | 27 | 142 | `facing` | -| 92 | `green_bed` | 27 | 76 | `facing`, `occupied`, `part` | -| 93 | `decorated_pot` | 27 | 49 | `cracked`, `facing` | -| 94 | `cobweb` | 26 | 346 | | -| 95 | `spruce_wood` | 26 | 2521 | `axis` | -| 96 | `rose_bush` | 26 | 304 | `half` | -| 97 | `jungle_slab` | 26 | 778 | `type` | -| 98 | `deepslate_brick_stairs` | 26 | 1319 | `facing`, `half`, `shape` | -| 99 | `green_wool` | 25 | 3524 | | -| 100 | `cartography_table` | 25 | 29 | | -| 101 | `chiseled_stone_bricks` | 25 | 274 | | -| 102 | `loom` | 25 | 245 | `facing` | -| 103 | `white_carpet` | 24 | 112 | | -| 104 | `oak_fence_gate` | 24 | 466 | `facing`, `in_wall`, `open`, `powered` | -| 105 | `smooth_sandstone_slab` | 24 | 364 | `type` | -| 106 | `azalea_leaves` | 24 | 2186 | `distance`, `persistent` | -| 107 | `potted_fern` | 24 | 51 | | -| 108 | `deepslate_bricks` | 24 | 1356 | | -| 109 | `acacia_slab` | 24 | 1741 | `type` | -| 110 | `cauldron` | 23 | 47 | | -| 111 | `lectern` | 23 | 96 | `facing`, `has_book`, `powered` | -| 112 | `cornflower` | 23 | 46 | | -| 113 | `bamboo` | 23 | 608 | `age`, `leaves`, `stage` | -| 114 | `deepslate_brick_slab` | 23 | 1455 | `type` | -| 115 | `red_carpet` | 22 | 278 | | -| 116 | `blue_bed` | 22 | 66 | `facing`, `occupied`, `part` | -| 117 | `black_wall_banner` | 22 | 55 | `facing` | -| 118 | `crimson_roots` | 22 | 177 | | -| 119 | `andesite_stairs` | 21 | 169 | `facing`, `half`, `shape` | -| 120 | `mossy_stone_brick_stairs` | 21 | 119 | `facing`, `half`, `shape` | -| 121 | `smooth_quartz_stairs` | 21 | 372 | `facing`, `half`, `shape` | -| 122 | `green_concrete` | 21 | 3324 | | -| 123 | `fletching_table` | 21 | 41 | | -| 124 | `sea_pickle` | 21 | 84 | `pickles` | -| 125 | `potted_oak_sapling` | 21 | 32 | | -| 126 | `fern` | 21 | 139 | | -| 127 | `diorite_slab` | 21 | 318 | `type` | -| 128 | `jungle_door` | 21 | 70 | `facing`, `half`, `hinge`, `open`, `powered` | -| 129 | `dead_brain_coral_block` | 21 | 797 | | -| 130 | `hopper` | 20 | 53 | `enabled`, `facing` | -| 131 | `dark_oak_wood` | 20 | 1805 | `axis` | -| 132 | `potted_spruce_sapling` | 20 | 29 | | -| 133 | `brewing_stand` | 20 | 38 | `has_bottle_0`, `has_bottle_1`, `has_bottle_2` | -| 134 | `green_concrete_powder` | 20 | 530 | | -| 135 | `polished_diorite_slab` | 20 | 293 | `type` | -| 136 | `glow_lichen` | 20 | 346 | `down`, `east`, `north`, `south`, `up`, `west` | -| 137 | `spruce_wall_hanging_sign` | 20 | 58 | `facing` | - -### Missing, used in 5 to 19 templates - -- **19:** `dark_oak_wall_sign`, `andesite_wall`, `moss_carpet`, `granite`, `oak_wood`, `potted_dead_bush`, - `mossy_stone_brick_slab`, `cut_sandstone_slab`, `brown_mushroom`, `smooth_quartz_slab` -- **18:** `anvil`, `potted_dark_oak_sapling`, `oxeye_daisy`, `mossy_cobblestone_stairs`, `green_terracotta`, - `green_glazed_terracotta` -- **17:** `smooth_quartz`, `lever`, `sandstone_wall`, `sandstone_slab`, `stonecutter`, `tripwire_hook`, `pumpkin`, - `dried_kelp_block`, `mushroom_stem`, `green_stained_glass`, `pink_bed` -- **16:** `damaged_anvil`, `tuff`, `cyan_terracotta`, `red_wall_banner`, `cave_vines_plant`, `cave_vines`, `clay`, - `crimson_fungus`, `acacia_door`, `oak_pressure_plate`, `wet_sponge` -- **15:** `bricks`, `gravel`, `mossy_cobblestone_wall`, `brick_stairs`, `mossy_stone_brick_wall`, `glowstone`, - `potted_dandelion`, `note_block`, `obsidian`, `red_stained_glass_pane`, `orange_terracotta`, `deepslate_tile_slab`, - `potted_flowering_azalea_bush` -- **14:** `spruce_button`, `heavy_weighted_pressure_plate`, `jungle_wood`, `potted_red_tulip`, `azalea`, `white_bed`, - `potted_bamboo`, `weeping_vines` -- **13:** `andesite_slab`, `potted_lily_of_the_valley`, `potted_cactus`, `sandstone_stairs`, `blue_orchid`, - `flowering_azalea`, `amethyst_cluster`, `azure_bluet`, `large_fern`, `white_concrete`, `white_terracotta`, - `potted_azalea_bush`, `deepslate_tile_stairs`, `lime_stained_glass`, `dead_bubble_coral_block`, `cherry_door` -- **12:** `gray_carpet`, `diorite_wall`, `bone_block`, `tripwire`, `stone_pressure_plate`, `brown_carpet`, - `polished_andesite_stairs`, `crimson_slab`, `mangrove_trapdoor`, `weeping_vines_plant`, `red_candle`, `sponge` -- **11:** `stripped_dark_oak_wood`, `torch`, `orange_bed`, `quartz_stairs`, `quartz_slab`, `yellow_wool`, - `birch_stairs`, `gold_block`, `black_bed`, `carved_pumpkin`, `brown_wall_banner`, `potted_oxeye_daisy`, - `potted_pink_tulip`, `potted_cornflower`, `beetroots`, `dead_horn_coral_fan`, `orange_stained_glass_pane`, - `polished_andesite_slab`, `potted_poppy`, `smooth_stone_slab`, `mangrove_stairs`, `mud_bricks`, `jungle_fence_gate`, - `yellow_wall_banner`, `light_blue_terracotta`, `white_concrete_powder`, `yellow_terracotta`, `crimson_fence`, - `spruce_hanging_sign`, `potted_cherry_sapling` -- **10:** `peony`, `packed_ice`, `gray_wool`, `blue_ice`, `chiseled_sandstone`, `seagrass`, `white_candle`, - `large_amethyst_bud`, `dark_oak_door`, `spawner`, `crying_obsidian`, `red_sandstone`, `stripped_crimson_hyphae`, - `chiseled_bookshelf`, `lava_cauldron`, `bamboo_sapling`, `bamboo_fence`, `bamboo_trapdoor` -- **9:** `green_carpet`, `brick_slab`, `brick_wall`, `lilac`, `coal_block`, `polished_diorite_stairs`, `diorite_stairs`, - `potted_white_tulip`, `sweet_berry_bush`, `magma_block`, `redstone_wire`, `white_stained_glass_pane`, - `light_gray_carpet`, `allium`, `red_wool`, `netherrack`, `beehive`, `deepslate_brick_wall`, `yellow_carpet`, - `stripped_birch_wood`, `mud_brick_stairs`, `crimson_hyphae`, `crimson_trapdoor`, `bamboo_pressure_plate` -- **8:** `dark_oak_button`, `iron_trapdoor`, `blue_wool`, `deepslate`, `dead_bush`, `potted_acacia_sapling`, - `dark_oak_pressure_plate`, `lightning_rod`, `enchanting_table`, `light_gray_stained_glass_pane`, `ice`, `packed_mud`, - `mangrove_wood`, `deepslate_tiles`, `stripped_oak_wood`, `raw_iron_block`, `brown_mushroom_block`, `shroomlight`, - `acacia_fence_gate`, `birch_wall_sign`, `red_stained_glass`, `short_grass`, `cherry_stairs` -- **7:** `oak_button`, `skeleton_skull`, `hanging_roots`, `polished_deepslate_wall`, `cyan_wool`, `soul_campfire`, - `black_wool`, `quartz_block`, `stripped_jungle_log`, `mud_brick_slab`, `brown_bed`, `potted_crimson_fungus`, - `lily_of_the_valley`, `medium_amethyst_bud`, `jukebox`, `black_carpet`, `lily_pad`, `nether_brick_fence`, - `red_terracotta`, `potted_mangrove_propagule`, `mangrove_log`, `blue_terracotta`, `red_mushroom`, `potted_allium`, - `lava`, `dripstone_block`, `crimson_planks`, `jungle_wall_hanging_sign` -- **6:** `brown_terracotta`, `dead_brain_coral_fan`, `polished_deepslate`, `sugar_cane`, `potted_birch_sapling`, - `granite_stairs`, `polished_granite`, `attached_pumpkin_stem`, `stripped_birch_log`, `cobbled_deepslate`, - `purple_stained_glass`, `gray_bed`, `purple_carpet`, `tnt`, `nether_wart_block`, `potted_brown_mushroom`, - `yellow_bed`, `oak_wall_hanging_sign`, `jungle_pressure_plate`, `cherry_hanging_sign` -- **5:** `green_wall_banner`, `white_tulip`, `iron_block`, `polished_deepslate_stairs`, `cobbled_deepslate_slab`, - `tall_seagrass`, `cake`, `pumpkin_stem`, `attached_melon_stem`, `emerald_block`, `red_tulip`, `purple_wool`, - `nether_brick_slab`, `nether_brick_stairs`, `black_terracotta`, `gray_stained_glass_pane`, `blackstone_wall`, - `jungle_wall_sign`, `infested_chiseled_stone_bricks`, `piston`, `stripped_acacia_log`, `potted_azure_bluet`, - `lapis_ore`, `light_gray_terracotta`, `raw_gold_block`, `target`, `granite_wall`, `crimson_nylium`, - `twisting_vines_plant`, `twisting_vines`, `stripped_cherry_log`, `cherry_wall_hanging_sign`, `bamboo_stairs`, - `acacia_hanging_sign`, `acacia_wall_hanging_sign`, `acacia_pressure_plate` - -The other 287 are in fewer than 5 templates each; the importer's unmapped report lists them. - -### Missing, by family - -Many missing blocks are one shape in many materials, so adding the shape once (a model, its states and its rules) and -then the materials is most of the work. - -| Family | Missing blocks | In templates (sum) | Examples | -| ------------------------- | -------------: | -----------------: | ----------------------------------------------------------------------------------------------------------- | -| slabs | 45 | 971 | `spruce_slab`, `dark_oak_slab`, `oak_slab`, `stone_brick_slab`, ... | -| stairs | 47 | 964 | `spruce_stairs`, `dark_oak_stairs`, `stone_brick_stairs`, `cobblestone_stairs`, ... | -| flower pots | 33 | 353 | `potted_blue_orchid`, `potted_fern`, `potted_oak_sapling`, `potted_spruce_sapling`, ... | -| walls | 19 | 315 | `cobblestone_wall`, `stone_brick_wall`, `mud_brick_wall`, `andesite_wall`, ... | -| stripped logs and wood | 19 | 244 | `stripped_spruce_log`, `stripped_oak_log`, `stripped_dark_oak_log`, `stripped_spruce_wood`, ... | -| doors | 10 | 232 | `spruce_door`, `oak_door`, `jungle_door`, `acacia_door`, ... | -| terracotta | 27 | 209 | `lime_terracotta`, `green_terracotta`, `green_glazed_terracotta`, `cyan_terracotta`, ... | -| wool | 16 | 195 | `light_gray_wool`, `white_wool`, `green_wool`, `yellow_wool`, ... | -| beds | 15 | 194 | `red_bed`, `light_blue_bed`, `green_bed`, `blue_bed`, ... | -| fence gates | 8 | 190 | `spruce_fence_gate`, `dark_oak_fence_gate`, `oak_fence_gate`, `jungle_fence_gate`, ... | -| signs | 20 | 180 | `oak_wall_sign`, `spruce_wall_sign`, `spruce_wall_hanging_sign`, `dark_oak_wall_sign`, ... | -| wood (bark on every side) | 8 | 151 | `birch_wood`, `acacia_wood`, `spruce_wood`, `dark_oak_wood`, ... | -| carpets | 17 | 150 | `white_carpet`, `red_carpet`, `moss_carpet`, `gray_carpet`, ... | -| glass panes | 12 | 141 | `glass_pane`, `red_stained_glass_pane`, `orange_stained_glass_pane`, `white_stained_glass_pane`, ... | -| banners | 17 | 122 | `white_wall_banner`, `black_wall_banner`, `red_wall_banner`, `brown_wall_banner`, ... | -| pressure plates | 12 | 111 | `spruce_pressure_plate`, `oak_pressure_plate`, `heavy_weighted_pressure_plate`, `stone_pressure_plate`, ... | -| concrete | 12 | 100 | `light_gray_concrete`, `green_concrete`, `white_concrete`, `red_concrete`, ... | -| buttons | 9 | 81 | `stone_button`, `spruce_button`, `dark_oak_button`, `oak_button`, ... | -| stained glass | 9 | 57 | `green_stained_glass`, `lime_stained_glass`, `red_stained_glass`, `purple_stained_glass`, ... | -| trapdoors | 5 | 41 | `mangrove_trapdoor`, `bamboo_trapdoor`, `crimson_trapdoor`, `iron_trapdoor`, ... | -| candles | 9 | 34 | `red_candle`, `white_candle`, `light_gray_candle`, `pink_candle`, ... | -| fences | 5 | 31 | `crimson_fence`, `bamboo_fence`, `nether_brick_fence`, `mangrove_fence`, ... | +And a `/exportschematic [x1] [y1] [z1] [x2] [y2] [z2]` command that calls ctx.schematics.export on the player's +dimension diff --git a/deno.json b/deno.json index 9e58be4..4a1dae7 100644 --- a/deno.json +++ b/deno.json @@ -25,6 +25,7 @@ }, "imports": { "@/": "./", + "@std/msgpack": "jsr:@std/msgpack@^1.0.3", "cubi/server": "./common/mod_api/server.ts", "cubi/client": "./common/mod_api/client.ts", "cubi/worldgen": "./common/mod_api/worldgen.ts", diff --git a/deno.lock b/deno.lock index 5f59a35..cbd651b 100644 --- a/deno.lock +++ b/deno.lock @@ -5,6 +5,7 @@ "jsr:@paulaboks/codecounter@*": "0.0.3", "jsr:@paulaboks/rng@^0.0.3": "0.0.3", "jsr:@std/assert@1": "1.0.14", + "jsr:@std/bytes@^1.0.5": "1.0.6", "jsr:@std/cli@^1.0.27": "1.0.27", "jsr:@std/encoding@1.0.5": "1.0.5", "jsr:@std/encoding@^1.0.10": "1.0.10", @@ -14,14 +15,15 @@ "jsr:@std/html@^1.0.5": "1.0.5", "jsr:@std/http@*": "1.0.24", "jsr:@std/http@^1.0.23": "1.0.24", - "jsr:@std/internal@^1.0.10": "1.0.12", - "jsr:@std/internal@^1.0.12": "1.0.12", + "jsr:@std/internal@^1.0.10": "1.0.14", + "jsr:@std/internal@^1.0.12": "1.0.14", "jsr:@std/internal@^1.0.14": "1.0.14", "jsr:@std/media-types@^1.1.0": "1.1.0", + "jsr:@std/msgpack@^1.0.3": "1.0.3", "jsr:@std/net@^1.0.6": "1.0.6", "jsr:@std/path@1": "1.1.6", "jsr:@std/path@^1.1.2": "1.1.6", - "jsr:@std/path@^1.1.4": "1.1.4", + "jsr:@std/path@^1.1.4": "1.1.6", "jsr:@std/streams@^1.0.17": "1.1.2", "jsr:@zod/zod@^4.6.7": "4.6.7", "npm:fflate@~0.8.2": "0.8.3", @@ -50,6 +52,9 @@ "jsr:@std/internal@^1.0.10" ] }, + "@std/bytes@1.0.6": { + "integrity": "f6ac6adbd8ccd99314045f5703e23af0a68d7f7e58364b47d2c7f408aeb5820a" + }, "@std/cli@1.0.27": { "integrity": "eba97edd0891871a7410e835dd94b3c260c709cca5983df2689c25a71fbe04de" }, @@ -95,6 +100,12 @@ "@std/media-types@1.1.0": { "integrity": "c9d093f0c05c3512932b330e3cc1fe1d627b301db33a4c2c2185c02471d6eaa4" }, + "@std/msgpack@1.0.3": { + "integrity": "b384239867dfd08aba9069d433e415a8229c6f966716d6b7fd3972a6fe605848", + "dependencies": [ + "jsr:@std/bytes" + ] + }, "@std/net@1.0.6": { "integrity": "110735f93e95bb9feb95790a8b1d1bf69ec0dc74f3f97a00a76ea5efea25500c" }, @@ -140,6 +151,7 @@ "jsr:@std/assert@1", "jsr:@std/fs@^1.0.23", "jsr:@std/http@^1.0.23", + "jsr:@std/msgpack@^1.0.3", "jsr:@std/path@1", "jsr:@zod/zod@^4.6.7", "npm:fflate@~0.8.2",