Rename engine to cubi

This commit is contained in:
2026-11-03 17:17:37 -03:00
parent 68b78f053a
commit 98fa45ebd1
109 changed files with 643 additions and 788 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ game's effects are defined this way, in `mods/bworld/effects`.
"id": "copper_tools:swiftness",
"category": "beneficial",
"icon": "copper_tools:swiftness",
"modifiers": [{ "attribute": "bworld:movement_speed", "amount": 0.1, "operation": "add_multiplied_total" }]
"modifiers": [{ "attribute": "cubi:movement_speed", "amount": 0.1, "operation": "add_multiplied_total" }]
}
}
```
+2 -2
View File
@@ -172,12 +172,12 @@ have a `push` too, see [Players](players.md#pushing).
Minecraft's `getEntitiesOfClass`, only the ones of `type` when it's given. Players aren't among them, they're in
`ctx.players`.
Items lying around are entities of type `bworld:item`. A machine that works on them, like a press, finds them, changes
Items lying around are entities of type `cubi:item`. A machine that works on them, like a press, finds them, changes
them with `set_item`, and adds what it made with `ctx.world.spawn_item`, which lays an item down still where it's put,
unlike `drop_item`, which pops it out of a block:
```ts
const [item] = ctx.world.entities_in({ x, y: y - 1, z }, { x: x + 1, y, z: z + 1 }, "bworld:item");
const [item] = ctx.world.entities_in({ x, y: y - 1, z }, { x: x + 1, y, z: z + 1 }, "cubi:item");
const stack = item?.get_item();
if (stack?.id === "bworld:iron_ingot") {
item.set_item(stack.count > 1 ? { ...stack, count: stack.count - 1 } : undefined);
+13 -13
View File
@@ -35,7 +35,7 @@ interface Player {
teleport(x: number, y: number, z: number): void;
readonly health: number; // out of max_health
readonly max_health: number; // 20, or what the bworld:max_health attribute makes it
readonly max_health: number; // 20, or what the cubi:max_health attribute makes it
readonly food: number; // hunger, out of 20
readonly saturation: number; // never above food
@@ -74,7 +74,7 @@ what a player is looking at, like Minecraft's `getPlayerPOVHitResult`:
```ts
const eye = player.eye_position;
const look = player.look_direction;
const reach = player.attribute("bworld:block_interaction_range");
const reach = player.attribute("cubi:block_interaction_range");
const to = { x: eye.x + look.x * reach, y: eye.y + look.y * reach, z: eye.z + look.z * reach };
const hit = ctx.world.raycast(eye, to, { fluids: "source_only" });
```
@@ -106,17 +106,17 @@ even when their game isn't running, like in a background tab.
A player's stats are attributes, like Minecraft's: a base value that modifiers change without touching it.
| Attribute | Base | Meaning |
| --------------------------------- | ---- | -------------------------------------------------------------------------- |
| `bworld:attack_damage` | 1 | How much their hits do. |
| `bworld:attack_speed` | 4 | Full strength attacks a second. Hitting sooner than that does less damage. |
| `bworld:block_interaction_range` | 6 | How far from their eyes they break and use blocks, in blocks. |
| `bworld:entity_interaction_range` | 3 | How far from their eyes they hit entities, in blocks. |
| Attribute | Base | Meaning |
| ------------------------------- | ---- | -------------------------------------------------------------------------- |
| `cubi:attack_damage` | 1 | How much their hits do. |
| `cubi:attack_speed` | 4 | Full strength attacks a second. Hitting sooner than that does less damage. |
| `cubi:block_interaction_range` | 6 | How far from their eyes they break and use blocks, in blocks. |
| `cubi:entity_interaction_range` | 3 | How far from their eyes they hit entities, in blocks. |
```ts
player.add_modifier("bworld:attack_damage", { id: "my_mod:rage", amount: 2, operation: "add_value" });
player.attribute("bworld:attack_damage"); // 3
player.remove_modifier("bworld:attack_damage", "my_mod:rage");
player.add_modifier("cubi:attack_damage", { id: "my_mod:rage", amount: 2, operation: "add_value" });
player.attribute("cubi:attack_damage"); // 3
player.remove_modifier("cubi:attack_damage", "my_mod:rage");
```
The value is the base, plus every `add_value`, plus that times the amount of each `add_multiplied_base`, then times 1
@@ -136,13 +136,13 @@ reaches further gives a modifier while it's held, like Create's extendo grip:
ctx.events.after.tick.subscribe(() => {
for (const player of ctx.players.all()) {
if (player.held_item?.id === "copper_tools:grabber") {
player.add_modifier("bworld:block_interaction_range", {
player.add_modifier("cubi:block_interaction_range", {
id: "copper_tools:grabber",
amount: 3,
operation: "add_value",
});
} else {
player.remove_modifier("bworld:block_interaction_range", "copper_tools:grabber");
player.remove_modifier("cubi:block_interaction_range", "copper_tools:grabber");
}
}
});