Single module modding

This commit is contained in:
2026-11-14 12:18:41 -03:00
parent 605008f584
commit 313098892e
134 changed files with 919 additions and 924 deletions
+11 -11
View File
@@ -15,8 +15,8 @@ client server
│ [another site: confirm screen] │
│ download every .cubi, check each one's │
│ sha256, build the texture atlas, load │
│ data in the listed order, run client │
│ scripts' setup, start chunk workers │
│ data in the listed order, run shared │
│ and client phases, start chunk workers │
│ │
│ ready { view_distance } │
├────────────────────────────────────────►│
@@ -30,10 +30,10 @@ client server
- The client loads mods **in the order the server lists them**, so both sides register the same content the same way.
- Every `.cubi` is checked against its SHA-256 before it's opened, and scripts run from the checked bytes, so what runs
is exactly what the server listed.
- Players get each mod's `.cubi` **without its server and worldgen scripts**. The server makes that copy when it starts,
named by its hash so it can be cached forever.
- If any download, hash check or client `setup` fails, the client disconnects and says which mod failed. It never joins
with some mods missing.
- Players get each mod's `.cubi` **without its terrain data and config**. Its script is all there, and players run its
shared and client phases. The server makes that copy when it starts, named by its hash so it can be cached forever.
- If any download, hash check, shared or client phase fails, the client disconnects and says which mod failed. It never
joins with some mods missing.
- Until `ready`, the connection isn't a player: nobody sees it, and anything else it sends is ignored. A client that
doesn't send `ready` within 60 seconds is turned away.
- Leaving a server reloads the page, so one server's mod code never stays loaded while playing on another.
@@ -43,8 +43,8 @@ away before anything is downloaded.
## The World
The server sends the world the way Minecraft Java does since 1.20.2. Clients never generate terrain, so worldgen scripts
stay on the server.
The server sends the world the way Minecraft Java does since 1.20.2. Clients never generate terrain, so they never run
the worldgen phase.
- Chunks are 16×16 and as tall as the dimension, sent whole, compressed, in batches, nearest first. The server paces
batches by how fast each client says it loads them.
@@ -54,12 +54,12 @@ stay on the server.
close.
- Entities near a player are sent to them, and their movement follows.
For a mod, this means: what a client knows about the world is what's near its player. Tile data, `ctx.storage` and
server code are never sent at all. See [Sides](../concepts/sides.md#what-each-side-knows).
For a mod, this means: what a client knows about the world is what's near its player. Tile data and `ctx.storage` are
never sent at all. See [Sides](../concepts/sides.md#what-each-side-knows).
## Mod Channels
Mod channels let a mod's client and server scripts send each other JSON messages:
Mod channels let a mod's client and server phases send each other JSON messages:
```ts
// server.ts