Loading schematics

This commit is contained in:
2026-11-15 19:54:08 -03:00
parent 6bb2c87373
commit 0564275f58
15 changed files with 142 additions and 17 deletions
+4 -3
View File
@@ -29,6 +29,7 @@ mods/
worldgen/noise_settings/**/*.json
worldgen/biome_source/**/*.json
worldgen/spawns.json # monsters that spawn on their own, see entities/index.md
schematics/*.cbsm # schematics, never sent to players. see misc/schematics.md
textures/*.png
textures/*.json # animations, see resources/textures.md
scripts/
@@ -115,7 +116,7 @@ deno task build # packs every mod in mods/ into server_mo
```
copper_tools.cubi
manifest.json # with main and credits pointing into the zip
data.json # every block, model, item, entity, recipe, ore, tag and loot table, and the config
data.json # every block, model, item, entity, recipe, ore, tag, loot table and schematic, and the config
script.js # the script bundled into one module
textures/<name>.png
textures/<name>.json # for animated textures
@@ -127,5 +128,5 @@ copper_tools.cubi
- `deno task build` leaves other `.cubi` files in `server_mods/` alone, so mods from elsewhere can sit next to the ones
it builds.
- `data.json` doesn't hold the blocks the content phase registers. The server runs it when it loads the `.cubi`.
- Players get a copy **without** the terrain's data and the config, but with the blocks the content phase registered in
its `data.json`. See [Networking](../networking/index.md).
- Players get a copy **without** the terrain's data, the schematics and the config, but with the blocks the content
phase registered in its `data.json`. See [Networking](../networking/index.md).
+7 -3
View File
@@ -4,8 +4,8 @@ A schematic is a box of the world saved to a file: its blocks with their states
placed again somewhere else. Schematic files end in `.cbsm` and are [MessagePack](https://msgpack.org), see
`common/schematic.ts` for their format.
Exporting, registering and placing are built. Mods shipping their own as files, and blocks making what their data points
to when they're placed (`import_data`), are planned in `STRUCTURES.md`.
Exporting, registering and placing are built. Blocks making what their data points to when they're placed
(`import_data`) is planned in `STRUCTURES.md`.
## Exporting
@@ -35,7 +35,11 @@ Positions are from the box's lowest corner.
## Placing
A schematic is registered by id in the server phase, then placed by that id:
A mod's `schematics/<name>.cbsm` files are its schematics `<mod id>:<name>`, so an exported file can be dropped in as it
is. `check-mods` checks that every block and entity in them exists. They're registered before any script runs, so a
server phase can place them right away. Players never download them.
A script can also register one it made itself, by id in the server phase, then place it by that id:
```ts
ctx.schematics.register("copper_tools:hut", schematic);