Block registry api
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Mod Files
|
||||
|
||||
A mod is a folder with a `manifest.json`, some data files, textures, and up to four scripts. The build packs it into a
|
||||
A mod is a folder with a `manifest.json`, some data files, textures, and up to five scripts. The build packs it into a
|
||||
single `.cubi` file, which is what servers load.
|
||||
|
||||
## Layout
|
||||
@@ -36,6 +36,7 @@ mods/
|
||||
client.ts # sent to players
|
||||
shared.ts # block rules, run on the server and sent to players
|
||||
worldgen.ts # terrain features, never sent to players
|
||||
content.ts # blocks made in code, run by the server while it loads mods, never sent to players
|
||||
```
|
||||
|
||||
Data folders can have subfolders. Every data file holds one definition, wrapped with the format version:
|
||||
@@ -66,7 +67,8 @@ matter, the `id` inside does, except for [tags](../resources/tags.md), whose id
|
||||
"server": "scripts/server.ts",
|
||||
"client": "scripts/client.ts",
|
||||
"worldgen": "scripts/worldgen.ts",
|
||||
"shared": "scripts/shared.ts"
|
||||
"shared": "scripts/shared.ts",
|
||||
"content": "scripts/content.ts"
|
||||
},
|
||||
"credits": "CREDITS.md"
|
||||
}
|
||||
@@ -83,7 +85,7 @@ matter, the `id` inside does, except for [tags](../resources/tags.md), whose id
|
||||
| `game_version` | no | The bworld versions the mod works with, as a semver range. Only checked for mods with `engine_access`. |
|
||||
| `engine_access` | no | `true` lets the scripts import `cubi/engine` and hook the engine. See [Engine Access](../misc/engine.md). |
|
||||
| `dependencies` | no | Other mods, `{ "id", "version" }`. A missing dependency is an error, and dependencies load first. The version range isn't checked yet. |
|
||||
| `scripts` | no | Paths to the `server`, `client`, `shared` and `worldgen` scripts. See [Sides](../concepts/sides.md). |
|
||||
| `scripts` | no | Paths to the `server`, `client`, `shared`, `worldgen` and `content` scripts. See [Sides](../concepts/sides.md). |
|
||||
| `credits` | no | A markdown file for licenses and thanks, shown on the Credits screen. Raw HTML in it is shown as text. |
|
||||
|
||||
List every mod whose ids you use in `dependencies`, including `bworld` for the base game's blocks and items. It
|
||||
@@ -102,8 +104,8 @@ so they can import other files and packages, but code imported by several script
|
||||
|
||||
When a mod's folder has a `deno.json`, its scripts are bundled and typechecked with it, so the mod can have its own
|
||||
imports and npm or JSR packages. Mods without one use the `deno.json` of the folder the build runs in, like the mods in
|
||||
this repository. That config maps the API types, which scripts import as `cubi/server`, `cubi/client`, `cubi/shared` and
|
||||
`cubi/worldgen`, and [`cubi/engine`](../misc/engine.md):
|
||||
this repository. That config maps the API types, which scripts import as `cubi/server`, `cubi/client`, `cubi/shared`,
|
||||
`cubi/worldgen` and `cubi/content`, and [`cubi/engine`](../misc/engine.md):
|
||||
|
||||
```ts
|
||||
import type { ServerContext } from "cubi/server";
|
||||
@@ -127,6 +129,7 @@ copper_tools.cubi
|
||||
scripts/client.js
|
||||
scripts/worldgen.js
|
||||
scripts/shared.js
|
||||
scripts/content.js
|
||||
textures/<name>.png
|
||||
textures/<name>.json # for animated textures
|
||||
credits.md
|
||||
@@ -136,5 +139,6 @@ copper_tools.cubi
|
||||
- Packing the same mod twice gives the same bytes, so the file only changes when the mod does.
|
||||
- `deno task build` leaves other `.cubi` files in `server_mods/` alone, so mods from elsewhere can sit next to the ones
|
||||
it builds.
|
||||
- Players get a copy **without** `scripts/server.js`, `scripts/worldgen.js` and the config. See
|
||||
[Networking](../networking/index.md).
|
||||
- `data.json` doesn't hold the blocks `scripts/content.js` registers. The server runs it when it loads the `.cubi`.
|
||||
- Players get a copy **without** `scripts/server.js`, `scripts/worldgen.js`, `scripts/content.js` and the config, but
|
||||
with the blocks the content script registered in its `data.json`. See [Networking](../networking/index.md).
|
||||
|
||||
Reference in New Issue
Block a user