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
+2 -2
View File
@@ -23,7 +23,7 @@ A block can list several. Their handlers run in the listed order.
In the server script:
```ts
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
interface OxidizesParams {
seconds: number;
@@ -150,7 +150,7 @@ run them too: that's how a player sees a fence join its neighbors the moment the
when the server answers. A component can have rules, handlers, or both, and a block can list one that only has rules.
```ts
import type { SharedContext } from "bworld/shared";
import type { SharedContext } from "cubi/shared";
export function setup(ctx: SharedContext) {
ctx.components.register_block("copper_tools:pipe", {
+1 -1
View File
@@ -8,7 +8,7 @@ draws its machines with.
## Registering
```ts
import type { ClientContext } from "bworld/client";
import type { ClientContext } from "cubi/client";
export function setup(ctx: ClientContext) {
ctx.render.register_visual("copper_tools:shaft", (block, instances) => {
+1 -1
View File
@@ -13,7 +13,7 @@ Every event is a signal you subscribe to. Events come in two kinds:
- **After events** fire once it has happened. They're for reacting, and can't change anything.
```ts
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
// nobody breaks blocks within 16 blocks of the world's center
+3 -3
View File
@@ -46,7 +46,7 @@ on every client, before any script runs. See [Registries](registries.md).
### Server Scripts
```ts
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
// register components and commands, subscribe to events
@@ -64,7 +64,7 @@ world, through [tile data](../blocks/tiledata.md), [containers](../inventories/c
### Client Scripts
```ts
import type { ClientContext } from "bworld/client";
import type { ClientContext } from "cubi/client";
export function setup(ctx: ClientContext) {
ctx.ui.add_inventory_overlay({ on_render(g, screen) {/* ... */} });
@@ -81,7 +81,7 @@ Client code is visible to players and can be changed by them. Never trust it for
### Shared Scripts
```ts
import type { SharedContext } from "bworld/shared";
import type { SharedContext } from "cubi/shared";
export function setup(ctx: SharedContext) {
ctx.components.register_block("copper_tools:pipe", {
+1 -1
View File
@@ -48,7 +48,7 @@ An effect that does something each tick lists components, with their parameters:
The server script registers them during `setup`, in the mod's own namespace:
```ts
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
ctx.components.register_effect<{ every: number }>("copper_tools:rusting", {
+4 -4
View File
@@ -81,7 +81,7 @@ matter, the `id` inside does, except for [tags](../resources/tags.md), whose id
| `version` | yes | The mod's own version, semver like `1.0.0`. |
| `authors` | no | A list of names. |
| `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 `bworld/engine` and hook the engine. See [Engine Access](../misc/engine.md). |
| `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). |
| `credits` | no | A markdown file for licenses and thanks, shown on the Credits screen. Raw HTML in it is shown as text. |
@@ -102,11 +102,11 @@ 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 `bworld/server`, `bworld/client`,
`bworld/shared` and `bworld/worldgen`, and [`bworld/engine`](../misc/engine.md):
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):
```ts
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
```
## `.bmod` Files
+1 -1
View File
@@ -53,7 +53,7 @@ the screen, like Just Enough Items' item list. A menu screen with `inventory_ove
game's fishing minigame. `mods/recipe_viewer` is one.
```ts
import type { ClientContext } from "bworld/client";
import type { ClientContext } from "cubi/client";
export function setup(ctx: ClientContext) {
ctx.ui.add_inventory_overlay({
+1 -1
View File
@@ -11,7 +11,7 @@ Each argument type reads its part of the text and suggests what could go there.
In the server script's `setup`:
```ts
import type { Player, ServerContext } from "bworld/server";
import type { Player, ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
const { literal, argument, types } = ctx.commands;
+1 -1
View File
@@ -29,7 +29,7 @@ can change has to be in this file with its default.
`ctx.config` in the server script holds the settings, with the server's changes made:
```ts
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
interface Config {
max_speed: number;
+5 -5
View File
@@ -15,14 +15,14 @@ Prefer the Game API. Many mods hooking the same thing is a sign it should become
`game_version` has to be one minor version: `~0.1.0` (0.1.0 and later 0.1 patches) or an exact `0.1.2`. Loading the mod
on another version is a load error, so the server doesn't start with it.
Without `engine_access`, importing `bworld/engine` is an error in `check-mods`, when a `.bmod` loads, and when the
script runs. When players join from another site, the confirm screen marks mods that change the engine.
Without `engine_access`, importing `cubi/engine` is an error in `check-mods`, when a `.bmod` loads, and when the script
runs. When players join from another site, the confirm screen marks mods that change the engine.
## Hooking
```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", {
@@ -60,8 +60,8 @@ made changes too. It returns a function that unhooks it.
| `client` | client scripts | `Client`, `LocalPlayer`, `ClientLevel`, `GameRenderer`, `Camera`, `GuiScreen` |
The full lists are in `common/engine_modules.ts`, `server/game/engine_modules.ts` and `client/engine_modules.ts`. The
types are the engine's own source, so `check-mods` typechecks against exactly the engine the mod runs on.
`bworld/engine` also exports `game_version`, the version of the game that's running.
types are the engine's own source, so `check-mods` typechecks against exactly the engine the mod runs on. `cubi/engine`
also exports `game_version`, the version of the game that's running.
- Module exports can't be reassigned, so functions mods may want to change are on plain objects the engine calls
through: `engine.common.physics.move_body` is how every entity moves, on the server and on clients.
+1 -1
View File
@@ -52,7 +52,7 @@ A fluid's name, color and value can depend on its data. The mod's [shared script
gives one of its fluids rules for that, like NeoForge's `FluidType.getDescription` and `FluidTintSource.colorAsStack`:
```ts
import type { SharedContext } from "bworld/shared";
import type { SharedContext } from "cubi/shared";
interface SyrupData {
tree?: string;
+1 -1
View File
@@ -177,7 +177,7 @@ Those become the `bworld:season`, `bworld:biome` and `bworld:time` conditions, w
Server scripts roll tables, fill containers, and add conditions, functions and changes of their own:
```ts
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
// "condition": "my_mod:night" in any table
+2 -2
View File
@@ -166,7 +166,7 @@ recipes. What their fields mean is up to the mod, which registers the type from
[shared script](../concepts/sides.md#shared-scripts), like NeoForge's `RecipeType` with its serializer:
```ts
import type { ItemStack, SharedContext } from "bworld/shared";
import type { ItemStack, SharedContext } from "cubi/shared";
interface SmithingRecipe {
tool: string;
@@ -228,7 +228,7 @@ A recipe that follows from other data, like one for every item with a component,
adds one like a file in `recipes/` with that `type` would, with the rest of its fields from `json`:
```ts
import type { SharedContext } from "bworld/shared";
import type { SharedContext } from "cubi/shared";
export function setup(ctx: SharedContext) {
// a sieve recipe for every item that says what it sifts into
+1 -1
View File
@@ -115,4 +115,4 @@ ctx.components.register_block("my_mod:crop", {
});
```
`Season` is exported from `bworld/server`, `bworld/client` and `bworld/shared`.
`Season` is exported from `cubi/server`, `cubi/client` and `cubi/shared`.
+1 -1
View File
@@ -77,7 +77,7 @@ order they were registered. The base game's trees are in `vegetal_decoration`, s
The worldgen script registers them:
```ts
import type { WorldgenContext } from "bworld/worldgen";
import type { WorldgenContext } from "cubi/worldgen";
export function setup(gen: WorldgenContext) {
gen.register_feature("copper_tools:boulders", (chunk) => {