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 -9
View File
@@ -9,24 +9,26 @@ Anything a client sends can be forged by a player who edits their client. The en
reach and the held item for every break, place and interact, and container rules (slot filters, output-only slots) on
the server. A mod's own logic has to do the same:
- Decide on the server. Client scripts show things. Server scripts decide what happens.
- Check permissions on the server, in the server script, before acting for a player, like `requires` on a
- Decide on the server. The client phase shows things. The server phase decides what happens.
- Check permissions on the server, in the server phase, before acting for a player, like `requires` on a
[command](../misc/commands.md).
- Never use a value from a client as an item id, a count or a position without checking it.
Server script code and tile data are never sent to clients, so a mod can keep anti-cheat logic or secrets there. Only
the fields a script sets as [client data](../blocks/tiledata.md#client-data) are.
Tile data is never sent to clients, only the fields a script sets as [client data](../blocks/tiledata.md#client-data). A
mod's script is: players get all of it, its server phase too, and only run its shared and client phases. So a mod can
keep secrets in the world, in tile data or [`ctx.storage`](../datastorage/index.md), but never in its code. Anti-cheat
works by the server deciding, not by hiding how it decides.
## Server Scripts
## The Server Phase
Server scripts run in the game worker with **no Deno permissions**: they can't read files, open connections or run
The server phase runs in the game worker with **no Deno permissions**: they can't read files, open connections or run
programs. Everything they can do goes through the mod API. Installing a server mod still means trusting it with the game
world and everything players send.
## Client Scripts
## The Client Phase
Client scripts run in the game page with the page's full access. How much that matters depends on where the page came
from:
The client phase runs in the game page, like the rest of a mod's script there, with the page's full access. How much
that matters depends on where the page came from:
- **The page was served by the game server** (the default). That server already chose every line of JavaScript on the
page, so running its mods doesn't trust it any more than loading the page did.