Export schematics

This commit is contained in:
2026-11-15 18:41:22 -03:00
parent 2fa109026c
commit 59bfed58bf
18 changed files with 511 additions and 26 deletions
+10 -5
View File
@@ -11,7 +11,8 @@ Schematics are json data, encoded and decoded with MessagePack (@std/msgpack), t
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
The data on palette.palette[number].data is from BlockComponent.export_data
The data on blocks[number].data is from BlockComponent.export_data. A block's client data, like the item a cutting board
holds, goes in blocks[number].client_data. `id` is left out of exported schematics, it's set when one is registered
Example:
@@ -41,7 +42,7 @@ Example:
{
"i": 2,
"p": [1, 1, 0],
"data": { "items": [] }
"data": { "progress": 0, "container": [{ "id": "bworld:coal", "count": 5 }, null, null] }
}
],
"entities": [
@@ -108,9 +109,13 @@ Entities get their position turned the same way as blocks, and their yaw with it
### Saving schematics
Built, see `docs/modding/misc/schematics.md`:
```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
// writes a .cbsm file to the system's temporary directory and resolves to its path
ctx.schematics.export(from, to);
```
And a `/exportschematic [x1] [y1] [z1] [x2] [y2] [z2]` command that calls ctx.schematics.export on the player's
dimension
It has no dimension argument yet, since a server only has one world. `/exportschematic x1 y1 z1 x2 y2 z2` calls it and
tells the player the path in chat. The game worker can't write files, so the host writes it (`write_schematic` in
`server/game/host_protocol.ts`).