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
+6 -6
View File
@@ -75,7 +75,7 @@ Deno.test("a chest keeps items, shows them to everyone, and drops them when brok
assertEquals(opened.open_data, { rows: 3 });
assertEquals(opened.slots.length, 27 + 36);
// nothing got placed on top
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
move_to_menu(t, opened, coal, 4);
assertEquals(menu_items(t.take(1))[4], { id: "bworld:coal", count: 10 });
@@ -213,7 +213,7 @@ Deno.test("bone meal grows wheat until it's fully grown", async () => {
for (let i = 0; i < 7; i++) t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
assertEquals(age(), 7);
assertEquals(container_items(t.take(1), "inventory")[slot]?.count, 1);
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
});
Deno.test("the last bone meal is used up", async () => {
@@ -247,7 +247,7 @@ Deno.test("items are called by their name, or by one made from their id", async
assertEquals(display_name("bworld:iron_ingot"), "Iron Ingot");
assertEquals(display_name("bworld:stone_pickaxe"), "Stone Pickaxe");
assertEquals(display_name("bworld:hoed_dirt"), "Hoed Dirt");
EverythingRegistry.register<ItemRegistry>("items", "test:thing", { texture_id: "engine:missing", name: "A Thing" });
EverythingRegistry.register<ItemRegistry>("items", "test:thing", { texture_id: "cubi:missing", name: "A Thing" });
assertEquals(display_name("test:thing"), "A Thing");
});
@@ -410,7 +410,7 @@ Deno.test("a bucket picks up a water source but not flowing water, and a water b
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
assertEquals(held(), "bworld:water_bucket");
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 100, 0), "cubi:air");
t.send(1, { type: "use_block", x: -2, y: 99, z: 0, face: "top" });
assertEquals(held(), "bworld:bucket");
@@ -432,7 +432,7 @@ Deno.test("only an empty bucket picks up water, and from a stack the water bucke
player.inventory.set_item(0, undefined);
t.game.give(player, "bworld:bucket", 3);
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 100, 0), "cubi:air");
assertEquals(slots(), [["bworld:bucket", 2], ["bworld:water_bucket", 1]]);
});
@@ -443,7 +443,7 @@ Deno.test("a bucket picks up a lava source too, and a lava bucket puts one back"
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
assertEquals(held(), "bworld:lava_bucket");
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 100, 0), "cubi:air");
t.send(1, { type: "use_block", x: -2, y: 99, z: 0, face: "top" });
assertEquals(held(), "bworld:bucket");
+5 -5
View File
@@ -14,7 +14,7 @@ import {
import { block_from_json, validate_block } from "$/common/mod_data.ts";
import { set_state_value } from "$/common/utils.ts";
const cube = BUILTIN_MODELS["engine:cube"];
const cube = BUILTIN_MODELS["cubi:cube"];
Deno.test("cubes resolve the old texture shapes", () => {
assertEquals(resolve_texture("#top", "a:all", cube), "a:all");
@@ -31,7 +31,7 @@ Deno.test("cubes resolve the old texture shapes", () => {
"a:side",
"a:front",
]);
assertEquals(resolve_texture("#nothing", { crop: "a:crop" }), "engine:missing");
assertEquals(resolve_texture("#nothing", { crop: "a:crop" }), "cubi:missing");
});
Deno.test("a cube bakes into six full faces that cull against their neighbors", () => {
@@ -44,12 +44,12 @@ Deno.test("a cube bakes into six full faces that cull against their neighbors",
});
Deno.test("crop and cross models are planes inside the block, seen from both sides", () => {
const crop = bake_model(BUILTIN_MODELS["engine:crop"], { crop: "a:wheat" });
const crop = bake_model(BUILTIN_MODELS["cubi:crop"], { crop: "a:wheat" });
assertEquals(crop.length, 8);
assert(crop.every((q) => !q.flush && q.cull === -1 && !q.shade && q.texture === "a:wheat"));
assertEquals(crop[0].positions.filter((_, i) => i % 3 === 0), [0.25, 0.25, 0.25, 0.25]);
const cross = bake_model(BUILTIN_MODELS["engine:cross"], { cross: "a:flower" });
const cross = bake_model(BUILTIN_MODELS["cubi:cross"], { cross: "a:flower" });
assertEquals(cross.length, 4);
// rescaled so the diagonal planes stay as wide as the block, like minecraft's (0.8 to 15.2 pixels)
for (const quad of cross) {
@@ -99,7 +99,7 @@ Deno.test("an x turn tips a model's top to the north, before its y turn", () =>
Deno.test("variants pick textures by state", () => {
const { block } = block_from_json(JSON.parse(Deno.readTextFileSync("mods/bworld/blocks/wheat.json")).block);
assertEquals(block_variant(block, { age: 5 }).textures, { crop: "bworld:wheat_stage_5" });
assertEquals(block_variant(block, { age: 5 }).model, "engine:crop");
assertEquals(block_variant(block, { age: 5 }).model, "cubi:crop");
assertEquals(block_variant(block).textures, { crop: "bworld:wheat_stage_0" });
// states live above the numeric id
assertEquals(set_state_value(7, block, "age", 3), (3 << 16) | 7);
+5 -5
View File
@@ -25,7 +25,7 @@ const slab: ModelJson = {
const SLAB: Shape = [[0, 0, 0, 1, 0.5, 1]];
Deno.test("a model's shape is the boxes of its elements", () => {
assertEquals(model_shape(BUILTIN_MODELS["engine:cube"]), FULL_SHAPE);
assertEquals(model_shape(BUILTIN_MODELS["cubi:cube"]), FULL_SHAPE);
assertEquals(model_shape(slab), SLAB);
const stairs: ModelJson = {
id: "test:stairs",
@@ -40,8 +40,8 @@ Deno.test("a model's shape is the boxes of its elements", () => {
});
Deno.test("models made of planes get one box around them, so plants can still be pointed at", () => {
assertEquals(model_shape(BUILTIN_MODELS["engine:crop"]), [[0, 0, 0, 1, 1, 1]]);
const [cross] = model_shape(BUILTIN_MODELS["engine:cross"]);
assertEquals(model_shape(BUILTIN_MODELS["cubi:crop"]), [[0, 0, 0, 1, 1, 1]]);
const [cross] = model_shape(BUILTIN_MODELS["cubi:cross"]);
assertEquals(cross[1], 0);
assertEquals(cross[4], 1);
assert(cross[0] < 0.1 && cross[3] > 0.9);
@@ -60,7 +60,7 @@ Deno.test("a block's shape follows its model, or its own shape in pixels, turned
const { block: plant } = block_from_json({
id: "test:plant",
textures: { cross: "test:flower" },
model: "engine:cross",
model: "cubi:cross",
collision: false,
});
assertEquals(collision_shape_at(plant, 0), EMPTY_SHAPE);
@@ -188,7 +188,7 @@ Deno.test("a solid block is drawn in the solid layer and is a whole block to bum
assert(!is_solid(block({ render_layer: "translucent" })), "like glass");
assert(!is_solid(block({ collision: false })));
assert(!is_solid(block({ shape: [[0, 0, 0, 16, 8, 16]] })), "like a slab");
assert(!is_solid(block({ states, variants: { "age=1": { model: "engine:cross" } } })), "not in one of its states");
assert(!is_solid(block({ states, variants: { "age=1": { model: "cubi:cross" } } })), "not in one of its states");
assert(!is_solid(block({ states, variants: { "age=1": { collision_shape: [[0, 0, 0, 16, 8, 16]] } } })));
assert(
is_solid(block({ shape: [[0, 0, 0, 16, 8, 16]], collision_shape: [[0, 0, 0, 16, 16, 16]] })),
+4 -4
View File
@@ -18,7 +18,7 @@ import { decode_level_chunk, type LevelChunk } from "$/common/chunk_streaming.ts
import { decode_chunk, encode_chunk } from "$/server/game/saves.ts";
import { list_chunks, read_chunk, write_chunks } from "$/server/regions.ts";
const ENGINE_TEXTURES = ["engine:missing", ...Array.from({ length: 9 }, (_, i) => `engine:break_${i}`)];
const ENGINE_TEXTURES = ["cubi:missing", ...Array.from({ length: 9 }, (_, i) => `cubi:break_${i}`)];
// mods/bworld and one made from the template, packed into a folder of .bmod files
async function packed_mods() {
@@ -214,14 +214,14 @@ const sizes = (entries: [string, number, number][]) =>
new Map(entries.map(([id, width, height]) => [id, { width, height }]));
Deno.test("the atlas lays out same sized textures by id, with the missing texture among them", () => {
const layout = atlas_layout(sizes([["b:two", 16, 16], ["a:one", 16, 16], ["engine:break_0", 16, 16]]));
const layout = atlas_layout(sizes([["b:two", 16, 16], ["a:one", 16, 16], ["cubi:break_0", 16, 16]]));
assertEquals(layout.size, 64);
// each inside a pixel of border
assertEquals(layout.regions, {
"a:one": { x: 1, y: 1, width: 16, height: 16 },
"b:two": { x: 19, y: 1, width: 16, height: 16 },
"engine:break_0": { x: 37, y: 1, width: 16, height: 16 },
"engine:missing": { x: 1, y: 19, width: 16, height: 16 },
"cubi:break_0": { x: 37, y: 1, width: 16, height: 16 },
"cubi:missing": { x: 1, y: 19, width: 16, height: 16 },
});
const many = atlas_layout(sizes(Array.from({ length: 100 }, (_, i) => [`m:t${i}`, 16, 16])));
assertEquals(many.size, 256);
+1 -1
View File
@@ -137,7 +137,7 @@ Deno.test("/give suggests item ids as they're typed", async () => {
assertEquals(ids("/give ").length, 100);
assert(ids("/give bworld:sto").includes("bworld:stone"));
assert(ids("/give bworld:cab").includes("bworld:cabbage"));
assert(!ids("/give bworld:a").includes("bworld:air"));
assert(!ids("/give bworld:a").includes("cubi:air"));
assertEquals(suggest("/give bworld:tom").suggestions.map((s: { text: string }) => s.text), [
"bworld:tomato",
"bworld:tomato_sauce",
+1 -1
View File
@@ -35,7 +35,7 @@ Deno.test("a crab pot placed in water holds it, and leaves it behind when broken
for (let x = -2; x <= 2; x++) {
for (let z = -2; z <= 2; z++) {
t.game.set_block(x, 99, z, "bworld:stone");
t.game.set_block(x, 100, z, "bworld:air");
t.game.set_block(x, 100, z, "cubi:air");
}
}
t.game.set_block(0, 100, 0, "bworld:water");
+6 -6
View File
@@ -19,7 +19,7 @@ async function setup() {
for (let x = -3; x <= 3; x++) {
for (let z = -3; z <= 3; z++) {
t.game.set_block(x, 99, z, "bworld:stone");
for (let y = 100; y < 103; y++) t.game.set_block(x, y, z, "bworld:air");
for (let y = 100; y < 103; y++) t.game.set_block(x, y, z, "cubi:air");
}
}
t.send(1, { type: "move", x: 0.5, y: 100, z: 3.5, yaw: 0, pitch: 0 });
@@ -57,7 +57,7 @@ Deno.test("a door isn't placed without room for its upper half", async () => {
const { t, held } = await setup();
t.game.set_block(0, 101, 0, "bworld:stone");
t.send(1, { type: "use_block", x: 0, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
assertEquals(t.game.world.get_block_id(0, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 100, 0), "cubi:air");
assertEquals(held(), 64);
});
@@ -74,7 +74,7 @@ Deno.test("right clicking either half opens and closes both, and the door turns
// swung against the west side, its hinge on alice's left
assertEquals(shape(), [[0, 0, 0, 3 / 16, 1, 1]]);
// nothing placed in the doorway
assertEquals(t.game.world.get_block_id(0, 102, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 102, 0), "cubi:air");
t.send(1, { type: "use_block", x: 0, y: 100, z: 0, face: "west", hit: [0, 0.5, 0.5] });
assertEquals([states(0, 100, 0).open, states(0, 101, 0).open], [0, 0]);
@@ -84,13 +84,13 @@ Deno.test("breaking either half breaks the whole door, which drops one door", as
const { t, dropped } = await setup();
t.send(1, { type: "use_block", x: 0, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
t.send(1, { type: "break_block", x: 0, y: 101, z: 0 });
assertEquals(t.game.world.get_block_id(0, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 100, 0), "cubi:air");
assertEquals(t.game.world.get_block_id(0, 101, 0), "cubi:air");
assertEquals(dropped(), ["bworld:oak_door 1"]);
t.send(1, { type: "use_block", x: 1, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
t.send(1, { type: "break_block", x: 1, y: 100, z: 0 });
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
assertEquals(dropped(), ["bworld:oak_door 1", "bworld:oak_door 1"]);
});
+1 -1
View File
@@ -17,7 +17,7 @@ async function mesh_light() {
type: "init",
blocks_registry: JSON.parse(JSON.stringify(blocks)),
models: {},
textures_info: { "engine:missing": { x: 0, y: 0, width: 16, height: 16 } },
textures_info: { "cubi:missing": { x: 0, y: 0, width: 16, height: 16 } },
image: { width: 1024, height: 1024 },
visuals: [],
});
+10 -10
View File
@@ -53,7 +53,7 @@ Deno.test("hoe, fill the can, plant, water, and the crop grows the next morning"
// seeds only go on farmland
t.hold("bworld:wheat_seeds");
t.use(0, 100, 1);
assertEquals(t.game.world.get_block_id(0, 101, 1), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 101, 1), "cubi:air");
t.use(1, 100, 0);
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:wheat");
@@ -107,7 +107,7 @@ Deno.test("digging up the farmland pops the crop off with its drops", async () =
t.game.set_block(1, 100, 0, "bworld:hoed_dirt");
t.game.set_block(1, 101, 0, "bworld:wheat");
t.send(1, { type: "break_block", x: 1, y: 100, z: 0 });
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
const ids = t.game.item_entities().map((e) => e.item.type_id).sort();
assertEquals(ids, ["bworld:dirt", "bworld:wheat_seeds"]);
});
@@ -182,7 +182,7 @@ Deno.test("potatoes and carrots are planted on farmland, and eaten anywhere else
assertEquals(t.game.players()[0].vitals.food, 10, "planted, not eaten");
// on stone it can't be planted, so it's eaten
t.use(0, 99, 1);
assertEquals(t.game.world.get_block_id(0, 100, 1), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 100, 1), "cubi:air");
assertEquals(t.game.players()[0].vitals.food, 11);
});
@@ -220,14 +220,14 @@ Deno.test("rice is planted in water, grows panicles on top without watering, and
// not on land
t.hold("bworld:rice");
t.use(2, 100, 0);
assertEquals(t.game.world.get_block_id(2, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(2, 101, 0), "cubi:air");
// into the water, standing on the dirt under it
t.use(1, 100, 0);
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:rice");
for (let day = 0; day < 3; day++) t.next_morning();
assertEquals(t.state(1, 100, 0, "age"), 3);
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
for (let day = 0; day < 3; day++) t.next_morning();
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:rice_panicles");
assertEquals(t.state(1, 101, 0, "age"), 3, "fully grown after 6 days");
@@ -241,7 +241,7 @@ Deno.test("rice is planted in water, grows panicles on top without watering, and
const dropped = t.game.item_entities().map((e) => e.item.type_id).sort();
assertEquals(dropped, ["bworld:rice", "bworld:rice_panicle"]);
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:water");
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
});
Deno.test("a crop dies into a dead bush the first morning out of its seasons", async () => {
@@ -272,7 +272,7 @@ Deno.test("a two block crop dies whole, its top going without dropping anything"
t.game.tick();
t.game.tick();
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:dead_bush");
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
assertEquals(t.game.item_entities(), []);
});
@@ -329,7 +329,7 @@ Deno.test("blocks without data run on_new_day near players, once a morning", asy
t.game.world.remove_tile(0, 101, 0);
t.next_morning();
assertEquals(t.game.world.get_block_id(0, 102, 0), "bworld:cactus", "grew a block");
assertEquals(t.game.world.get_block_id(0, 103, 0), "bworld:air", "the new block waits for tomorrow");
assertEquals(t.game.world.get_block_id(0, 103, 0), "cubi:air", "the new block waits for tomorrow");
// far from every player, in a chunk that isn't kept, nothing runs
const far = 16 * 40;
@@ -337,7 +337,7 @@ Deno.test("blocks without data run on_new_day near players, once a morning", asy
t.game.set_block(far, 101, 0, "bworld:cactus");
t.game.world.remove_tile(far, 101, 0);
t.next_morning();
assertEquals(t.game.world.get_block_id(far, 102, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(far, 102, 0), "cubi:air");
});
Deno.test("a cactus grows a block a day until it's 4 tall", async () => {
@@ -346,5 +346,5 @@ Deno.test("a cactus grows a block a day until it's 4 tall", async () => {
t.game.set_block(0, 101, 0, "bworld:cactus");
for (let day = 0; day < 6; day++) t.next_morning();
const column = [101, 102, 103, 104, 105].map((y) => t.game.world.get_block_id(0, y, 0));
assertEquals(column, ["bworld:cactus", "bworld:cactus", "bworld:cactus", "bworld:cactus", "bworld:air"]);
assertEquals(column, ["bworld:cactus", "bworld:cactus", "bworld:cactus", "bworld:cactus", "cubi:air"]);
});
+2 -2
View File
@@ -18,7 +18,7 @@ const Y = 100;
async function setup() {
const { game } = await test_game("mods");
for (let x = -1; x <= 5; x++) {
for (let z = -1; z <= 1; z++) game.set_block(x, Y, z, "bworld:air");
for (let z = -1; z <= 1; z++) game.set_block(x, Y, z, "cubi:air");
}
const sides = (x: number, z: number) => {
const info = game.world.get_block_info(x, Y, z)!;
@@ -38,7 +38,7 @@ Deno.test("fences join the fences beside them, and let go when one is broken", a
assertEquals(sides(1, 0), ["east", "west"]);
assertEquals(sides(2, 0), ["west"]);
game.set_block(1, Y, 0, "bworld:air");
game.set_block(1, Y, 0, "cubi:air");
assertEquals(sides(0, 0), []);
assertEquals(sides(2, 0), []);
});
+384 -384
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -31,15 +31,15 @@ async function setup() {
format_version: 1,
item: {
id: JAR,
texture: "engine:missing",
texture: "cubi:missing",
max_stack: 16,
fluid_container: { capacity: 250, full_max_stack: 4 },
layers: [{ texture: "engine:break_0", tint: "fluid" }, { texture: "engine:break_1", tint: "#ff0000" }],
layers: [{ texture: "cubi:break_0", tint: "fluid" }, { texture: "cubi:break_1", tint: "#ff0000" }],
},
});
write("items/flask.json", {
format_version: 1,
item: { id: FLASK, texture: "engine:missing", base_sell_value: 2, fluid_container: { capacity: 1000 } },
item: { id: FLASK, texture: "cubi:missing", base_sell_value: 2, fluid_container: { capacity: 1000 } },
});
const t = await test_game(dir);
Deno.removeSync(dir, { recursive: true });
@@ -69,9 +69,9 @@ Deno.test("a layer tinted fluid is drawn in the fluid's color while there's one,
stack.data = data;
return item_layers(stack);
};
const red = { texture: "engine:break_1", color: [1, 0, 0] };
const red = { texture: "cubi:break_1", color: [1, 0, 0] };
assertEquals(jar(), [red]);
assertEquals(jar(FULL), [{ texture: "engine:break_0", color: [0xa0 / 255, 0x52 / 255, 0x2d / 255] }, red]);
assertEquals(jar(FULL), [{ texture: "cubi:break_0", color: [0xa0 / 255, 0x52 / 255, 0x2d / 255] }, red]);
});
Deno.test("a full fluid container sells for its own value and its fluid's, rounded up", async () => {
+3 -3
View File
@@ -107,7 +107,7 @@ Deno.test("taking the source away drains what flowed from it", async () => {
ticks(game, 60);
assertEquals(level(game, 5, Y, 0), 5);
game.set_block(0, Y, 0, "bworld:air");
game.set_block(0, Y, 0, "cubi:air");
ticks(game, 200);
for (let x = -8; x <= 8; x++) {
for (let z = -8; z <= 8; z++) assertEquals(level(game, x, Y, z), undefined, `at ${x}, ${z}`);
@@ -130,8 +130,8 @@ Deno.test("two sources beside a spot on solid ground make it a source, like infi
assertEquals(level(game, 0, Y, 0), 0);
// and stays one with the others gone
game.set_block(-1, Y, 0, "bworld:air");
game.set_block(1, Y, 0, "bworld:air");
game.set_block(-1, Y, 0, "cubi:air");
game.set_block(1, Y, 0, "cubi:air");
ticks(game, 20);
assertEquals(level(game, 0, Y, 0), 0);
});
+1 -1
View File
@@ -54,7 +54,7 @@ async function setup() {
write("fluids/honey.json", { format_version: 1, fluid: { id: HONEY.id, color: "#e0a030" } });
write("items/jar.json", {
format_version: 1,
item: { id: JAR, texture: "engine:missing", fluid_container: { capacity: 250 } },
item: { id: JAR, texture: "cubi:missing", fluid_container: { capacity: 250 } },
});
write("blocks/tank.json", {
format_version: 1,
+1 -1
View File
@@ -33,7 +33,7 @@ function fluid_mod(dir: string, fluids: Record<string, unknown>, shared_script?:
write("scripts/shared.ts", shared_script);
write("items/maple.json", {
format_version: 1,
item: { id: "testfluids:maple", texture: "engine:missing", name: "Sugar Maple" },
item: { id: "testfluids:maple", texture: "cubi:missing", name: "Sugar Maple" },
});
}
}
+2 -2
View File
@@ -68,7 +68,7 @@ Deno.test("check-mods catches fluids that can't work", () => {
assertEquals(problems({ textures: { top: "a:b" } }), [
"textures must be a texture id or { still, flowing } for a fluid",
]);
assertEquals(problems({ model: "engine:cross" }), ["model isn't for fluids, the engine draws them"]);
assertEquals(problems({ model: "cubi:cross" }), ["model isn't for fluids, the engine draws them"]);
assertEquals(problems({ states: [{ name: "level", bits: 2, default: 0 }] }), [
`states can't have "level", a fluid gets that state of its own`,
]);
@@ -175,7 +175,7 @@ async function mesh(blocks: [number, number, number, string, number?][]) {
// with the registry's gaps, like the client sends it
blocks_registry: registry.map((block) => JSON.parse(JSON.stringify(block))),
models: {},
textures_info: { "engine:missing": { x: 0, y: 0, width: 16, height: 16 } },
textures_info: { "cubi:missing": { x: 0, y: 0, width: 16, height: 16 } },
image: { width: 1024, height: 1024 },
visuals: [],
});
+1 -1
View File
@@ -482,7 +482,7 @@ function gears_mod(): string {
Deno.writeTextFileSync(`${mod}/${path}`, JSON.stringify(json));
};
write("manifest.json", { format_version: 1, id: "gears", name: "Gears", version: "1.0.0" });
write("blocks/gear.json", { format_version: 1, block: { id: "gears:gear", textures: "engine:missing" } });
write("blocks/gear.json", { format_version: 1, block: { id: "gears:gear", textures: "cubi:missing" } });
write("tags/items/gears/teeth.json", { format_version: 1, tag: { values: ["gears:gear"] } });
return mod;
}
+1 -1
View File
@@ -125,7 +125,7 @@ Deno.test("items fall into water, float back up and bob at its surface", async (
for (let z = -3; z <= 3; z++) {
for (let y = 99; y <= 103; y++) {
const inside = x >= 4 && x <= 8 && z >= -2 && z <= 2 && y >= 100;
game.set_block(x, y, z, inside ? (y <= 102 ? "bworld:water" : "bworld:air") : "bworld:stone");
game.set_block(x, y, z, inside ? (y <= 102 ? "bworld:water" : "cubi:air") : "bworld:stone");
}
}
}
+2 -2
View File
@@ -40,11 +40,11 @@ async function setup(recipes: Record<string, unknown> = {}) {
format_version: 1,
item: {
id: CLOUDBERRY,
texture: "engine:missing",
texture: "cubi:missing",
components: { "bworld:juiceable": { juice: 100, color: "#e0a030" } },
},
});
write("items/pebble.json", { format_version: 1, item: { id: PEBBLE, texture: "engine:missing" } });
write("items/pebble.json", { format_version: 1, item: { id: PEBBLE, texture: "cubi:missing" } });
for (const [name, recipe] of Object.entries(recipes)) write(`recipes/${name}`, { format_version: 1, recipe });
try {
const t = await test_game(dir);
+1 -1
View File
@@ -292,7 +292,7 @@ Deno.test("a broken block drops from its loot table, with the tool it was broken
t.game.set_block(1, 100, 0, "testloot:ore");
t.send(1, { type: "break_block", x: 1, y: 100, z: 0 });
// broken by hand, it gives nothing
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 100, 0), "cubi:air");
assertEquals(dropped(), []);
t.send(1, { type: "chat", text: "/give bworld:iron_pickaxe" });
+1 -1
View File
@@ -89,7 +89,7 @@ Deno.test("items lying in a box are found, changed and taken away", async () =>
game.tick();
assertEquals(iron.position, { x: 0.5, y: 100, z: 0.5 });
const found = ctx.world.entities_in({ x: 0, y: 99.5, z: 0 }, { x: 1, y: 101, z: 1 }, "bworld:item");
const found = ctx.world.entities_in({ x: 0, y: 99.5, z: 0 }, { x: 1, y: 101, z: 1 }, "cubi:item");
assertEquals(found.map((entity) => entity.get_item()), [{ id: "bworld:iron_ingot", count: 3 }]);
assertEquals(ctx.world.entities_in({ x: 0, y: 99.5, z: 0 }, { x: 1, y: 101, z: 1 }, "bworld:chicken"), []);
+4 -4
View File
@@ -86,8 +86,8 @@ Deno.test("/summon spawns a mod's entity where the player is", async () => {
// animals don't despawn
assertEquals(chicken.remove_when_far_away(1000), false);
send(1, { type: "chat", text: "/summon bworld:item" });
assertStringIncludes(take(1).find((m) => m.type === "chat").text, "There's no entity bworld:item");
send(1, { type: "chat", text: "/summon cubi:item" });
assertStringIncludes(take(1).find((m) => m.type === "chat").text, "There's no entity cubi:item");
});
Deno.test("solid blocks can't be placed where a mob or player is", async () => {
@@ -104,7 +104,7 @@ Deno.test("solid blocks can't be placed where a mob or player is", async () => {
chicken.set_position(2.1, 101, 1.5);
game.entities.add_entity(chicken);
send(1, { type: "use_block", x: 1, y: 100, z: 1, face: "top" });
assertEquals(game.world.get_block_id(1, 101, 1), "bworld:air");
assertEquals(game.world.get_block_id(1, 101, 1), "cubi:air");
chicken.set_position(2.5, 101, 1.5);
send(1, { type: "use_block", x: 1, y: 100, z: 1, face: "top" });
@@ -113,5 +113,5 @@ Deno.test("solid blocks can't be placed where a mob or player is", async () => {
// nor where a player is, the one placing it included
game.set_block(3, 100, 3, "bworld:stone");
send(1, { type: "use_block", x: 3, y: 100, z: 3, face: "top" });
assertEquals(game.world.get_block_id(3, 101, 3), "bworld:air");
assertEquals(game.world.get_block_id(3, 101, 3), "cubi:air");
});
+1 -1
View File
@@ -112,7 +112,7 @@ Deno.test("a mod made from the template loads and runs", async () => {
for (let i = 0; i < 3 * 20; i++) game.tick();
send(1, { type: "use_block", x: 1, y: y + 1, z: 1, face: "top" });
assert(take(1).some((m) => m.text === "You found the example block! It's been here for 3 seconds."));
assertEquals(game.world.get_block_id(1, y + 2, 1), "bworld:air");
assertEquals(game.world.get_block_id(1, y + 2, 1), "cubi:air");
// the shaped recipe: 4 example items in a square
send(1, { type: "chat", text: "/give copper_tools:example_item 4" });
+1 -1
View File
@@ -63,7 +63,7 @@ Deno.test("new-mod rejects bad and reserved ids", () => {
const dir = temp_mods_dir();
assertThrows(() => create_mod("Has Spaces", "x", dir));
assertThrows(() => create_mod("bworld", "x", dir));
assertThrows(() => create_mod("engine", "x", dir));
assertThrows(() => create_mod("cubi", "x", dir));
create_mod("once", "x", dir);
assertThrows(() => create_mod("once", "x", dir));
Deno.removeSync(dir, { recursive: true });
+2 -2
View File
@@ -43,11 +43,11 @@ Deno.test("a parent can be another mod's model or a built-in one", () => {
const earlier: Record<string, ModelJson> = { "base:slab": { id: "base:slab", elements: [BOX] } };
const { models, problems } = resolve_models([
{ id: "a:slab", parent: "base:slab", textures: { top: "a:top" } },
{ id: "a:cross", parent: "engine:cross" },
{ id: "a:cross", parent: "cubi:cross" },
], (id) => BUILTIN_MODELS[id] ?? earlier[id]);
assertEquals(problems, []);
assertEquals(models[0].elements, [BOX]);
assertEquals(models[1].elements, BUILTIN_MODELS["engine:cross"].elements);
assertEquals(models[1].elements, BUILTIN_MODELS["cubi:cross"].elements);
});
Deno.test("a missing parent and parents that loop are problems, and the models still resolve", () => {
+3 -3
View File
@@ -32,7 +32,7 @@ async function setup(roof = "bworld:stone") {
for (let x = x0; x < x0 + CHUNK_SIZE; x++) {
for (let z = x0; z < x0 + CHUNK_SIZE; z++) {
for (let y = 0; y < FLOOR; y++) world.set_block(x, y, z, "bworld:stone");
for (let y = ROOF + 1; y < CHUNK_HEIGHT; y++) world.set_block(x, y, z, "bworld:air");
for (let y = ROOF + 1; y < CHUNK_HEIGHT; y++) world.set_block(x, y, z, "cubi:air");
}
}
for (let x = x0 - 1; x <= x0 + CHUNK_SIZE; x++) {
@@ -40,7 +40,7 @@ async function setup(roof = "bworld:stone") {
const wall = x < x0 || z < x0 || x >= x0 + CHUNK_SIZE || z >= x0 + CHUNK_SIZE;
world.set_block(x, FLOOR, z, "bworld:stone");
world.set_block(x, ROOF, z, wall ? "bworld:stone" : roof);
for (let y = FLOOR + 1; y < ROOF; y++) world.set_block(x, y, z, wall ? "bworld:stone" : "bworld:air");
for (let y = FLOOR + 1; y < ROOF; y++) world.set_block(x, y, z, wall ? "bworld:stone" : "cubi:air");
}
}
// only the rotwalker, so what else the undergarden spawns doesn't change what can spawn here
@@ -76,7 +76,7 @@ function try_spawning(game: Awaited<ReturnType<typeof setup>>["game"], tries: nu
Deno.test("the server's light is the same as what clients work out", async () => {
const { world, x0 } = await setup();
world.set_block(x0 + 3, FLOOR + 1, x0 + 3, "bworld:light");
world.set_block(x0 + 12, ROOF, x0 + 12, "bworld:air");
world.set_block(x0 + 12, ROOF, x0 + 12, "cubi:air");
const blocks = EverythingRegistry.get_registry<BlockRegistry>("blocks");
const opacity = new Uint8Array(REGION_VOID + 1);
+2 -2
View File
@@ -29,7 +29,7 @@ export function setup(ctx: ServerContext) {
// hangs from the block above and falls when it's gone, which only a server handler can do
ctx.components.register_block("testmod:lantern", {
on_neighbor_change(block) {
if (ctx.world.get_block(block.x, block.y + 1, block.z) === "bworld:air") {
if (ctx.world.get_block(block.x, block.y + 1, block.z) === "cubi:air") {
ctx.world.break_block(block.x, block.y, block.z);
}
},
@@ -196,7 +196,7 @@ Deno.test("a script can tell any block of a change, and one told in on_break hea
// right away, when nothing else is changing
command("/tell 2 100 0 2 100 5");
assertEquals(log(), [["neighbor", "2 100 0", "bworld:air", "2 100 5", 1]]);
assertEquals(log(), [["neighbor", "2 100 0", "cubi:air", "2 100 5", 1]]);
cleanup();
});
+2 -2
View File
@@ -114,7 +114,7 @@ Deno.test("sneaking with an item places it against a block that does something w
hold("testmod:pillar");
send(1, { type: "use_block", x: 1, y: 99, z: 1, face: "top" });
assertEquals(log()["interact"], [false]);
assertEquals(game.world.get_block_id(1, 100, 1), "bworld:air");
assertEquals(game.world.get_block_id(1, 100, 1), "cubi:air");
// the box isn't used, and the pillar's placement knows they were sneaking
move(true);
@@ -195,6 +195,6 @@ Deno.test("how far players reach is an attribute, which their client is sent", a
const sent = take(1).filter((m) => m.type === "attributes").at(-1);
assertEquals([sent.block_interaction_range, sent.entity_interaction_range], [9, 3]);
send(1, { type: "break_block", x: 0, y: 99, z: 9 });
assertEquals(game.world.get_block_id(0, 99, 9), "bworld:air");
assertEquals(game.world.get_block_id(0, 99, 9), "cubi:air");
cleanup();
});
+1 -1
View File
@@ -120,7 +120,7 @@ Deno.test("recipes are found by category in jei's order, and a catalyst's uses a
furnace_uses.find(([type]) => type === "bworld:fuel")?.[1],
all.filter((r) => r.type === "bworld:fuel"),
);
assertEquals(index.find(item("bworld:air"), "recipes"), []);
assertEquals(index.find(item("cubi:air"), "recipes"), []);
});
Deno.test("clicking a fish shows when and where it bites, and the fishing rod's uses are every fish", async () => {
+1 -1
View File
@@ -65,7 +65,7 @@ function recipe_mod(shared_extra = "", recipes: Record<string, unknown> = {}) {
const item = (id: string, components?: unknown) =>
write(`items/${id}.json`, {
format_version: 1,
item: { id: `testrecipes:${id}`, texture: "engine:missing", ...(components ? { components } : {}) },
item: { id: `testrecipes:${id}`, texture: "cubi:missing", ...(components ? { components } : {}) },
});
item("gravel", { "testrecipes:siftable": { into: "testrecipes:flint" } });
item("sand");
+2 -2
View File
@@ -271,7 +271,7 @@ Deno.test("hitting a block runs on_click, using an item runs on_use instead of p
// on a block: used, not placed (even though it can place stone)
send(1, { type: "use_block", x: 1, y: 99, z: 1, face: "top" });
assertEquals(log()["use"]?.length, 2);
assertEquals(game.world.get_block_id(1, 100, 1), "bworld:air");
assertEquals(game.world.get_block_id(1, 100, 1), "cubi:air");
Deno.removeSync(dir, { recursive: true });
});
@@ -343,7 +343,7 @@ Deno.test("ctx.blocks.solid says which blocks are solid, air isn't, and unknown
};
assertEquals(solid("bworld:stone"), "solid true");
assertEquals(solid("testmod:lamp"), "solid true");
assertEquals(solid("bworld:air"), "solid false");
assertEquals(solid("cubi:air"), "solid false");
assertEquals(solid("nobody:block"), "error unknown block nobody:block");
Deno.removeSync(dir, { recursive: true });
});
+1 -1
View File
@@ -56,7 +56,7 @@ async function mesh_chunks(radius: number) {
type: "init",
blocks_registry: JSON.parse(JSON.stringify(blocks)),
models: {},
textures_info: { "engine:missing": { x: 0, y: 0, width: 16, height: 16 } },
textures_info: { "cubi:missing": { x: 0, y: 0, width: 16, height: 16 } },
image: { width: 1024, height: 1024 },
visuals: [],
});
+1 -1
View File
@@ -24,7 +24,7 @@ async function mesh_block(id: string, x: number, middle: Colors, west: Colors |
type: "init",
blocks_registry: JSON.parse(JSON.stringify(blocks)),
models: {},
textures_info: { "engine:missing": { x: 0, y: 0, width: 16, height: 16 } },
textures_info: { "cubi:missing": { x: 0, y: 0, width: 16, height: 16 } },
image: { width: 1024, height: 1024 },
visuals: [],
});
+2 -2
View File
@@ -18,7 +18,7 @@ async function setup() {
for (let x = -3; x <= 3; x++) {
for (let z = -3; z <= 3; z++) {
t.game.set_block(x, 99, z, "bworld:stone");
for (let y = 100; y < 103; y++) t.game.set_block(x, y, z, "bworld:air");
for (let y = 100; y < 103; y++) t.game.set_block(x, y, z, "cubi:air");
}
}
t.send(1, { type: "move", x: 0.5, y: 100, z: 3.5, yaw: 0, pitch: 0 });
@@ -66,7 +66,7 @@ Deno.test("right clicking a trapdoor opens and closes it, and what it's shaped l
assertEquals(shape(), [[0, 0, 0, 1, 1, 3 / 16]]);
assertEquals(collision_shape_at(info, t.game.world.get_block_value(0, 100, 0)), shape());
// still one trapdoor in the world, none placed on top of it
assertEquals(t.game.world.get_block_id(0, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 101, 0), "cubi:air");
t.send(1, { type: "use_block", x: 0, y: 100, z: 0, face: "south", hit: [0.5, 0.5, 3 / 16] });
assertEquals(states(0, 100, 0).open, 0);
+3 -3
View File
@@ -59,9 +59,9 @@ function write_testmod(dir: string, client_script?: string) {
format_version: 1,
item: {
id: "testmod:jar",
texture: "engine:missing",
texture: "cubi:missing",
fluid_container: { capacity: 250 },
layers: [{ texture: "engine:break_0", tint: "fluid" }],
layers: [{ texture: "cubi:break_0", tint: "fluid" }],
},
});
if (client_script) Deno.writeTextFileSync(`${mod}/scripts/client.ts`, client_script);
@@ -89,7 +89,7 @@ Deno.test("the chunk mesher lists the blocks with visuals, and leaves out models
type: "init",
blocks_registry: JSON.parse(JSON.stringify(EverythingRegistry.get_registry<BlockRegistry>("blocks"))),
models: Object.fromEntries(EverythingRegistry.entries("models")),
textures_info: { "engine:missing": { x: 0, y: 0, width: 16, height: 16 } },
textures_info: { "cubi:missing": { x: 0, y: 0, width: 16, height: 16 } },
image: { width: 1024, height: 1024 },
visuals: [[nid("bworld:stone"), true], [nid("bworld:cobblestone"), false]],
});
+2 -2
View File
@@ -54,7 +54,7 @@ Deno.test("a water bucket fills a fence and a bucket empties it, the fence stays
assertEquals(waterlogged(t.game, 2, 100, 0), 1);
assertEquals(held(), "bworld:bucket");
// nothing went on top of it
assertEquals(t.game.world.get_block_id(2, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(2, 101, 0), "cubi:air");
t.send(1, { type: "use_block", x: 2, y: 100, z: 0, face: "top", hit: [0.5, 1, 0.5] });
assertEquals(held(), "bworld:water_bucket");
@@ -88,7 +88,7 @@ Deno.test("rice is only planted in a water source, holds it, and leaves it behin
t.send(1, { type: "use_block", x: -2, y: 100, z: 0, face: "top", hit: [0.5, 1, 0.5] });
assertEquals(t.game.world.get_block_id(-2, 100, 0), "bworld:water");
t.send(1, { type: "use_block", x: 4, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
assertEquals(t.game.world.get_block_id(4, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(4, 100, 0), "cubi:air");
t.send(1, { type: "use_block", x: 2, y: 100, z: 0, face: "top", hit: [0.5, 1, 0.5] });
assertEquals(t.game.world.get_block_id(2, 100, 0), "bworld:rice");
+2 -2
View File
@@ -38,8 +38,8 @@ Deno.test("new players spawn on dry land, all in the same place", async () => {
const joined = join(1, "alice");
const { x, y, z } = joined.spawn;
const ground = game.world.get_block_id(Math.floor(x), y - 1, Math.floor(z));
assert(ground !== "bworld:air" && ground !== "bworld:water", `spawned on ${ground}`);
assertEquals(game.world.get_block_id(Math.floor(x), y, Math.floor(z)), "bworld:air");
assert(ground !== "cubi:air" && ground !== "bworld:water", `spawned on ${ground}`);
assertEquals(game.world.get_block_id(Math.floor(x), y, Math.floor(z)), "cubi:air");
assert(y > SEA_LEVEL, "above the sea");
// the same place for the next new player
+1 -1
View File
@@ -127,5 +127,5 @@ Deno.test("breaking a worm bin drops it, its input and what it made", async () =
t.send(1, { type: "break_block", x: 0, y: 100, z: 0 });
const dropped = t.game.item_entities().map((e) => `${e.item.type_id} ${e.item.amount}`).sort();
assertEquals(dropped, ["bworld:worm_bin 1", "bworld:worms 1", "bworld:worms 5"]);
assert(t.game.world.get_block_id(0, 100, 0) === "bworld:air");
assert(t.game.world.get_block_id(0, 100, 0) === "cubi:air");
});