Update modding docs

This commit is contained in:
2026-09-29 23:29:14 -03:00
parent f0cf4e4eeb
commit 1ac7a5c943
50 changed files with 2672 additions and 1924 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import type { ServerAddress, Welcome } from "./handshake.ts";
// asks before running a server's mods when the page came from somewhere else, see "Security" in MODS.md.
// asks before running a server's mods when the page came from somewhere else, see docs/modding/concepts/security.md.
// resolves with whether the player wants to join
export function confirm_mods(address: ServerAddress, welcome: Welcome): Promise<boolean> {
return new Promise((resolve) => {
+1 -1
View File
@@ -1,4 +1,4 @@
// connecting to a server and getting what it needs before joining, see "Delivery to clients" in MODS.md:
// connecting to a server and getting what it needs before joining, see docs/modding/networking/index.md:
// hello -> welcome, download and check everything, ready -> join
import { ClientMessage, PROTOCOL_VERSION, ServerMessage } from "$/common/protocol.ts";
+1 -1
View File
@@ -114,7 +114,7 @@ class ClientLoop {
// can't go back to the title screen to try again, the page has to start over
class FailedAfterLoadingMods extends Error {}
// the game only runs against a server, it owns the world and everything in it. see "Delivery to clients" in MODS.md
// the game only runs against a server, it owns the world and everything in it. see docs/modding/networking/index.md
async function join_server(address: ServerAddress, name: string, status: (text: string) => void): Promise<Connection> {
const { socket, welcome } = await connect(address, name);
console.log(`Connected to ${address.ws_url}`);
+8 -6
View File
@@ -1,5 +1,5 @@
// loads the mods the server lists: downloads their .bmod files, registers their data, then runs their client scripts.
// see "Delivery to clients" in MODS.md
// see docs/modding/networking/index.md
import { AIR } from "$/common/constants.ts";
import { BlockRegistry, EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
import type { ClientContext, InventoryOverlay } from "$/common/mod_api/client.ts";
@@ -75,7 +75,9 @@ function client_context(listing: ModListing): ClientContext {
const not_yet = (name: string, where: string) =>
new Proxy({}, {
get: (_, prop) => () => {
throw new Error(`[${mod}] ctx.${name}.${String(prop)} isn't implemented yet (${where} in MODS.md)`);
throw new Error(
`[${mod}] ctx.${name}.${String(prop)} isn't implemented yet (${where}, see docs/modding_plan.md)`,
);
},
});
const need_client = () => {
@@ -84,7 +86,7 @@ function client_context(listing: ModListing): ClientContext {
};
const not_yet_fn = (name: string) => () => {
throw new Error(`[${mod}] ctx.ui.${name} isn't implemented yet (Custom screens in MODS.md)`);
throw new Error(`[${mod}] ctx.ui.${name} isn't implemented yet (custom screens, see docs/modding_plan.md)`);
};
const known_item = (id: string) => {
const item = EverythingRegistry.get<ItemRegistry>("items", id);
@@ -101,9 +103,9 @@ function client_context(listing: ModListing): ClientContext {
inventory_overlays.push({ mod, overlay });
},
},
hud: not_yet("hud", "step 7") as ClientContext["hud"],
input: not_yet("input", "step 8") as ClientContext["input"],
net: not_yet("net", "step 8") as ClientContext["net"],
hud: not_yet("hud", "HUD elements") as ClientContext["hud"],
input: not_yet("input", "keybinds") as ClientContext["input"],
net: not_yet("net", "mod channels") as ClientContext["net"],
player: {
get name() {
return need_client().connection.name;