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
@@ -3,8 +3,8 @@
// artifacts: items worn in curios slots that change the wearer's attributes, see mods/artifacts
import { assertEquals } from "@std/assert";
import { ATTRIBUTES } from "$/server/game/entity/attributes.ts";
import { PLAYER_MENU_EXTRA } from "$/common/protocol.ts";
import { ATTRIBUTES } from "@/server/game/entity/attributes.ts";
import { PLAYER_MENU_EXTRA } from "@/common/protocol.ts";
import { container_items, test_game } from "./helpers.ts";
async function setup() {
+4 -4
View File
@@ -3,10 +3,10 @@
// the base game's block and item behavior: hoeing, chests, furnaces, crops and the watering can
import { assert, assertEquals } from "@std/assert";
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
import { sell_value } from "$/common/inventory.ts";
import { CYCLE_TICKS } from "$/common/time.ts";
import { display_name, get_state_value } from "$/common/utils.ts";
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "@/common/everything_registry.ts";
import { sell_value } from "@/common/inventory.ts";
import { CYCLE_TICKS } from "@/common/time.ts";
import { display_name, get_state_value } from "@/common/utils.ts";
import { container_items, menu_data, menu_items, opened_menu, stone_floor, test_game } from "./helpers.ts";
// deno-lint-ignore no-explicit-any
+4 -4
View File
@@ -3,10 +3,10 @@
// the render benchmark's numbers, its report, and its level, which has to be the same in every run for runs to compare
import { assert, assertEquals } from "@std/assert";
import { type BenchmarkReport, format_report, frame_stats, parse_report } from "$/client/benchmark/report.ts";
import { bench_blocks, BenchTerrain, ZONES } from "$/client/benchmark/bench_level.ts";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { AIR, CHUNK_SIZE, ID_MASK } from "$/common/constants.ts";
import { type BenchmarkReport, format_report, frame_stats, parse_report } from "@/client/benchmark/report.ts";
import { bench_blocks, BenchTerrain, ZONES } from "@/client/benchmark/bench_level.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { AIR, CHUNK_SIZE, ID_MASK } from "@/common/constants.ts";
import { test_game } from "./helpers.ts";
Deno.test("the lows are the fps of the slowest frames", () => {
+2 -2
View File
@@ -3,7 +3,7 @@
// biomes are data, worldgen/biomes/<name>.json in a mod. see common/worldgen/biomes.ts
import { assert, assertEquals } from "@std/assert";
import { CYCLE_TICKS } from "$/common/time.ts";
import { CYCLE_TICKS } from "@/common/time.ts";
import {
biome_from_json,
biome_ids,
@@ -11,7 +11,7 @@ import {
calendar_season,
get_biome,
validate_biome,
} from "$/common/worldgen/biomes.ts";
} from "@/common/worldgen/biomes.ts";
import { test_game } from "./helpers.ts";
const PLAIN = { id: "my_mod:flat", surface: { top: "bworld:grass_block", filler: "bworld:dirt", filler_depth: 3 } };
+3 -3
View File
@@ -10,9 +10,9 @@ import {
BUILTIN_MODELS,
type ModelJson,
resolve_texture,
} from "$/common/block_models.ts";
import { block_from_json, validate_block } from "$/common/mod_data.ts";
import { set_state_value } from "$/common/utils.ts";
} from "@/common/block_models.ts";
import { block_from_json, validate_block } from "@/common/mod_data.ts";
import { set_state_value } from "@/common/utils.ts";
const cube = BUILTIN_MODELS["cubi:cube"];
+1 -1
View File
@@ -4,7 +4,7 @@
// what a client guesses about blocks waits for the server's block_ack before the server's word replaces it, like
// minecraft's BlockStatePredictionHandler, so clicking fast doesn't flicker. see client/level/block_predictions.ts
import { assertEquals } from "@std/assert";
import { BlockPredictions } from "$/client/level/block_predictions.ts";
import { BlockPredictions } from "@/client/level/block_predictions.ts";
import { test_game } from "./helpers.ts";
const CLOSED = { x: 0, y: 100, z: 0, id: "bworld:oak_trapdoor", state: 0 };
+6 -6
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { BUILTIN_MODELS, type ModelJson } from "$/common/block_models.ts";
import { BUILTIN_MODELS, type ModelJson } from "@/common/block_models.ts";
import {
block_shape,
clip_shape,
@@ -13,10 +13,10 @@ import {
model_shape,
raycast_blocks,
type Shape,
} from "$/common/block_shapes.ts";
import { block_from_json, type BlockJson, validate_block } from "$/common/mod_data.ts";
import { move_body } from "$/common/physics.ts";
import { box_overlaps_block } from "$/common/utils.ts";
} from "@/common/block_shapes.ts";
import { block_from_json, type BlockJson, validate_block } from "@/common/mod_data.ts";
import { move_body } from "@/common/physics.ts";
import { box_overlaps_block } from "@/common/utils.ts";
const slab: ModelJson = {
id: "test:slab",
@@ -115,7 +115,7 @@ Deno.test("only a placed block's boxes are in the way of whoever stands there",
});
Deno.test("the outline is the edges of the shape's boxes, a little outside them", async () => {
const { shape_edges } = await import("$/client/rendering/level_renderer.ts");
const { shape_edges } = await import("@/client/rendering/level_renderer.ts");
const cube = shape_edges(FULL_SHAPE);
assertEquals(cube.length, 12);
assert(cube.every((edge) => edge.every((v) => v < 0 || v > 1)));
+12 -12
View File
@@ -4,19 +4,19 @@
// .bmod files: packing mods, reading them back, and the server loading a folder of them
import { assert, assertEquals, assertRejects, assertStringIncludes, assertThrows } from "@std/assert";
import { zipSync } from "fflate";
import { ATLAS_BORDER, atlas_layout, extrude_borders } from "$/client/atlas.ts";
import { MAX_TEXTURE_SIZE } from "$/common/constants.ts";
import { type Bmod, read_bmod, write_bmod } from "$/common/bmod.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { pack_mod } from "$/tools/pack_mod.ts";
import { create_mod } from "$/tools/new_mod.ts";
import { load_bmods } from "$/server/load_bmods.ts";
import { start_host } from "$/server/host.ts";
import { ATLAS_BORDER, atlas_layout, extrude_borders } from "@/client/atlas.ts";
import { MAX_TEXTURE_SIZE } from "@/common/constants.ts";
import { type Bmod, read_bmod, write_bmod } from "@/common/bmod.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { pack_mod } from "@/tools/pack_mod.ts";
import { create_mod } from "@/tools/new_mod.ts";
import { load_bmods } from "@/server/load_bmods.ts";
import { start_host } from "@/server/host.ts";
import { copy_dir } from "./helpers.ts";
import { PROTOCOL_VERSION } from "$/common/protocol.ts";
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";
import { PROTOCOL_VERSION } from "@/common/protocol.ts";
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 = ["cubi:missing", ...Array.from({ length: 9 }, (_, i) => `cubi:break_${i}`)];
+2 -2
View File
@@ -3,8 +3,8 @@
// a game with a worldgen pool, and ticking it like a client loads chunks, for tests/chunk_loading_test.ts and
// tools/chunk_loading_bench.ts
import { type WorkerPort, WorldgenPool } from "$/server/game/worldgen_pool.ts";
import { start_worldgen_workers } from "$/server/worldgen_workers.ts";
import { type WorkerPort, WorldgenPool } from "@/server/game/worldgen_pool.ts";
import { start_worldgen_workers } from "@/server/worldgen_workers.ts";
import { test_game } from "./helpers.ts";
// a game whose chunks come from a pool of workers
+1 -1
View File
@@ -5,7 +5,7 @@
// gets every chunk around them, the same as the game would make them, without the game generating them itself. see
// GameServer.use_worldgen_pool
import { assert, assertEquals } from "@std/assert";
import { is_within_view } from "$/common/chunk_streaming.ts";
import { is_within_view } from "@/common/chunk_streaming.ts";
import { game_with_pool, load_view } from "./chunk_loading.ts";
// the workers and their ports live until the test closes them
+3 -3
View File
@@ -4,9 +4,9 @@
// the server sends the world in whole chunks, like minecraft java: nearest first, in batches the client paces, and
// only to players who can see them
import { assert, assertEquals } from "@std/assert";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
import { decode_level_chunk, encode_level_chunk, is_within_view } from "$/common/chunk_streaming.ts";
import { PROTOCOL_VERSION } from "$/common/protocol.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
import { decode_level_chunk, encode_level_chunk, is_within_view } from "@/common/chunk_streaming.ts";
import { PROTOCOL_VERSION } from "@/common/protocol.ts";
import { sent_block, test_game } from "./helpers.ts";
Deno.test("a chunk comes back as it was encoded, whatever its sections hold", () => {
+3 -3
View File
@@ -4,9 +4,9 @@
// the part of a block's tile data clients see: sent with its chunk, then field by field as it changes, saved, and gone
// with the block
import { assertEquals } from "@std/assert";
import { chunk_key, ClientLevel } from "$/client/level/client_level.ts";
import { Visuals } from "$/client/rendering/visuals.ts";
import { AIR_ID } from "$/common/protocol.ts";
import { chunk_key, ClientLevel } from "@/client/level/client_level.ts";
import { Visuals } from "@/client/rendering/visuals.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { copy_dir, stone_floor, test_game } from "./helpers.ts";
const SHAFT = [1, 99, 1] as const;
+2 -2
View File
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assertEquals } from "@std/assert";
import { ClientMenu } from "$/client/menu.ts";
import { ItemStack } from "$/common/inventory.ts";
import { ClientMenu } from "@/client/menu.ts";
import { ItemStack } from "@/common/inventory.ts";
Deno.test("a mod's screen reads its menu's slots as copies", () => {
const menu = ClientMenu.opened(1, "testmod:box", "Box", null, [{ x: 0, y: 0 }, { x: 18, y: 0 }]);
+2 -2
View File
@@ -3,8 +3,8 @@
import { assertEquals } from "@std/assert";
import { join } from "@std/path";
import { CLIENT_MANIFEST, client_manifest, update_client } from "$/desktop/client_updates.ts";
import { sha256 } from "$/common/utils.ts";
import { CLIENT_MANIFEST, client_manifest, update_client } from "@/desktop/client_updates.ts";
import { sha256 } from "@/common/utils.ts";
const PROTOCOL = 7;
+1 -1
View File
@@ -12,7 +12,7 @@ import {
integer,
literal,
word,
} from "$/common/commands.ts";
} from "@/common/commands.ts";
import { test_game } from "./helpers.ts";
interface Source {
+4 -4
View File
@@ -3,10 +3,10 @@
// farmer's delight's cooking pot: cooks its recipes over a lit furnace, and serves meals into bowls
import { assert, assertEquals } from "@std/assert";
import { ItemStack } from "$/common/inventory.ts";
import { bake_model } from "$/common/block_models.ts";
import { validate_recipe } from "$/common/mod_data.ts";
import { get_state_value, set_state_value } from "$/common/utils.ts";
import { ItemStack } from "@/common/inventory.ts";
import { bake_model } from "@/common/block_models.ts";
import { validate_recipe } from "@/common/mod_data.ts";
import { get_state_value, set_state_value } from "@/common/utils.ts";
import { stone_floor, test_game } from "./helpers.ts";
const POT = [0, 101, 0] as const;
+7 -7
View File
@@ -3,13 +3,13 @@
// the crab pot: a block with a model converted from fishermen's trap's fish trap
import { assert, assertEquals } from "@std/assert";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { bake_block, type ModelJson } from "$/common/block_models.ts";
import { shape_at } from "$/common/block_shapes.ts";
import { get_state_value, set_state_value } from "$/common/utils.ts";
import { ItemStack } from "$/common/inventory.ts";
import { CYCLE_TICKS } from "$/common/time.ts";
import { tag_api } from "$/common/tags.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { bake_block, type ModelJson } from "@/common/block_models.ts";
import { shape_at } from "@/common/block_shapes.ts";
import { get_state_value, set_state_value } from "@/common/utils.ts";
import { ItemStack } from "@/common/inventory.ts";
import { CYCLE_TICKS } from "@/common/time.ts";
import { tag_api } from "@/common/tags.ts";
import { opened_menu, test_game } from "./helpers.ts";
Deno.test("a crab pot is a box 10 pixels tall and deep, drawn with its textures, turned by its facing", async () => {
+3 -3
View File
@@ -4,8 +4,8 @@
// create's basin: items dropped into it go in, a kind to a stack, fluid containers empty into it and fill from it, and
// an empty hand takes the items out
import { assert, assertEquals } from "@std/assert";
import { ItemStack } from "$/common/inventory.ts";
import type { FluidStack, ItemStack as Stack } from "bworld/shared";
import { ItemStack } from "@/common/inventory.ts";
import type { FluidStack, ItemStack as Stack } from "cubi/shared";
import {
apply_basin_recipe,
BASIN_SLOTS,
@@ -13,7 +13,7 @@ import {
BASIN_TANKS,
fill,
insert_item,
} from "$/mods/create/scripts/processing/basin.ts";
} from "@/mods/create/scripts/processing/basin.ts";
import { setup, visual_for } from "./helpers.ts";
const juice = (item: string) => ({ id: "bworld:juice", data: { item } });
+3 -3
View File
@@ -4,9 +4,9 @@
// create's generators besides the hand crank: the water wheel, turned by water flowing past it, and the creative
// motor, which turns at whatever speed it's scrolled to
import { assert, assertEquals } from "@std/assert";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { AIR_ID } from "$/common/protocol.ts";
import { flow_score, motor_step } from "$/mods/create/scripts/kinetics/generators.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { flow_score, motor_step } from "@/mods/create/scripts/kinetics/generators.ts";
import { AXIS, FACING, setup, visual_for } from "./helpers.ts";
// the rpm a generator's params say
+6 -6
View File
@@ -1,12 +1,12 @@
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { AIR_ID } from "$/common/protocol.ts";
import { get_state_value, set_state_value } from "$/common/utils.ts";
import type { Face } from "$/common/mod_api/shared.ts";
import type { ClientContext, Instances, ModelRef, Visual, VisualBlock } from "$/common/mod_api/client.ts";
import { setup as setup_client } from "$/mods/create/scripts/client.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { get_state_value, set_state_value } from "@/common/utils.ts";
import type { Face } from "@/common/mod_api/shared.ts";
import type { ClientContext, Instances, ModelRef, Visual, VisualBlock } from "@/common/mod_api/client.ts";
import { setup as setup_client } from "@/mods/create/scripts/client.ts";
import { stone_floor, test_game } from "../helpers.ts";
// facing and axis states, in the order the importer numbers them
+1 -1
View File
@@ -4,7 +4,7 @@
// create's kinetics: shafts take the speed of what turns them, a hand crank turns them while it's being clicked, a
// block that would turn two ways at once breaks, and a network that takes more than its generators make stops
import { assert, assertEquals } from "@std/assert";
import { AIR_ID } from "$/common/protocol.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { test_game } from "../helpers.ts";
import { AXIS, FACING, setup, visual_for } from "./helpers.ts";
+3 -3
View File
@@ -5,9 +5,9 @@
// pressing recipes, one at a time, or with a basin under it makes compacting recipes in that, and it only ticks while
// it turns
import { assert, assertEquals } from "@std/assert";
import { ItemStack } from "$/common/inventory.ts";
import { BASIN_TANK_CAPACITY } from "$/mods/create/scripts/processing/basin.ts";
import { BASIN_TRAVEL, PRESS_AT } from "$/mods/create/scripts/processing/press.ts";
import { ItemStack } from "@/common/inventory.ts";
import { BASIN_TANK_CAPACITY } from "@/mods/create/scripts/processing/basin.ts";
import { BASIN_TRAVEL, PRESS_AT } from "@/mods/create/scripts/processing/press.ts";
import { FACING, setup, visual_for } from "./helpers.ts";
// a press at 1 101 0 along x, turned by a crank on its west side, with the floor two blocks under it
+8 -8
View File
@@ -3,20 +3,20 @@
// create's recipe types: read and checked when the mod loads, and shown by the recipe viewer
import { assert, assertEquals, assertThrows } from "@std/assert";
import { EverythingRegistry } from "$/common/everything_registry.ts";
import { tag_api } from "$/common/tags.ts";
import type { ClientContext } from "$/common/mod_api/client.ts";
import type { RecipeReader } from "$/common/mod_api/shared.ts";
import { recipe_lookup } from "$/common/mod_loader.ts";
import { EverythingRegistry } from "@/common/everything_registry.ts";
import { tag_api } from "@/common/tags.ts";
import type { ClientContext } from "@/common/mod_api/client.ts";
import type { RecipeReader } from "@/common/mod_api/shared.ts";
import { recipe_lookup } from "@/common/mod_loader.ts";
import {
COMPACTING,
parse_processing,
PRESSING,
processing_type,
type ProcessingRecipe,
} from "$/mods/create/scripts/recipes/processing.ts";
import { inputs, outputs } from "$/mods/recipe_viewer/scripts/recipes.ts";
import { RecipeIndex } from "$/mods/recipe_viewer/scripts/recipes_screen.ts";
} from "@/mods/create/scripts/recipes/processing.ts";
import { inputs, outputs } from "@/mods/recipe_viewer/scripts/recipes.ts";
import { RecipeIndex } from "@/mods/recipe_viewer/scripts/recipes_screen.ts";
import { test_game } from "../helpers.ts";
const lookup = () => ({
+2 -2
View File
@@ -4,8 +4,8 @@
// create's blocks that pass rotation on: gearboxes, clutches and gearshifts worked by verdigris, encased shafts and
// cogs, and chain drives
import { assert, assertEquals } from "@std/assert";
import { AIR_ID } from "$/common/protocol.ts";
import { chain_ratio } from "$/mods/create/scripts/kinetics/connections.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { chain_ratio } from "@/mods/create/scripts/kinetics/connections.ts";
import { AXIS, FACING, setup, visual_for } from "./helpers.ts";
// a crank at 0 100 0 facing west, turning a shaft at 1 100 0 along x, and the speed it turns that line at
+2 -2
View File
@@ -4,9 +4,9 @@
// curios: accessory slots for items in the curios tags, next to the player's inventory, see
// mods/bworld/scripts/curios.ts
import { assert, assertEquals } from "@std/assert";
import { PLAYER_MENU_EXTRA, PROTOCOL_VERSION } from "$/common/protocol.ts";
import { PLAYER_MENU_EXTRA, PROTOCOL_VERSION } from "@/common/protocol.ts";
import { container_items, copy_dir, test_game } from "./helpers.ts";
import type { WorldSave } from "$/server/game/saves.ts";
import type { WorldSave } from "@/server/game/saves.ts";
// deno-lint-ignore no-explicit-any
type Msg = any;
+2 -2
View File
@@ -3,8 +3,8 @@
// farmer's delight's cutting board: holds a stack of anything, shows it on top, and a knife cuts it one at a time
import { assert, assertEquals } from "@std/assert";
import { get_state_value } from "$/common/utils.ts";
import type { ItemData } from "$/common/inventory.ts";
import { get_state_value } from "@/common/utils.ts";
import type { ItemData } from "@/common/inventory.ts";
import { stone_floor, test_game } from "./helpers.ts";
const BOARD = [0, 100, 0] as const;
+7 -7
View File
@@ -3,13 +3,13 @@
// doors: two blocks tall, facing the way the player looks, opened from either half, broken as one
import { assertEquals } from "@std/assert";
import { Container, ItemStack } from "$/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "$/common/protocol.ts";
import { shape_at } from "$/common/block_shapes.ts";
import { bake_block, type ModelJson } from "$/common/block_models.ts";
import { type BlockRegistry, EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
import { get_state_value } from "$/common/utils.ts";
import { update_crafting_result } from "$/server/game/crafting.ts";
import { Container, ItemStack } from "@/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "@/common/protocol.ts";
import { shape_at } from "@/common/block_shapes.ts";
import { bake_block, type ModelJson } from "@/common/block_models.ts";
import { type BlockRegistry, EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
import { get_state_value } from "@/common/utils.ts";
import { update_crafting_result } from "@/server/game/crafting.ts";
import { test_game } from "./helpers.ts";
// alice on a stone floor at y 100, south of 0 100 0 and looking north, with oak doors in hand
+24 -24
View File
@@ -1,21 +1,21 @@
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
// engine access: mods importing bworld/engine and hooking the engine's methods. see docs/modding/misc/engine.md
// engine access: mods importing cubi/engine and hooking the engine's methods. see docs/modding/misc/engine.md
import { assert, assertEquals, assertStringIncludes, assertThrows } from "@std/assert";
import { clear_hooks, expose_engine, hook, loading_mod } from "$/common/hooks.ts";
import { GAME_VERSION } from "$/common/constants.ts";
import { engine_version_problem, validate_manifest } from "$/common/mod_data.ts";
import { ItemStack } from "$/common/inventory.ts";
import { EverythingRegistry } from "$/common/everything_registry.ts";
import { read_bmod } from "$/common/bmod.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { pack_mod } from "$/tools/pack_mod.ts";
import { load_client_mods } from "$/client/mods.ts";
import { LocalPlayer } from "$/client/entity/local_player.ts";
import { Options } from "$/client/options.ts";
import type { Client } from "$/client/client.ts";
import type { ModListing } from "$/common/mod_loader.ts";
import { clear_hooks, expose_engine, hook, loading_mod } from "@/common/hooks.ts";
import { GAME_VERSION } from "@/common/constants.ts";
import { engine_version_problem, validate_manifest } from "@/common/mod_data.ts";
import { ItemStack } from "@/common/inventory.ts";
import { EverythingRegistry } from "@/common/everything_registry.ts";
import { read_bmod } from "@/common/bmod.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { pack_mod } from "@/tools/pack_mod.ts";
import { load_client_mods } from "@/client/mods.ts";
import { LocalPlayer } from "@/client/entity/local_player.ts";
import { Options } from "@/client/options.ts";
import type { Client } from "@/client/client.ts";
import type { ModListing } from "@/common/mod_loader.ts";
import { copy_dir, test_game } from "./helpers.ts";
import { game_with_pool } from "./chunk_loading.ts";
@@ -83,7 +83,7 @@ Deno.test("a server mod hooks GameServer to drop twice, like the plan's example"
write_mod(dir, "double_drops", {
server: [
"server.ts",
`import { engine, hook } from "bworld/engine";
`import { engine, hook } from "cubi/engine";
export function setup() {
hook(engine.server.GameServer.prototype, "pop_item", {
after(game, [x, y, z, stack], entity) {
@@ -108,7 +108,7 @@ Deno.test("a worldgen mod hooks the terrain in engine.common", async () => {
write_mod(dir, "flat_sea", {
worldgen: [
"worldgen.ts",
`import { engine, hook } from "bworld/engine";
`import { engine, hook } from "cubi/engine";
// no ground anywhere, so it's all sea
export function setup() {
hook(engine.common.OverworldTerrain.prototype, "density", { replace: () => -1 });
@@ -134,7 +134,7 @@ Deno.test({
write_mod(dir, "flat_sea", {
worldgen: [
"worldgen.ts",
`import { engine, hook } from "bworld/engine";
`import { engine, hook } from "cubi/engine";
export function setup() {
hook(engine.common.OverworldTerrain.prototype, "density", { replace: () => -1 });
}`,
@@ -162,7 +162,7 @@ Deno.test("a client mod hooks LocalPlayer from its .bmod", async () => {
write_mod(dir, "floaty", {
client: [
"client.ts",
`import { engine, hook } from "bworld/engine";
`import { engine, hook } from "cubi/engine";
// everyone is a block higher than they think
export function setup() {
hook(engine.client.LocalPlayer.prototype, "set_position", {
@@ -325,7 +325,7 @@ Deno.test("hook needs a loading mod with engine access", async () => {
assertThrows(() => hook(new Counter(), "count", {}), Error, "isn't a method");
});
// importing bworld/engine at all
// importing cubi/engine at all
expose_engine({});
const shim = new URL("../common/mod_api/engine.ts", import.meta.url).href;
let import_error: Error | undefined;
@@ -334,24 +334,24 @@ Deno.test("hook needs a loading mod with engine access", async () => {
} catch (e) {
import_error = e as Error;
}
assertStringIncludes(String(import_error), `sneaky imports bworld/engine without "engine_access"`);
assertStringIncludes(String(import_error), `sneaky imports cubi/engine without "engine_access"`);
});
Deno.test("bworld/engine without engine_access is an error in check-mods and in a .bmod", async () => {
Deno.test("cubi/engine without engine_access is an error in check-mods and in a .bmod", async () => {
const dir = Deno.makeTempDirSync({ prefix: "bworld_engine_" });
const script = `import { engine } from "bworld/engine";
const script = `import { engine } from "cubi/engine";
export function setup() {
console.log(engine.common.physics);
}`;
write_mod(dir, "sneaky", { server: ["server.ts", script] }, {});
const [mod] = load_and_check(dir);
assertEquals(mod.report.errors, [
`scripts/server.ts imports bworld/engine, which needs "engine_access": true in manifest.json`,
`scripts/server.ts imports cubi/engine, which needs "engine_access": true in manifest.json`,
]);
// packed anyway, the bundle gives it away
const bytes = await pack_mod(mod);
assertThrows(() => read_bmod(bytes, "sneaky.bmod"), Error, "a script uses bworld/engine");
assertThrows(() => read_bmod(bytes, "sneaky.bmod"), Error, "a script uses cubi/engine");
Deno.removeSync(dir, { recursive: true });
});
+2 -2
View File
@@ -3,8 +3,8 @@
// entities are lit from the light the chunk worker sends back with each mesh, one byte per block: block << 4 | sky
import { assertEquals } from "@std/assert";
import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
import { BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
import { test_game } from "./helpers.ts";
// the middle chunk's light, with a stone roof at y 20 over x 0-7 and a light block at 12, 5, 8
+7 -7
View File
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { ItemStack } from "$/common/inventory.ts";
import { Attribute, ATTRIBUTES } from "$/server/game/entity/attributes.ts";
import { effect_type, EffectInstance } from "$/server/game/entity/effects.ts";
import { DAMAGE } from "$/server/game/entity/entity.ts";
import { register_entity_type } from "$/server/game/entity/entity_types.ts";
import { Goal, GoalSelector, RandomStrollGoal } from "$/server/game/entity/goals.ts";
import { Mob } from "$/server/game/entity/mob.ts";
import { ItemStack } from "@/common/inventory.ts";
import { Attribute, ATTRIBUTES } from "@/server/game/entity/attributes.ts";
import { effect_type, EffectInstance } from "@/server/game/entity/effects.ts";
import { DAMAGE } from "@/server/game/entity/entity.ts";
import { register_entity_type } from "@/server/game/entity/entity_types.ts";
import { Goal, GoalSelector, RandomStrollGoal } from "@/server/game/entity/goals.ts";
import { Mob } from "@/server/game/entity/mob.ts";
import { test_game } from "./helpers.ts";
// a mob for testing, walking like a pig
+3 -3
View File
@@ -4,9 +4,9 @@
// farming: crops grow one stage every morning at 06:00 if their farmland was watered the day before, like stardew
// valley, with minecraft's rules for where crops stand and what they drop
import { assert, assertEquals } from "@std/assert";
import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { CYCLE_TICKS } from "$/common/time.ts";
import { get_state_value } from "$/common/utils.ts";
import { BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { CYCLE_TICKS } from "@/common/time.ts";
import { get_state_value } from "@/common/utils.ts";
import { container_items, stone_floor, test_game } from "./helpers.ts";
// deno-lint-ignore no-explicit-any
+4 -4
View File
@@ -4,12 +4,12 @@
// features are code or data, and use each other: data features with types and modifiers scripts register, scripts
// placing data features. they run by step, then mod, data before code. see docs/modding/worldgen/index.md
import { assert, assertEquals, assertRejects } from "@std/assert";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
import { generate_raw_chunk } from "$/common/generation.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { copy_dir, test_game } from "./helpers.ts";
const SCRIPT = `
import type { WorldgenContext } from "bworld/worldgen";
import type { WorldgenContext } from "cubi/worldgen";
export function setup(gen: WorldgenContext) {
// a type for data features: a pillar of a block
@@ -143,7 +143,7 @@ Deno.test("a data feature whose type no script registers stops the server", asyn
Deno.test("a feature can't be both code and data", async () => {
const clash = with_mod(
{ "worldgen/features/glass_pillar.json": GLASS_PILLAR },
`import type { WorldgenContext } from "bworld/worldgen";
`import type { WorldgenContext } from "cubi/worldgen";
export function setup(gen: WorldgenContext) {
gen.register_feature("testmod:glass_pillar", () => {});
}`,
+8 -8
View File
@@ -2,14 +2,14 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { Container, ItemStack } from "$/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "$/common/protocol.ts";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { bake_block, block_item_texture, type ModelJson } from "$/common/block_models.ts";
import { collision_shape_at, covers_face, FULL_SHAPE, shape_at } from "$/common/block_shapes.ts";
import { move_body } from "$/common/physics.ts";
import { get_state_value } from "$/common/utils.ts";
import { update_crafting_result } from "$/server/game/crafting.ts";
import { Container, ItemStack } from "@/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "@/common/protocol.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { bake_block, block_item_texture, type ModelJson } from "@/common/block_models.ts";
import { collision_shape_at, covers_face, FULL_SHAPE, shape_at } from "@/common/block_shapes.ts";
import { move_body } from "@/common/physics.ts";
import { get_state_value } from "@/common/utils.ts";
import { update_crafting_result } from "@/server/game/crafting.ts";
import { stone_floor, test_game } from "./helpers.ts";
const Y = 100;
+6 -6
View File
@@ -3,12 +3,12 @@
// fishing: throw the hook into water, wait for a bite, reel it in before it gets away
import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
import { ItemStack } from "$/common/inventory.ts";
import { item_texture } from "$/common/utils.ts";
import { tag_api } from "$/common/tags.ts";
import { CYCLE_TICKS } from "$/common/time.ts";
import { biome_season } from "$/common/worldgen/biomes.ts";
import { EverythingRegistry, ItemRegistry } from "@/common/everything_registry.ts";
import { ItemStack } from "@/common/inventory.ts";
import { item_texture } from "@/common/utils.ts";
import { tag_api } from "@/common/tags.ts";
import { CYCLE_TICKS } from "@/common/time.ts";
import { biome_season } from "@/common/worldgen/biomes.ts";
import { menu_data, opened_menu, test_game } from "./helpers.ts";
// deno-lint-ignore no-explicit-any
+3 -3
View File
@@ -4,9 +4,9 @@
// items that hold one fluid, full or empty: how many stack, what they look like, what they sell for, and turning the
// held one into another
import { assertEquals } from "@std/assert";
import { item_tooltip } from "$/client/gui/tooltip.ts";
import { item_layers } from "$/client/rendering/item_renderer.ts";
import { ItemStack, sell_value } from "$/common/inventory.ts";
import { item_tooltip } from "@/client/gui/tooltip.ts";
import { item_layers } from "@/client/rendering/item_renderer.ts";
import { ItemStack, sell_value } from "@/common/inventory.ts";
import { copy_dir, test_game } from "./helpers.ts";
const JAR = "testjars:jar";
+5 -5
View File
@@ -3,11 +3,11 @@
// fluids flowing on the server, like minecraft's water: out from a source, down past edges, and draining away
import { assert, assertEquals } from "@std/assert";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { get_state_value } from "$/common/utils.ts";
import { FLUID_DEFAULTS } from "$/common/everything_registry.ts";
import { FluidFlow } from "$/server/game/fluids.ts";
import { ItemStack } from "$/common/inventory.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { get_state_value } from "@/common/utils.ts";
import { FLUID_DEFAULTS } from "@/common/everything_registry.ts";
import { FluidFlow } from "@/server/game/fluids.ts";
import { ItemStack } from "@/common/inventory.ts";
import { test_game } from "./helpers.ts";
type Game = Awaited<ReturnType<typeof test_game>>["game"];
+2 -2
View File
@@ -4,7 +4,7 @@
// fluid handlers: blocks' from their components, fluid containers', the tanks ctx.fluids.tank_handler keeps for a
// script, and pouring from one into another
import { assertEquals } from "@std/assert";
import { item_handler, transfer } from "$/server/game/fluid_handlers.ts";
import { item_handler, transfer } from "@/server/game/fluid_handlers.ts";
import { copy_dir, stone_floor, test_game } from "./helpers.ts";
const SYRUP = { id: "testmod:syrup" };
@@ -13,7 +13,7 @@ const HONEY = { id: "testmod:honey" };
const JAR = "testmod:jar";
const SERVER_SCRIPT = `
import type { FluidStack, ServerContext } from "bworld/server";
import type { FluidStack, ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
// two tanks kept in its data, reached from every side but the bottom
ctx.components.register_block("testmod:tank", {
+1 -1
View File
@@ -3,7 +3,7 @@
// which way fluid flows and how it pushes what's in it, like minecraft's FlowingFluid.getFlow
import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { type Body, fluid_flow, type FluidInCell, push_by_fluid } from "$/common/physics.ts";
import { type Body, fluid_flow, type FluidInCell, push_by_fluid } from "@/common/physics.ts";
const WATER = "a:water";
+11 -11
View File
@@ -2,16 +2,16 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { EverythingRegistry } from "$/common/everything_registry.ts";
import type { FluidJson } from "$/common/mod_data.ts";
import type { ModListing } from "$/common/mod_loader.ts";
import type { FluidApi } from "$/common/mod_api/shared.ts";
import { read_bmod } from "$/common/bmod.ts";
import { register_mod_data } from "$/common/mod_loader.ts";
import { load_client_mods } from "$/client/mods.ts";
import { fluid_rules } from "$/client/fluid_rules.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { pack_mod } from "$/tools/pack_mod.ts";
import { EverythingRegistry } from "@/common/everything_registry.ts";
import type { FluidJson } from "@/common/mod_data.ts";
import type { ModListing } from "@/common/mod_loader.ts";
import type { FluidApi } from "@/common/mod_api/shared.ts";
import { read_bmod } from "@/common/bmod.ts";
import { register_mod_data } from "@/common/mod_loader.ts";
import { load_client_mods } from "@/client/mods.ts";
import { fluid_rules } from "@/client/fluid_rules.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { pack_mod } from "@/tools/pack_mod.ts";
import { copy_dir, test_game } from "./helpers.ts";
// testfluids: a manifest, the given fluids/ files by file name, and maybe a shared script and an item for it to read
@@ -65,7 +65,7 @@ Deno.test("a fluid with a bad color fails loading", () => {
// syrup is named after the tree in its data and has the color its data says, sap has no rules
const RULES = `
import type { SharedContext } from "bworld/shared";
import type { SharedContext } from "cubi/shared";
export function setup(ctx: SharedContext) {
ctx.fluids.register("testfluids:syrup", {
name: (data: any) => data?.tree && ctx.items.name(data.tree) + " Syrup",
+7 -7
View File
@@ -9,13 +9,13 @@ import {
fluid_height,
fluid_textures,
is_fluid_block,
} from "$/common/everything_registry.ts";
import { block_from_json, block_to_json, type BlockJson, validate_block } from "$/common/mod_data.ts";
import { cube_face_texture } from "$/common/block_models.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
import { get_state_value, set_state_value } from "$/common/utils.ts";
import { cell_index, corner_height, fluid_quads, type FluidCell } from "$/client/workers/fluid_mesh.ts";
import { TERRAIN_VERTEX_BYTES } from "$/client/workers/chunk_messages.ts";
} from "@/common/everything_registry.ts";
import { block_from_json, block_to_json, type BlockJson, validate_block } from "@/common/mod_data.ts";
import { cube_face_texture } from "@/common/block_models.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
import { get_state_value, set_state_value } from "@/common/utils.ts";
import { cell_index, corner_height, fluid_quads, type FluidCell } from "@/client/workers/fluid_mesh.ts";
import { TERRAIN_VERTEX_BYTES } from "@/client/workers/chunk_messages.ts";
import { test_game } from "./helpers.ts";
const OIL: BlockJson = {
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { GameLoop, LoopClock } from "$/server/game/game_loop.ts";
import { GameLoop, LoopClock } from "@/server/game/game_loop.ts";
// a clock tests move by hand. ticks can move it too, to pretend they were slow
class FakeClock implements LoopClock {
+4 -4
View File
@@ -3,10 +3,10 @@
// the golden fixture's hashes, shared by the tests that check generation against it: worldgen_golden_test.ts,
// worldgen_bundle_test.ts and worldgen_pool_test.ts. hashed by name, since numeric ids move whenever a block is added
import { AIR, ID_MASK } from "$/common/constants.ts";
import type { RawChunk } from "$/common/generation.ts";
import { AIR_ID } from "$/common/protocol.ts";
import { sha256 } from "$/common/utils.ts";
import { AIR, ID_MASK } from "@/common/constants.ts";
import type { RawChunk } from "@/common/generation.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { sha256 } from "@/common/utils.ts";
export const FIXTURE = new URL("./fixtures/worldgen_golden.json", import.meta.url);
export const SEEDS = ["golden-1", "golden-2", "golden-3"];
+5 -5
View File
@@ -3,12 +3,12 @@
// the player in the inventory turns to look at the mouse
import { assert, assertEquals } from "@std/assert";
import { gui_player_faces, gui_player_pose } from "$/client/rendering/gui_player.ts";
import { AssetManager } from "$/client/assets.ts";
import type { Texture } from "$/client/renderer/mod.ts";
import { ItemStack } from "$/common/inventory.ts";
import { gui_player_faces, gui_player_pose } from "@/client/rendering/gui_player.ts";
import { AssetManager } from "@/client/assets.ts";
import type { Texture } from "@/client/renderer/mod.ts";
import { ItemStack } from "@/common/inventory.ts";
import { test_game } from "./helpers.ts";
import { part_point, PARTS, pose_to_world } from "$/client/rendering/player_model.ts";
import { part_point, PARTS, pose_to_world } from "@/client/rendering/player_model.ts";
// where a point of the head or body is, in blocks, the viewer at +z with +x on their right and +y up
function where(part_name: "head" | "body", dx: number, dy: number, local: [number, number, number]) {
+2 -2
View File
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { PROTOCOL_VERSION } from "$/common/protocol.ts";
import { TICKS_PER_SECOND } from "$/common/constants.ts";
import { PROTOCOL_VERSION } from "@/common/protocol.ts";
import { TICKS_PER_SECOND } from "@/common/constants.ts";
import { test_game } from "./helpers.ts";
Deno.test("a different protocol version is rejected before anything else", async () => {
+17 -17
View File
@@ -2,23 +2,23 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { resolve, toFileUrl } from "@std/path";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { load_and_check, load_order } from "$/tools/check_mods.ts";
import { mod_data } from "$/common/mod_check.ts";
import type { ServerModSource } from "$/server/game/load_mods.ts";
import { GameServer } from "$/server/game/game_server.ts";
import { start_game } from "$/server/game/load_mods.ts";
import { apply_config } from "$/server/load_bmods.ts";
import { AIR_ID, PROTOCOL_VERSION } from "$/common/protocol.ts";
import { decode_level_chunk } from "$/common/chunk_streaming.ts";
import { CHUNK_AREA, CHUNK_SIZE, ID_MASK } from "$/common/constants.ts";
import type { SavedChunk, SavedChunks, WorldSave } from "$/server/game/saves.ts";
import { BlockRules } from "$/common/block_rules.ts";
import { collision_shape_at, covers_face, is_solid } from "$/common/block_shapes.ts";
import { tag_api } from "$/common/tags.ts";
import { get_state_value, set_state_value, shared_items_api } from "$/common/utils.ts";
import type { Face, SharedWorld } from "$/common/mod_api/shared.ts";
import { setup as setup_shared } from "$/mods/bworld/scripts/shared.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { load_and_check, load_order } from "@/tools/check_mods.ts";
import { mod_data } from "@/common/mod_check.ts";
import type { ServerModSource } from "@/server/game/load_mods.ts";
import { GameServer } from "@/server/game/game_server.ts";
import { start_game } from "@/server/game/load_mods.ts";
import { apply_config } from "@/server/load_bmods.ts";
import { AIR_ID, PROTOCOL_VERSION } from "@/common/protocol.ts";
import { decode_level_chunk } from "@/common/chunk_streaming.ts";
import { CHUNK_AREA, CHUNK_SIZE, ID_MASK } from "@/common/constants.ts";
import type { SavedChunk, SavedChunks, WorldSave } from "@/server/game/saves.ts";
import { BlockRules } from "@/common/block_rules.ts";
import { collision_shape_at, covers_face, is_solid } from "@/common/block_shapes.ts";
import { tag_api } from "@/common/tags.ts";
import { get_state_value, set_state_value, shared_items_api } from "@/common/utils.ts";
import type { Face, SharedWorld } from "@/common/mod_api/shared.ts";
import { setup as setup_shared } from "@/mods/bworld/scripts/shared.ts";
// the repo's own mods/, read once: reading and checking every mod's files is most of starting a game in a test. only
// mods/ is kept, since tests change the temporary folders they make between games
+8 -8
View File
@@ -2,14 +2,14 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals, assertStringIncludes, assertThrows } from "@std/assert";
import { validate_block, validate_item, validate_model, validate_recipe } from "$/common/mod_data.ts";
import type { ModelFileJson } from "$/common/block_models.ts";
import { import_blocks } from "$/tools/importer/blocks.ts";
import { import_items } from "$/tools/importer/items.ts";
import { import_models } from "$/tools/importer/models.ts";
import { import_recipes } from "$/tools/importer/recipes.ts";
import { import_tags } from "$/tools/importer/tags.ts";
import { convert_mcmeta, import_textures } from "$/tools/importer/textures.ts";
import { validate_block, validate_item, validate_model, validate_recipe } from "@/common/mod_data.ts";
import type { ModelFileJson } from "@/common/block_models.ts";
import { import_blocks } from "@/tools/importer/blocks.ts";
import { import_items } from "@/tools/importer/items.ts";
import { import_models } from "@/tools/importer/models.ts";
import { import_recipes } from "@/tools/importer/recipes.ts";
import { import_tags } from "@/tools/importer/tags.ts";
import { convert_mcmeta, import_textures } from "@/tools/importer/textures.ts";
// a java mod's resources in a temporary folder: { "block/gear": {...} } is assets/<namespace>/models/block/gear.json
function resources(models: Record<string, unknown>, namespace = "gears"): string {
+5 -5
View File
@@ -4,11 +4,11 @@
// items drawn with a model, placed in each place they're shown by the model's display transforms
import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { mat4 } from "gl-matrix";
import { display_transform, drawn_as_model, item_model_of } from "$/client/rendering/item_renderer.ts";
import type { DisplayTransform } from "$/common/block_models.ts";
import { ItemStack } from "$/common/inventory.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { create_mod } from "$/tools/new_mod.ts";
import { display_transform, drawn_as_model, item_model_of } from "@/client/rendering/item_renderer.ts";
import type { DisplayTransform } from "@/common/block_models.ts";
import { ItemStack } from "@/common/inventory.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { create_mod } from "@/tools/new_mod.ts";
import { copy_dir, test_game } from "./helpers.ts";
const HANDLE = {
+2 -2
View File
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { CRAFTING_RESULT_SLOT, PLAYER_MENU_CRAFTING } from "$/common/protocol.ts";
import { ItemStack } from "$/common/inventory.ts";
import { CRAFTING_RESULT_SLOT, PLAYER_MENU_CRAFTING } from "@/common/protocol.ts";
import { ItemStack } from "@/common/inventory.ts";
import { container_items, test_game } from "./helpers.ts";
// a stone floor at y 99 so drops have something to land on, high above the generated terrain
+2 -2
View File
@@ -3,8 +3,8 @@
// dropped items are drawn 3d like minecraft's: the sprite front and back, and a side face on every exposed pixel edge
import { assert, assertEquals } from "@std/assert";
import { extrude_item, type ItemQuad } from "$/client/rendering/item_model.ts";
import { TEXTURE_SIZE } from "$/common/constants.ts";
import { extrude_item, type ItemQuad } from "@/client/rendering/item_model.ts";
import { TEXTURE_SIZE } from "@/common/constants.ts";
function mask(pixels: [number, number][], width = TEXTURE_SIZE, height = TEXTURE_SIZE) {
const mask = new Uint8Array(width * height);
+12 -12
View File
@@ -3,18 +3,18 @@
// juice: one fluid named, colored and valued after the bworld:juiceable item in its data, and the juicer that makes it
import { assert, assertEquals, assertRejects } from "@std/assert";
import { EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
import type { FluidJson } from "$/common/mod_data.ts";
import type { ClientContext, Instances, Visual, VisualBlock } from "$/common/mod_api/client.ts";
import { CHUNK_AREA, CHUNK_SIZE } from "$/common/constants.ts";
import { block_value, display_name } from "$/common/utils.ts";
import { sell_value } from "$/common/inventory.ts";
import { block_visuals, Visuals } from "$/client/rendering/visuals.ts";
import { AssetManager } from "$/client/assets.ts";
import { fluid_rules, set_fluid_rules } from "$/client/fluid_rules.ts";
import { setup as setup_client } from "$/mods/bworld/scripts/client.ts";
import { JUICE_VALUE, type JuiceableParams, WINE_VALUE } from "$/mods/bworld/scripts/shared.ts";
import type { FermentableRecipe } from "$/mods/bworld/scripts/fermenting.ts";
import { EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
import type { FluidJson } from "@/common/mod_data.ts";
import type { ClientContext, Instances, Visual, VisualBlock } from "@/common/mod_api/client.ts";
import { CHUNK_AREA, CHUNK_SIZE } from "@/common/constants.ts";
import { block_value, display_name } from "@/common/utils.ts";
import { sell_value } from "@/common/inventory.ts";
import { block_visuals, Visuals } from "@/client/rendering/visuals.ts";
import { AssetManager } from "@/client/assets.ts";
import { fluid_rules, set_fluid_rules } from "@/client/fluid_rules.ts";
import { setup as setup_client } from "@/mods/bworld/scripts/client.ts";
import { JUICE_VALUE, type JuiceableParams, WINE_VALUE } from "@/mods/bworld/scripts/shared.ts";
import type { FermentableRecipe } from "@/mods/bworld/scripts/fermenting.ts";
import { copy_dir, stone_floor, test_game } from "./helpers.ts";
const CLOUDBERRY = "testberries:cloudberry";
+3 -3
View File
@@ -3,9 +3,9 @@
// the keg's input and output tanks, and menus' fluid slots, which its screen shows them in
import { assertEquals } from "@std/assert";
import { EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
import { ItemStack } from "$/common/inventory.ts";
import type { FermentableRecipe } from "$/mods/bworld/scripts/fermenting.ts";
import { EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
import { ItemStack } from "@/common/inventory.ts";
import type { FermentableRecipe } from "@/mods/bworld/scripts/fermenting.ts";
import { opened_menu, test_game } from "./helpers.ts";
const JUICE = { id: "bworld:juice" };
+4 -4
View File
@@ -2,10 +2,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertAlmostEquals, assertEquals, assertFalse } from "@std/assert";
import { LocalPlayer } from "$/client/entity/local_player.ts";
import { InputManager } from "$/client/input_manager.ts";
import { Options } from "$/client/options.ts";
import type { Client } from "$/client/client.ts";
import { LocalPlayer } from "@/client/entity/local_player.ts";
import { InputManager } from "@/client/input_manager.ts";
import { Options } from "@/client/options.ts";
import type { Client } from "@/client/client.ts";
type Blocks = (x: number, y: number, z: number) => boolean;
+7 -7
View File
@@ -3,7 +3,7 @@
// loot tables: rolling them, checking them, and the game using them for blocks, mobs and scripts
import { assert, assertEquals, assertThrows } from "@std/assert";
import { EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
import { EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
import {
type BaseLootContext,
type LootEnvironment,
@@ -11,11 +11,11 @@ import {
number,
roll_loot,
validate_loot_table,
} from "$/common/loot.ts";
import { Tags } from "$/common/tags.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { create_entity } from "$/server/game/entity/entity_types.ts";
import type { LivingEntity } from "$/server/game/entity/living_entity.ts";
} from "@/common/loot.ts";
import { Tags } from "@/common/tags.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { create_entity } from "@/server/game/entity/entity_types.ts";
import type { LivingEntity } from "@/server/game/entity/living_entity.ts";
import { copy_dir, test_game } from "./helpers.ts";
// the tables, registered fresh, with a tool and a tag to match
@@ -232,7 +232,7 @@ function loot_mod(dir: string) {
Deno.mkdirSync(`${mod}/scripts`);
Deno.writeTextFileSync(
`${mod}/scripts/server.ts`,
`import type { ServerContext } from "bworld/server";
`import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
ctx.loot.register_condition("testloot:high", (_params, context) => (context.position?.y ?? 0) > 120);
ctx.loot.register_function("testloot:double", (item) => ({ ...item, count: item.count * 2 }));
+3 -3
View File
@@ -4,13 +4,13 @@
// what machines do to the world through server scripts: read which way water flows, find items lying around and
// change them, push things, break blocks over time, and use items on blocks like a player would
import { assert, assertEquals, assertThrows } from "@std/assert";
import type { ServerContext } from "bworld/server";
import { AIR_ID } from "$/common/protocol.ts";
import type { ServerContext } from "cubi/server";
import { AIR_ID } from "@/common/protocol.ts";
import { copy_dir, stone_floor, test_game } from "./helpers.ts";
// hands the test its context, and has a block that says who right clicked it and an item that gives a stick when used
const SERVER_SCRIPT = `
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
(globalThis as any).machines_ctx = ctx;
ctx.components.register_block("testmod:button", {
+6 -6
View File
@@ -3,11 +3,11 @@
// mods' config.json: their settings, which servers and tests can change, see docs/modding/misc/config.md
import { assert, assertEquals, assertRejects } from "@std/assert";
import { read_bmod, write_bmod } from "$/common/bmod.ts";
import type { ModData } from "$/common/mod_loader.ts";
import { apply_config, load_bmods } from "$/server/load_bmods.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { create_mod } from "$/tools/new_mod.ts";
import { read_bmod, write_bmod } from "@/common/bmod.ts";
import type { ModData } from "@/common/mod_loader.ts";
import { apply_config, load_bmods } from "@/server/load_bmods.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { create_mod } from "@/tools/new_mod.ts";
import { copy_dir, test_game } from "./helpers.ts";
const config_file = (config: unknown) => JSON.stringify({ format_version: 1, config });
@@ -38,7 +38,7 @@ Deno.test("a server script reads its mod's config, with the changes a test makes
create_mod("copper_tools", "Copper Tools", dir);
Deno.writeTextFileSync(
`${dir}/copper_tools/scripts/server.ts`,
`import type { ServerContext } from "bworld/server";
`import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
ctx.components.register_block("copper_tools:announce", {});
ctx.commands.register("settings", {
+3 -3
View File
@@ -3,9 +3,9 @@
// mobs mods define in entities/<name>.json, drawn with a bedrock model from models/<name>.geo.json
import { assert, assertEquals, assertStringIncludes } from "@std/assert";
import { entity_model_from_geo, validate_entity } from "$/common/mod_data.ts";
import { Mob } from "$/server/game/entity/mob.ts";
import { create_entity } from "$/server/game/entity/entity_types.ts";
import { entity_model_from_geo, validate_entity } from "@/common/mod_data.ts";
import { Mob } from "@/server/game/entity/mob.ts";
import { create_entity } from "@/server/game/entity/entity_types.ts";
import { container_items, test_game } from "./helpers.ts";
Deno.test("a bedrock geo.json becomes an entity model with only what the engine uses", () => {
+10 -10
View File
@@ -2,15 +2,15 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { AIR, CHUNK_HEIGHT } from "$/common/constants.ts";
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
import { block_from_json, block_to_json, item_from_json, item_to_json } from "$/common/mod_data.ts";
import { generate_raw_chunk } from "$/common/generation.ts";
import { block_variant } from "$/common/block_models.ts";
import { load_worldgen } from "$/common/worldgen_loader.ts";
import { create_mod } from "$/tools/new_mod.ts";
import { PLAYER_MENU_CRAFTING, PROTOCOL_VERSION } from "$/common/protocol.ts";
import { recipe_lookup } from "$/common/mod_loader.ts";
import { AIR, CHUNK_HEIGHT } from "@/common/constants.ts";
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "@/common/everything_registry.ts";
import { block_from_json, block_to_json, item_from_json, item_to_json } from "@/common/mod_data.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { block_variant } from "@/common/block_models.ts";
import { load_worldgen } from "@/common/worldgen_loader.ts";
import { create_mod } from "@/tools/new_mod.ts";
import { PLAYER_MENU_CRAFTING, PROTOCOL_VERSION } from "@/common/protocol.ts";
import { recipe_lookup } from "@/common/mod_loader.ts";
import { container_items, copy_dir, test_game } from "./helpers.ts";
// mods/bworld plus a mod made from the template, in a temp folder
@@ -202,7 +202,7 @@ Deno.test("mod storage and block data are saved with the world", async () => {
// a server script that uses storage and block data
Deno.writeTextFileSync(
`${dir}/copper_tools/scripts/server.ts`,
`import type { ServerContext } from "bworld/server";
`import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
ctx.components.register_block("copper_tools:announce", {
on_create(block) { block.data = { placed_at: ctx.system.current_tick }; },
+4 -4
View File
@@ -2,10 +2,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals, assertThrows } from "@std/assert";
import { check_mods } from "$/tools/check_mods.ts";
import { MAX_TEXTURE_SIZE } from "$/common/constants.ts";
import { create_mod } from "$/tools/new_mod.ts";
import { item_from_json, item_to_json } from "$/common/mod_data.ts";
import { check_mods } from "@/tools/check_mods.ts";
import { MAX_TEXTURE_SIZE } from "@/common/constants.ts";
import { create_mod } from "@/tools/new_mod.ts";
import { item_from_json, item_to_json } from "@/common/mod_data.ts";
function temp_mods_dir() {
const dir = Deno.makeTempDirSync({ prefix: "bworld_mods_" });
+5 -5
View File
@@ -2,11 +2,11 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { BUILTIN_MODELS, type ModelJson, resolve_models, resolve_texture } from "$/common/block_models.ts";
import { EverythingRegistry } from "$/common/everything_registry.ts";
import { validate_model } from "$/common/mod_data.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { create_mod } from "$/tools/new_mod.ts";
import { BUILTIN_MODELS, type ModelJson, resolve_models, resolve_texture } from "@/common/block_models.ts";
import { EverythingRegistry } from "@/common/everything_registry.ts";
import { validate_model } from "@/common/mod_data.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { create_mod } from "@/tools/new_mod.ts";
import { copy_dir, test_game } from "./helpers.ts";
const BOX = { from: [0, 0, 0], to: [16, 8, 16], faces: { top: { texture: "#top" } } } as ModelJson["elements"][0];
+2 -2
View File
@@ -3,8 +3,8 @@
// "monster" entities go after players and whoever hurts them, like undergarden's rotwalker, see mods/undergarden
import { assert, assertEquals } from "@std/assert";
import { create_entity } from "$/server/game/entity/entity_types.ts";
import { Mob } from "$/server/game/entity/mob.ts";
import { create_entity } from "@/server/game/entity/entity_types.ts";
import { Mob } from "@/server/game/entity/mob.ts";
import { stone_floor, test_game } from "./helpers.ts";
// a stone floor with alice on it, and a rotwalker 3 blocks away
+7 -7
View File
@@ -4,18 +4,18 @@
// monsters spawning on their own in the dark near players, like undergarden's rotwalkers, see natural_spawner.ts and
// mods/undergarden/worldgen/spawns.json
import { assert, assertEquals } from "@std/assert";
import { CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
import { decode_level_chunk } from "$/common/chunk_streaming.ts";
import { CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
import { decode_level_chunk } from "@/common/chunk_streaming.ts";
import {
block_light_emission,
block_light_opacity,
BlockRegistry,
EverythingRegistry,
} from "$/common/everything_registry.ts";
import { LightRegion, REGION_LAYER, REGION_SIZE, REGION_VOID } from "$/client/workers/lighting.ts";
import { create_entity } from "$/server/game/entity/entity_types.ts";
import { Mob } from "$/server/game/entity/mob.ts";
import { NaturalSpawner } from "$/server/game/natural_spawner.ts";
} from "@/common/everything_registry.ts";
import { LightRegion, REGION_LAYER, REGION_SIZE, REGION_VOID } from "@/client/workers/lighting.ts";
import { create_entity } from "@/server/game/entity/entity_types.ts";
import { Mob } from "@/server/game/entity/mob.ts";
import { NaturalSpawner } from "@/server/game/natural_spawner.ts";
import { test_game } from "./helpers.ts";
// chunk 6, 6: a closed stone room with its floor at y 60 and its roof at y 64, and alice standing 40 blocks away.
+6 -6
View File
@@ -4,14 +4,14 @@
// the server's side of a block hearing about changes: its components' on_neighbor_change, after the shared rules, and
// on_state_change when its own states change. blocks hear of changes through a queue, once the change is done
import { assert, assertEquals } from "@std/assert";
import { AIR_ID } from "$/common/protocol.ts";
import { MAX_NEIGHBOR_UPDATES } from "$/common/block_rules.ts";
import { get_state_value } from "$/common/utils.ts";
import type { GameServer } from "$/server/game/game_server.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { MAX_NEIGHBOR_UPDATES } from "@/common/block_rules.ts";
import { get_state_value } from "@/common/utils.ts";
import type { GameServer } from "@/server/game/game_server.ts";
import { copy_dir, stone_floor, test_game } from "./helpers.ts";
const SERVER_SCRIPT = `
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
const log = (event: unknown[]) => ctx.storage.set("log", [...ctx.storage.get<unknown[]>("log") ?? [], event]);
const at = ({ x, y, z }: { x: number; y: number; z: number }) => x + " " + y + " " + z;
@@ -56,7 +56,7 @@ export function setup(ctx: ServerContext) {
`;
const SHARED_SCRIPT = `
import type { SharedContext } from "bworld/shared";
import type { SharedContext } from "cubi/shared";
export function setup(ctx: SharedContext) {
// marks the watcher once anything beside it changes
ctx.components.register_block("testmod:watcher", {
+2 -2
View File
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { eyes_in_water, in_water, move_body } from "$/common/physics.ts";
import { type BlockRegistry, FLUID_DEFAULTS, is_fluid_block } from "$/common/everything_registry.ts";
import { eyes_in_water, in_water, move_body } from "@/common/physics.ts";
import { type BlockRegistry, FLUID_DEFAULTS, is_fluid_block } from "@/common/everything_registry.ts";
const body = (x: number, z: number, vx: number, vz: number) => ({ x, y: 0, z, vx, vy: 0, vz, width: 0.6, height: 1.8 });
// a block at x 0 to 1, z 1 to 2, on a floor
+3 -3
View File
@@ -3,11 +3,11 @@
// what players do with their hands: sneaking while placing and using, how far they reach, and using an item over time
import { assert, assertEquals } from "@std/assert";
import { ATTRIBUTES } from "$/server/game/entity/attributes.ts";
import { ATTRIBUTES } from "@/server/game/entity/attributes.ts";
import { copy_dir, stone_floor, test_game } from "./helpers.ts";
const SERVER_SCRIPT = `
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
const log = (key: string, value: unknown = 1) => {
const all = ctx.storage.get<Record<string, unknown[]>>("log") ?? {};
@@ -40,7 +40,7 @@ export function setup(ctx: ServerContext) {
// a pillar placed upside down while sneaking, like a block whose placement reads sneaking
const SHARED_SCRIPT = `
import type { SharedContext } from "bworld/shared";
import type { SharedContext } from "cubi/shared";
export function setup(ctx: SharedContext) {
ctx.components.register_block("testmod:pillar", {
state_for_placement(placement) { return { flipped: placement.sneaking ? 1 : 0 }; },
+4 -4
View File
@@ -6,10 +6,10 @@ import { assert, assertEquals } from "@std/assert";
import { category_name, type RecipeLayout } from "../mods/recipe_viewer/scripts/categories.ts";
import { inputs as recipe_inputs, outputs } from "../mods/recipe_viewer/scripts/recipes.ts";
import { RecipeIndex } from "../mods/recipe_viewer/scripts/recipes_screen.ts";
import { tag_api } from "$/common/tags.ts";
import { FluidRules } from "$/common/fluids.ts";
import { type BlockRegistry, EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
import type { ClientContext } from "bworld/client";
import { tag_api } from "@/common/tags.ts";
import { FluidRules } from "@/common/fluids.ts";
import { type BlockRegistry, EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
import type { ClientContext } from "cubi/client";
import { test_game } from "./helpers.ts";
const ids = (ingredients: { ids: string[] }[]) => ingredients.map((i) => i.ids.join("|"));
+3 -3
View File
@@ -3,12 +3,12 @@
// ticks blocks schedule ahead with ctx.world.schedule_tick: when and in what order they run, and that they last
import { assert, assertEquals } from "@std/assert";
import { ScheduledTicks } from "$/server/game/scheduled_ticks.ts";
import type { WorldSave } from "$/server/game/saves.ts";
import { ScheduledTicks } from "@/server/game/scheduled_ticks.ts";
import type { WorldSave } from "@/server/game/saves.ts";
import { copy_dir, stone_floor, test_game } from "./helpers.ts";
const SERVER_SCRIPT = `
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
const log = (event: unknown[]) => ctx.storage.set("log", [...ctx.storage.get<unknown[]>("log") ?? [], event]);
ctx.components.register_block("testmod:clock", {
+8 -8
View File
@@ -4,19 +4,19 @@
// recipes a shared script registers with ctx.recipes.register: there on the server and every client alike, for their
// scripts and the crafting grid, without being sent
import { assert, assertEquals, assertRejects } from "@std/assert";
import { EverythingRegistry } from "$/common/everything_registry.ts";
import type { ModListing } from "$/common/mod_loader.ts";
import { read_bmod } from "$/common/bmod.ts";
import { load_client_mods } from "$/client/mods.ts";
import { load_order } from "$/common/mod_check.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { pack_mod } from "$/tools/pack_mod.ts";
import { EverythingRegistry } from "@/common/everything_registry.ts";
import type { ModListing } from "@/common/mod_loader.ts";
import { read_bmod } from "@/common/bmod.ts";
import { load_client_mods } from "@/client/mods.ts";
import { load_order } from "@/common/mod_check.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { pack_mod } from "@/tools/pack_mod.ts";
import { copy_dir, test_game } from "./helpers.ts";
// sifts into what its component says, and a shaped recipe made in code. then sifting and washing as testrecipes' own
// types, found by the item put in
const SHARED = `
import type { SharedContext } from "bworld/shared";
import type { SharedContext } from "cubi/shared";
export function setup(ctx: SharedContext) {
for (const id of ctx.items.ids()) {
const sifts = ctx.items.components(id)["testrecipes:siftable"] as { into: string } | undefined;
+3 -3
View File
@@ -3,12 +3,12 @@
// blocks, entities, players and the world tell scripts their biome's season, see docs/modding/worldgen/biomes.md
import { assertEquals } from "@std/assert";
import type { ServerContext } from "$/common/mod_api/server.ts";
import { get_biome } from "$/common/worldgen/biomes.ts";
import type { ServerContext } from "@/common/mod_api/server.ts";
import { get_biome } from "@/common/worldgen/biomes.ts";
import { copy_dir, test_game } from "./helpers.ts";
const SCRIPT = `
import type { ServerContext } from "bworld/server";
import type { ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
(globalThis as any).season_test = { ctx, created: [] };
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assertEquals, assertThrows } from "@std/assert";
import { server_address } from "$/client/handshake.ts";
import { server_address } from "@/client/handshake.ts";
const DESKTOP_PAGE = new URL("http://127.0.0.1:33549/client/");
const HTTPS_PAGE = new URL("https://bworld.moder.fans/client/");
+2 -2
View File
@@ -3,11 +3,11 @@
import { assert, assertEquals } from "@std/assert";
import { copy_dir, menu_data, menu_items, opened_menu, sent_block, test_game } from "./helpers.ts";
import type { WorldSave } from "$/server/game/saves.ts";
import type { WorldSave } from "@/server/game/saves.ts";
// a mod that uses every part of the server api worth testing, and writes down what happened in its storage
const SERVER_SCRIPT = `
import type { BlockRef, ServerContext } from "bworld/server";
import type { BlockRef, ServerContext } from "cubi/server";
export function setup(ctx: ServerContext) {
const log = (key: string, value: unknown = 1) => {
const all = ctx.storage.get<Record<string, unknown[]>>("log") ?? {};
+3 -3
View File
@@ -4,9 +4,9 @@
// shared scripts' block rules run on clients too, so what a client shows the moment it places, breaks or right clicks
// a block is what the server ends up with
import { assertEquals } from "@std/assert";
import { AIR_ID } from "$/common/protocol.ts";
import { get_state_value } from "$/common/utils.ts";
import type { Face } from "$/common/mod_api/shared.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { get_state_value } from "@/common/utils.ts";
import type { Face } from "@/common/mod_api/shared.ts";
import { type Area, client_of, server_blocks, test_game } from "./helpers.ts";
type Game = Awaited<ReturnType<typeof test_game>>;
+1 -1
View File
@@ -3,7 +3,7 @@
// shift clicking a slot moves its stack to the other part of the screen, like minecraft's quick move
import { assertEquals } from "@std/assert";
import { CRAFTING_RESULT_SLOT, PLAYER_MENU_CRAFTING } from "$/common/protocol.ts";
import { CRAFTING_RESULT_SLOT, PLAYER_MENU_CRAFTING } from "@/common/protocol.ts";
import { container_items, menu_items, opened_menu, stone_floor, test_game } from "./helpers.ts";
// deno-lint-ignore no-explicit-any
+2 -2
View File
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assertEquals } from "@std/assert";
import { encode_skin } from "$/server/game/skins.ts";
import { PROTOCOL_VERSION } from "$/common/protocol.ts";
import { encode_skin } from "@/server/game/skins.ts";
import { PROTOCOL_VERSION } from "@/common/protocol.ts";
import { test_game } from "./helpers.ts";
const SKIN = Deno.readFileSync("assets/sprites/skin_template.png");
+1 -1
View File
@@ -3,7 +3,7 @@
// the base game's bworld:smelting and bworld:fuel recipes, as another mod adding to them sees them
import { assertEquals, assertRejects } from "@std/assert";
import { recipe_lookup } from "$/common/mod_loader.ts";
import { recipe_lookup } from "@/common/mod_loader.ts";
import { copy_dir, test_game } from "./helpers.ts";
// the base game, and a mod after it with these recipes
+1 -1
View File
@@ -3,7 +3,7 @@
// stacks of one item only merge when their data is the same, whatever order its keys are in
import { assertEquals } from "@std/assert";
import { click_slot, Container, type Cursor, ItemStack, LEFT_CLICK } from "$/common/inventory.ts";
import { click_slot, Container, type Cursor, ItemStack, LEFT_CLICK } from "@/common/inventory.ts";
import { test_game } from "./helpers.ts";
const coal = (count: number, data?: unknown) => {
+2 -2
View File
@@ -4,8 +4,8 @@
// swimming as the server sees it: each player's client says when they're swimming, which gives them the short box
// and low eyes, and tells everyone else. how they swim is the client's, see local_player_test.ts
import { assert, assertAlmostEquals, assertEquals, assertNotEquals } from "@std/assert";
import { PLAYER_EYE_HEIGHT, PLAYER_HEIGHT, PLAYER_SWIM_EYE_HEIGHT, PLAYER_SWIM_HEIGHT } from "$/common/constants.ts";
import { part_point, PARTS, type PlayerPose, pose_at, pose_to_world } from "$/client/rendering/player_model.ts";
import { PLAYER_EYE_HEIGHT, PLAYER_HEIGHT, PLAYER_SWIM_EYE_HEIGHT, PLAYER_SWIM_HEIGHT } from "@/common/constants.ts";
import { part_point, PARTS, type PlayerPose, pose_at, pose_to_world } from "@/client/rendering/player_model.ts";
import { test_game } from "./helpers.ts";
// deno-lint-ignore no-explicit-any
+9 -9
View File
@@ -3,15 +3,15 @@
// tags: lists of blocks, items, entities or biomes that every mod can add to, see docs/modding/resources/tags.md
import { assert, assertEquals, assertThrows } from "@std/assert";
import { Container, ItemStack } from "$/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "$/common/protocol.ts";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import type { ManifestJson, TagJson } from "$/common/mod_data.ts";
import { resolve_tags, tag_api, type TagSource } from "$/common/tags.ts";
import { can_stand_on } from "$/common/utils.ts";
import { read_bmod, write_bmod } from "$/common/bmod.ts";
import { update_crafting_result } from "$/server/game/crafting.ts";
import { check_mods } from "$/tools/check_mods.ts";
import { Container, ItemStack } from "@/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "@/common/protocol.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import type { ManifestJson, TagJson } from "@/common/mod_data.ts";
import { resolve_tags, tag_api, type TagSource } from "@/common/tags.ts";
import { can_stand_on } from "@/common/utils.ts";
import { read_bmod, write_bmod } from "@/common/bmod.ts";
import { update_crafting_result } from "@/server/game/crafting.ts";
import { check_mods } from "@/tools/check_mods.ts";
import { copy_dir, test_game } from "./helpers.ts";
// tag files in load order, all item tags unless they say otherwise
+5 -5
View File
@@ -5,11 +5,11 @@
// would have shown
import { assert, assertEquals } from "@std/assert";
import { mat4 } from "gl-matrix";
import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { Frustum } from "$/client/rendering/frustum.ts";
import { group_faces_camera } from "$/client/rendering/level_renderer.ts";
import { FACE_GROUPS, type LayerMesh, TERRAIN_VERTEX_BYTES } from "$/client/workers/chunk_messages.ts";
import { decode_level_chunk } from "$/common/chunk_streaming.ts";
import { BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { Frustum } from "@/client/rendering/frustum.ts";
import { group_faces_camera } from "@/client/rendering/level_renderer.ts";
import { FACE_GROUPS, type LayerMesh, TERRAIN_VERTEX_BYTES } from "@/client/workers/chunk_messages.ts";
import { decode_level_chunk } from "@/common/chunk_streaming.ts";
import { test_game } from "./helpers.ts";
// the matrix the renderer makes for a camera, see update_camera in client/renderer/core.ts
+2 -2
View File
@@ -4,8 +4,8 @@
// the terrain is data: noises, density functions, noise settings and biome sources in mods' worldgen folders, see
// docs/modding/worldgen/terrain.md. tests/worldgen_golden_test.ts checks the base game's makes the same world
import { assert, assertEquals, assertRejects } from "@std/assert";
import { CHUNK_AREA } from "$/common/constants.ts";
import { generate_raw_chunk } from "$/common/generation.ts";
import { CHUNK_AREA } from "@/common/constants.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { copy_dir, test_game } from "./helpers.ts";
// mods/bworld and a mod with files, in a temp folder
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assertEquals } from "@std/assert";
import { TextInput } from "$/client/gui/widgets.ts";
import { TextInput } from "@/client/gui/widgets.ts";
// the text with the selection in [brackets], or a | at the caret when nothing is selected
function show(input: TextInput) {
+6 -6
View File
@@ -4,12 +4,12 @@
// animated textures: textures/<name>.json, carrying it through .bmod files, and playing it a tick at a time
import { assertEquals, assertThrows } from "@std/assert";
import { zipSync } from "fflate";
import { read_bmod, texture_size_problem } from "$/common/bmod.ts";
import { texture_animation, validate_texture_json } from "$/common/texture_animation.ts";
import { AnimatedTexture } from "$/client/texture_animations.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { pack_mod } from "$/tools/pack_mod.ts";
import { create_mod } from "$/tools/new_mod.ts";
import { read_bmod, texture_size_problem } from "@/common/bmod.ts";
import { texture_animation, validate_texture_json } from "@/common/texture_animation.ts";
import { AnimatedTexture } from "@/client/texture_animations.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { pack_mod } from "@/tools/pack_mod.ts";
import { create_mod } from "@/tools/new_mod.ts";
import { copy_dir } from "./helpers.ts";
// a png's header and nothing else, enough for everything that only reads its size
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { clock, CYCLE_TICKS, DAY_TICKS, daylight, format_clock, is_day, NIGHT_TICKS } from "$/common/time.ts";
import { clock, CYCLE_TICKS, DAY_TICKS, daylight, format_clock, is_day, NIGHT_TICKS } from "@/common/time.ts";
import { test_game } from "./helpers.ts";
Deno.test("a day is 30 minutes and a night 10, tick 0 is 06:00 of day 1", () => {
+5 -5
View File
@@ -3,11 +3,11 @@
// blocks with a "tint" are drawn in their biome's grass or foliage color, blended across biome edges, or a fixed one. water is its biome's water color
import { assert, assertEquals } from "@std/assert";
import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
import { generate_raw_chunk } from "$/common/generation.ts";
import { get_biome } from "$/common/worldgen/biomes.ts";
import { type LayerMesh, TERRAIN_VERTEX_BYTES } from "$/client/workers/chunk_messages.ts";
import { BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { get_biome } from "@/common/worldgen/biomes.ts";
import { type LayerMesh, TERRAIN_VERTEX_BYTES } from "@/client/workers/chunk_messages.ts";
import { test_game } from "./helpers.ts";
type Colors = { grass: number; foliage: number; water?: number };
+7 -7
View File
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { Container, ItemStack } from "$/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "$/common/protocol.ts";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { bake_block, type ModelJson } from "$/common/block_models.ts";
import { collision_shape_at, shape_at } from "$/common/block_shapes.ts";
import { get_state_value } from "$/common/utils.ts";
import { update_crafting_result } from "$/server/game/crafting.ts";
import { Container, ItemStack } from "@/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "@/common/protocol.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { bake_block, type ModelJson } from "@/common/block_models.ts";
import { collision_shape_at, shape_at } from "@/common/block_shapes.ts";
import { get_state_value } from "@/common/utils.ts";
import { update_crafting_result } from "@/server/game/crafting.ts";
import { test_game } from "./helpers.ts";
// alice on a stone floor at y 100, south of 0 100 0 and looking north, with oak trapdoors in hand
+9 -9
View File
@@ -3,15 +3,15 @@
// what the verdigris tests build with: a player on a stone floor placing things, and the world read the way the
// verdigris scripts read it
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import type { Face } from "$/common/mod_api/shared.ts";
import { AIR_ID } from "$/common/protocol.ts";
import { block_states } from "$/common/utils.ts";
import type { WorldSave } from "$/server/game/saves.ts";
import { joined_cell } from "$/mods/bworld/scripts/verdigris/joins.ts";
import type { BlockReader } from "$/mods/bworld/scripts/verdigris/signals.ts";
import { FACES } from "$/mods/bworld/scripts/verdigris/sides.ts";
import { wire_at } from "$/mods/bworld/scripts/verdigris/wires.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import type { Face } from "@/common/mod_api/shared.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { block_states } from "@/common/utils.ts";
import type { WorldSave } from "@/server/game/saves.ts";
import { joined_cell } from "@/mods/bworld/scripts/verdigris/joins.ts";
import type { BlockReader } from "@/mods/bworld/scripts/verdigris/signals.ts";
import { FACES } from "@/mods/bworld/scripts/verdigris/sides.ts";
import { wire_at } from "@/mods/bworld/scripts/verdigris/wires.ts";
import { type Area, test_game } from "./helpers.ts";
export type Pos = [number, number, number];
+8 -8
View File
@@ -3,14 +3,14 @@
// the blocks that make and use verdigris signals
import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { bake_block, type BakedQuad, type ModelJson } from "$/common/block_models.ts";
import { block_shape } from "$/common/block_shapes.ts";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import type { Face } from "$/common/mod_api/shared.ts";
import { AIR_ID } from "$/common/protocol.ts";
import { default_block_value, set_state_value } from "$/common/utils.ts";
import { ways_out } from "$/mods/bworld/scripts/verdigris/joins.ts";
import { FACE_OFFSETS, FACES, OPPOSITE, step } from "$/mods/bworld/scripts/verdigris/sides.ts";
import { bake_block, type BakedQuad, type ModelJson } from "@/common/block_models.ts";
import { block_shape } from "@/common/block_shapes.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import type { Face } from "@/common/mod_api/shared.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { default_block_value, set_state_value } from "@/common/utils.ts";
import { ways_out } from "@/mods/bworld/scripts/verdigris/joins.ts";
import { FACE_OFFSETS, FACES, OPPOSITE, step } from "@/mods/bworld/scripts/verdigris/sides.ts";
import { client_of, server_blocks, test_game } from "./helpers.ts";
import { AREA, type Builder, builder, type Pos } from "./verdigris.ts";
+10 -10
View File
@@ -4,16 +4,16 @@
// verdigris wire: how it's drawn on the faces of its cell, how it joins, and its nets' power
import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { Alea } from "@paulaboks/rng";
import { bake_block, type BakedQuad, FACE_INDEX, type ModelJson } from "$/common/block_models.ts";
import { block_shape, is_solid } from "$/common/block_shapes.ts";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import type { Face } from "$/common/mod_api/shared.ts";
import { AIR_ID } from "$/common/protocol.ts";
import { default_block_value, set_state_value } from "$/common/utils.ts";
import type { SavedChunk, WorldSave } from "$/server/game/saves.ts";
import { can_cover, ways_out } from "$/mods/bworld/scripts/verdigris/joins.ts";
import { DIRECTIONS, FACE_OFFSETS, FACES, OPPOSITE, step } from "$/mods/bworld/scripts/verdigris/sides.ts";
import { NetIndex } from "$/mods/bworld/scripts/verdigris/wires.ts";
import { bake_block, type BakedQuad, FACE_INDEX, type ModelJson } from "@/common/block_models.ts";
import { block_shape, is_solid } from "@/common/block_shapes.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import type { Face } from "@/common/mod_api/shared.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { default_block_value, set_state_value } from "@/common/utils.ts";
import type { SavedChunk, WorldSave } from "@/server/game/saves.ts";
import { can_cover, ways_out } from "@/mods/bworld/scripts/verdigris/joins.ts";
import { DIRECTIONS, FACE_OFFSETS, FACES, OPPOSITE, step } from "@/mods/bworld/scripts/verdigris/sides.ts";
import { NetIndex } from "@/mods/bworld/scripts/verdigris/wires.ts";
import { client_of, server_blocks, test_game } from "./helpers.ts";
import { AREA, type Builder, builder, type Pos } from "./verdigris.ts";
+15 -15
View File
@@ -5,19 +5,19 @@
// draws their instances, placed and turned by the time
import { assert, assertEquals, assertRejects, assertThrows } from "@std/assert";
import { mat4 } from "gl-matrix";
import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
import { block_value } from "$/common/utils.ts";
import type { ModListing } from "$/common/mod_loader.ts";
import { read_bmod } from "$/common/bmod.ts";
import type { FluidInstance, Instances, RotatingInstance, Visual } from "$/common/mod_api/client.ts";
import { block_visuals, instance_quads, InstanceGroup, pack_model, Visuals } from "$/client/rendering/visuals.ts";
import { INSTANCE_FLOATS, INSTANCED_BUFFERS, terrain_shader_src, type Texture } from "$/client/renderer/mod.ts";
import type { BakedQuad } from "$/common/block_models.ts";
import { AssetManager } from "$/client/assets.ts";
import { load_client_mods } from "$/client/mods.ts";
import { load_and_check } from "$/tools/check_mods.ts";
import { pack_mod } from "$/tools/pack_mod.ts";
import { BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
import { block_value } from "@/common/utils.ts";
import type { ModListing } from "@/common/mod_loader.ts";
import { read_bmod } from "@/common/bmod.ts";
import type { FluidInstance, Instances, RotatingInstance, Visual } from "@/common/mod_api/client.ts";
import { block_visuals, instance_quads, InstanceGroup, pack_model, Visuals } from "@/client/rendering/visuals.ts";
import { INSTANCE_FLOATS, INSTANCED_BUFFERS, terrain_shader_src, type Texture } from "@/client/renderer/mod.ts";
import type { BakedQuad } from "@/common/block_models.ts";
import { AssetManager } from "@/client/assets.ts";
import { load_client_mods } from "@/client/mods.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { pack_mod } from "@/tools/pack_mod.ts";
import { copy_dir, test_game } from "./helpers.ts";
const HALF = {
@@ -499,7 +499,7 @@ Deno.test("client scripts register visuals during setup, for blocks that exist",
await load_client_mods([listing], [bmod]);
};
await load(`
import type { ClientContext } from "bworld/client";
import type { ClientContext } from "cubi/client";
export function setup(ctx: ClientContext) {
ctx.render.register_visual("testmod:shaft", (_block, instances) => {
instances.rotating();
@@ -513,7 +513,7 @@ Deno.test("client scripts register visuals during setup, for blocks that exist",
await assertRejects(
() =>
load(`
import type { ClientContext } from "bworld/client";
import type { ClientContext } from "cubi/client";
export function setup(ctx: ClientContext) {
ctx.render.register_visual("testmod:gear", () => ({}));
}
+3 -3
View File
@@ -3,10 +3,10 @@
// health, hunger and saturation, with minecraft's rules
import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { MAX_HEALTH, Vitals } from "$/server/game/vitals.ts";
import { MAX_HEALTH, Vitals } from "@/server/game/vitals.ts";
import { test_game } from "./helpers.ts";
import { EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
import { ItemStack } from "$/common/inventory.ts";
import { EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
import { ItemStack } from "@/common/inventory.ts";
// deno-lint-ignore no-explicit-any
type Msg = any;
+2 -2
View File
@@ -4,8 +4,8 @@
// waterlogging, like minecraft's: a fence holds a water source, which flows out of it, can be bucketed in and out, and
// is left behind when the fence is broken
import { assert, assertEquals } from "@std/assert";
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
import { get_state_value, set_state_value } from "$/common/utils.ts";
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
import { get_state_value, set_state_value } from "@/common/utils.ts";
import { test_game } from "./helpers.ts";
// a player at 0.5 100 0.5 on stone, holding what they're given
+7 -7
View File
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals, assertRejects } from "@std/assert";
import { CHUNK_AREA, CHUNK_SIZE } from "$/common/constants.ts";
import { Container, ItemStack } from "$/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "$/common/protocol.ts";
import { generate_raw_chunk } from "$/common/generation.ts";
import { get_biome } from "$/common/worldgen/biomes.ts";
import { update_crafting_result } from "$/server/game/crafting.ts";
import { recipe_lookup } from "$/common/mod_loader.ts";
import { CHUNK_AREA, CHUNK_SIZE } from "@/common/constants.ts";
import { Container, ItemStack } from "@/common/inventory.ts";
import { CRAFTING_RESULT_SLOT } from "@/common/protocol.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { get_biome } from "@/common/worldgen/biomes.ts";
import { update_crafting_result } from "@/server/game/crafting.ts";
import { recipe_lookup } from "@/common/mod_loader.ts";
import { copy_dir, test_game } from "./helpers.ts";
Deno.test("recipes that take planks take any kind, even mixed, but nothing else", async () => {
+4 -4
View File
@@ -2,10 +2,10 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { AIR_ID } from "$/common/protocol.ts";
import { CHUNK_AREA } from "$/common/constants.ts";
import { CHUNK_VOLUME, decode_chunk, encode_chunk, SavedChunk } from "$/server/game/saves.ts";
import { list_chunks, read_chunk, region_file, write_chunks } from "$/server/regions.ts";
import { AIR_ID } from "@/common/protocol.ts";
import { CHUNK_AREA } from "@/common/constants.ts";
import { CHUNK_VOLUME, decode_chunk, encode_chunk, SavedChunk } from "@/server/game/saves.ts";
import { list_chunks, read_chunk, region_file, write_chunks } from "@/server/regions.ts";
import { sent_block, test_game } from "./helpers.ts";
function chunk_data(seed: number, palette_size = 3) {
+1 -1
View File
@@ -3,7 +3,7 @@
// how long generating chunks takes, on one thread. moving the terrain from code to data was held to 15% slower here,
// and cost about 9% (144.5 to 157.7 ms on the machine it was measured on). deno task bench
import { generate_raw_chunk } from "$/common/generation.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { test_game } from "./helpers.ts";
const SEED = "bench-seed";
+2 -2
View File
@@ -4,8 +4,8 @@
// the bundle is everything generation reads, so a worker sent it generates what the game does. see
// common/worldgen_bundle.ts
import { assert, assertEquals } from "@std/assert";
import { EverythingRegistry } from "$/common/everything_registry.ts";
import { load_bundle } from "$/common/worldgen_bundle.ts";
import { EverythingRegistry } from "@/common/everything_registry.ts";
import { load_bundle } from "@/common/worldgen_bundle.ts";
import { test_game } from "./helpers.ts";
import { golden_chunks, namer, raw_hash, recorded, SEEDS } from "./golden.ts";
+2 -2
View File
@@ -3,8 +3,8 @@
// the base game's worldgen features, see mods/bworld/scripts/worldgen.ts
import { assert, assertEquals } from "@std/assert";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, ID_MASK } from "$/common/constants.ts";
import { generate_raw_chunk } from "$/common/generation.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, ID_MASK } from "@/common/constants.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { test_game } from "./helpers.ts";
// a desert on this seed, found with estimate_biome
+1 -1
View File
@@ -7,7 +7,7 @@
// after a change that's meant to change generation, record it again:
// deno test -A tests/worldgen_golden_test.ts -- --update
import { assertEquals } from "@std/assert";
import { generate_raw_chunk } from "$/common/generation.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { test_game } from "./helpers.ts";
import { final_hash, FIXTURE, golden_chunks, type Hashes, namer, raw_hash, recorded, SEEDS } from "./golden.ts";
+4 -4
View File
@@ -4,10 +4,10 @@
// chunks generated in worldgen workers are the ones the game would generate, in any order and with any number of
// workers. see server/game/worldgen_pool.ts
import { assert, assertEquals } from "@std/assert";
import { chunk_key } from "$/common/utils.ts";
import type { RawChunk } from "$/common/generation.ts";
import { type WorkerPort, WorldgenPool } from "$/server/game/worldgen_pool.ts";
import { start_worldgen_workers } from "$/server/worldgen_workers.ts";
import { chunk_key } from "@/common/utils.ts";
import type { RawChunk } from "@/common/generation.ts";
import { type WorkerPort, WorldgenPool } from "@/server/game/worldgen_pool.ts";
import { start_worldgen_workers } from "@/server/worldgen_workers.ts";
import { test_game } from "./helpers.ts";
import { golden_chunks, namer, raw_hash, recorded } from "./golden.ts";
+2 -2
View File
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { assert, assertEquals } from "@std/assert";
import { CHUNK_AREA, CHUNK_HEIGHT, SEA_LEVEL } from "$/common/constants.ts";
import { generate_raw_chunk } from "$/common/generation.ts";
import { CHUNK_AREA, CHUNK_HEIGHT, SEA_LEVEL } from "@/common/constants.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { test_game } from "./helpers.ts";
Deno.test("the overworld generates the same way every time, with water only below sea level", async () => {
+2 -2
View File
@@ -3,8 +3,8 @@
// the worm bin: one worm_binable item in its input makes 5 more of it every morning, into its output
import { assert, assertEquals } from "@std/assert";
import { CYCLE_TICKS } from "$/common/time.ts";
import { Container, ItemStack } from "$/common/inventory.ts";
import { CYCLE_TICKS } from "@/common/time.ts";
import { Container, ItemStack } from "@/common/inventory.ts";
import { menu_items, opened_menu, test_game } from "./helpers.ts";
// the container's slots, see register_worm_bin
+3 -3
View File
@@ -3,8 +3,8 @@
// what players wear is drawn on their parts, moving with them, see client/rendering/worn_renderer.ts
import { assertAlmostEquals, assertEquals, assertNotEquals } from "@std/assert";
import { entity_model_from_geo } from "$/common/mod_data.ts";
import { apply, bone_matrices, type Vec3 } from "$/client/rendering/model_math.ts";
import { entity_model_from_geo } from "@/common/mod_data.ts";
import { apply, bone_matrices, type Vec3 } from "@/client/rendering/model_math.ts";
import {
on_part,
part_point,
@@ -13,7 +13,7 @@ import {
SLIM_PARTS,
worn_bone_pose,
worn_look,
} from "$/client/rendering/player_model.ts";
} from "@/client/rendering/player_model.ts";
// a glove made over blockbench's player template: its right arm's box, and a claw on a bone under it
const glove = entity_model_from_geo({