Change imports

This commit is contained in:
2026-11-04 21:51:26 -03:00
parent 98fa45ebd1
commit ba4b2a8798
270 changed files with 994 additions and 994 deletions
+13 -13
View File
@@ -15,11 +15,11 @@ bworld's modding takes from three places:
A mod is built from up to three layers. Most mods only need the first one or two:
| Layer | Like | What a mod writes | Stability |
| ----------------- | ---------------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------- |
| **Data** | Bedrock behavior packs | JSON in `blocks/`, `items/`, `models/`, `recipes/`, ... | Versioned by `format_version` |
| **Game API** | Minetest's Lua API, Bedrock's Script API | TypeScript against `bworld/server`, `bworld/client`, `bworld/worldgen` | Only breaks with the game's major version |
| **Engine access** | NeoForge's mixins | `import { engine, hook } from "bworld/engine"` | None, tied to one game version |
| Layer | Like | What a mod writes | Stability |
| ----------------- | ---------------------------------------- | ---------------------------------------------------------------- | ----------------------------------------- |
| **Data** | Bedrock behavior packs | JSON in `blocks/`, `items/`, `models/`, `recipes/`, ... | Versioned by `format_version` |
| **Game API** | Minetest's Lua API, Bedrock's Script API | TypeScript against `cubi/server`, `cubi/client`, `cubi/worldgen` | Only breaks with the game's major version |
| **Engine access** | NeoForge's mixins | `import { engine, hook } from "cubi/engine"` | None, tied to one game version |
## Status
@@ -43,15 +43,15 @@ The code is in `common/mod_loader.ts`, `common/mod_data.ts`, `common/mod_check.t
**Not built at all:** common scripts, the registry freeze and hash, overrides.
**Engine access** is built (phase 3): `bworld/engine`, `hook`, `engine_access` and its checks, and `physics` as the
first plain object mods can hook. See [Engine Access](modding/misc/engine.md). The code is in `common/hooks.ts`,
**Engine access** is built (phase 3): `cubi/engine`, `hook`, `engine_access` and its checks, and `physics` as the first
plain object mods can hook. See [Engine Access](modding/misc/engine.md). The code is in `common/hooks.ts`,
`common/mod_api/engine.ts` and the `engine_modules.ts` of each side.
**Known gaps:**
- Manifest `dependencies` version ranges aren't checked, and `game_version` only is for engine access mods.
- Mods can't throw a `CommandError` the server recognizes: it's checked with `instanceof`, and the class isn't in the
API, so a mod's bundled copy is a different class. Export it from `bworld/server`, or recognize it by `name`.
API, so a mod's bundled copy is a different class. Export it from `cubi/server`, or recognize it by `name`.
- Tools only lose durability when their owner dies. Nothing else uses it.
- The GUI scale is always 3: screens work in GUI pixels like NeoForge's, but there's no option to change it yet.
- Worn models haven't been looked at in the game yet, only tested: Artifacts' power glove and feral claws and the giant
@@ -170,7 +170,7 @@ asks for it in its manifest:
```ts
// server.ts: broken blocks drop twice
import { engine, hook } from "bworld/engine";
import { engine, hook } from "cubi/engine";
export function setup() {
hook(engine.server.GameServer.prototype, "pop_item", {
@@ -196,8 +196,8 @@ function hook<T, K extends keyof T>(target: T, method: K, handlers: {
```
- `engine` holds the live modules on each side: `engine.common` everywhere, `engine.server` in server scripts,
`engine.client` in client scripts. The engine puts them on the global object at startup, and `bworld/engine` in a
mod's bundle is a shim that reads them, so a hook on a prototype changes every instance already made.
`engine.client` in client scripts. The engine puts them on the global object at startup, and `cubi/engine` in a mod's
bundle is a shim that reads them, so a hook on a prototype changes every instance already made.
- Types are the engine's own source, so `check-mods` typechecks against exactly the engine the mod will run on.
- Several mods can hook one method: `before` hooks run in priority order, `replace` hooks nest, `after` hooks chain
results. A hook that throws is logged under its mod and skipped.
@@ -210,7 +210,7 @@ function hook<T, K extends keyof T>(target: T, method: K, handlers: {
- Hooks reach one JavaScript realm. Chunk workers run their own copy of the engine, so a client hook doesn't change
meshing.
- It isn't a stable API. A mod with `engine_access` must set `game_version` within one minor version, and loading it on
another is a load error. Without `engine_access`, importing `bworld/engine` is an error.
another is a load error. Without `engine_access`, importing `cubi/engine` is an error.
- A server mod with engine access controls the game worker completely, but the worker still has no Deno permissions. The
confirm screen for other sites lists which mods use it.
- Prefer the Game API. Many mods hooking the same thing is a sign it should become part of the Game API.
@@ -340,7 +340,7 @@ server and a client end up with equal registries and hashes.
`check-mods` rules. Check: a test mod adds a component to `bworld:grass_block`, changes `bworld:glass`'s toughness and
replaces the chest recipe, on both sides and in the hash.
**Phase 3: engine access.** The global engine modules and the `bworld/engine` shim, `hook`, `engine_access` in the
**Phase 3: engine access.** The global engine modules and the `cubi/engine` shim, `hook`, `engine_access` in the
manifest and its checks, and making the engine hookable where mods will want it. Check: test mods hook a server, a
client and a worldgen method, hooks on one method run in priority order, and a throwing hook is logged without breaking
the game.