Curios and artifacts !

This commit is contained in:
2026-09-30 15:22:32 -03:00
parent 342b45d593
commit 3af5f6e54b
45 changed files with 729 additions and 43 deletions
+9 -6
View File
@@ -59,10 +59,7 @@ server code are never sent at all. See [Sides](../concepts/sides.md#what-each-si
## Mod Channels
> [!NOTE]
> Not built yet. `ctx.net` exists on both sides but throws.
Mod channels will let a mod's client and server scripts send each other JSON messages:
Mod channels let a mod's client and server scripts send each other JSON messages:
```ts
// server.ts
@@ -75,5 +72,11 @@ ctx.net.on("copper_tools:heat", (data) => {/* ... */});
ctx.net.send("copper_tools:reset_stats", {});
```
Until then, the server reaches the client through what's already synced: [container screens](../inventories/menus.md)
and their properties, item stack `data`, block states, and displayed items.
- Channel ids are in the mod's namespace, and a mod only listens and sends on its own.
- A message from a client is at most 16 KB of JSON, and each player can send at most 60 a second. The server drops
anything over that without telling anyone.
- Everything a client sends is untrusted: check it like a click or a chat message.
- A handler that throws is logged under its mod, and the other handlers still run.
Curios (`mods/curios`) is a small example: its client script's button sends `curios:open`, and its server script opens
the curio slots for that player.