Change imports
This commit is contained in:
@@ -84,8 +84,8 @@ deno task build && deno task server # packs the mods and starts a se
|
||||
|
||||
## API Types
|
||||
|
||||
The API types are the reference for everything scripts can call. Scripts import them as `bworld/server`, `bworld/client`
|
||||
and `bworld/worldgen`, and they live in [`common/mod_api/`](common/mod_api/).
|
||||
The API types are the reference for everything scripts can call. Scripts import them as `cubi/server`, `cubi/client` and
|
||||
`cubi/worldgen`, and they live in [`common/mod_api/`](common/mod_api/).
|
||||
|
||||
A few parts of those types aren't built yet and throw when used: forms, custom screens, HUD elements and keybinds.
|
||||
[`docs/modding_plan.md`](docs/modding_plan.md) covers those, what else is planned, and the design behind the mod API.
|
||||
|
||||
+3
-3
@@ -3,9 +3,9 @@
|
||||
|
||||
// the texture atlas: the engine's textures and every mod's in one image, built by the client when it joins a server
|
||||
// from the textures in the server's .bmod files
|
||||
import { TEXTURE_SIZE } from "$/common/constants.ts";
|
||||
import type { SpriteRegion } from "$/common/constants.ts";
|
||||
import { type Animation, texture_animation, type TextureJson } from "$/common/texture_animation.ts";
|
||||
import { TEXTURE_SIZE } from "@/common/constants.ts";
|
||||
import type { SpriteRegion } from "@/common/constants.ts";
|
||||
import { type Animation, texture_animation, type TextureJson } from "@/common/texture_animation.ts";
|
||||
import { AnimatedTexture } from "./texture_animations.ts";
|
||||
|
||||
export interface AtlasLayout {
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
// entities, visuals and changing blocks. it's made of what the loaded mods' worldgen data makes the ground of, and other
|
||||
// blocks picked by what they are (a cutout plant, a translucent cube), not by their ids
|
||||
import { Alea } from "@paulaboks/rng";
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
|
||||
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
|
||||
import { DEFAULT_MODEL } from "$/common/block_models.ts";
|
||||
import { OctaveNoise2D, OctaveNoise3D, smoothstep } from "$/common/worldgen/noise.ts";
|
||||
import { can_stand_on, default_block_value } from "$/common/utils.ts";
|
||||
import type { Biome } from "$/common/worldgen/biomes.ts";
|
||||
import type { NoiseSettingsJson } from "$/common/worldgen/data.ts";
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
|
||||
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
|
||||
import { DEFAULT_MODEL } from "@/common/block_models.ts";
|
||||
import { OctaveNoise2D, OctaveNoise3D, smoothstep } from "@/common/worldgen/noise.ts";
|
||||
import { can_stand_on, default_block_value } from "@/common/utils.ts";
|
||||
import type { Biome } from "@/common/worldgen/biomes.ts";
|
||||
import type { NoiseSettingsJson } from "@/common/worldgen/data.ts";
|
||||
|
||||
const SEED = "benchmark";
|
||||
// chunks go from -LEVEL_RADIUS to LEVEL_RADIUS - 1 each way. the outermost ring is only there so the ones inside it
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
// so what's around the player doesn't change the numbers. each scene is timed with frames paced by the display, then
|
||||
// with frames back to back (see render_debug.uncapped), after a warmup. meshing the whole level is timed too, the
|
||||
// first time and again. the report says what the computer and the browser are, see report.ts
|
||||
import { Camera } from "$/client/camera.ts";
|
||||
import { ClientLevel } from "$/client/level/client_level.ts";
|
||||
import type { GameRenderer } from "$/client/rendering/game_renderer.ts";
|
||||
import { block_visuals } from "$/client/rendering/visuals.ts";
|
||||
import { draw_item } from "$/client/rendering/render_utils.ts";
|
||||
import { InputManager } from "$/client/input_manager.ts";
|
||||
import { type FrameSample, profiler } from "$/client/profiler.ts";
|
||||
import { RemotePlayer } from "$/client/entity/remote_player.ts";
|
||||
import { RemoteEntity } from "$/client/entity/remote_entity.ts";
|
||||
import { ItemEntity } from "$/client/entity/item_entity.ts";
|
||||
import { tick_texture_animations } from "$/client/texture_animations.ts";
|
||||
import { Camera } from "@/client/camera.ts";
|
||||
import { ClientLevel } from "@/client/level/client_level.ts";
|
||||
import type { GameRenderer } from "@/client/rendering/game_renderer.ts";
|
||||
import { block_visuals } from "@/client/rendering/visuals.ts";
|
||||
import { draw_item } from "@/client/rendering/render_utils.ts";
|
||||
import { InputManager } from "@/client/input_manager.ts";
|
||||
import { type FrameSample, profiler } from "@/client/profiler.ts";
|
||||
import { RemotePlayer } from "@/client/entity/remote_player.ts";
|
||||
import { RemoteEntity } from "@/client/entity/remote_entity.ts";
|
||||
import { ItemEntity } from "@/client/entity/item_entity.ts";
|
||||
import { tick_texture_animations } from "@/client/texture_animations.ts";
|
||||
import {
|
||||
adapter_info,
|
||||
device,
|
||||
@@ -26,15 +26,15 @@ import {
|
||||
render_debug,
|
||||
render_stats,
|
||||
set_canvas_size,
|
||||
} from "$/client/renderer/mod.ts";
|
||||
import { ID_MASK, SLOT_SIZE, STATE_SHIFT } from "$/common/constants.ts";
|
||||
import { AIR_ID } from "$/common/protocol.ts";
|
||||
import { TIMES_OF_DAY } from "$/common/time.ts";
|
||||
import { type BlockRegistry, EverythingRegistry, RENDER_LAYERS } from "$/common/everything_registry.ts";
|
||||
import type { EntityJson } from "$/common/mod_data.ts";
|
||||
import type { ModListing } from "$/common/mod_loader.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import { display_name } from "$/common/utils.ts";
|
||||
} from "@/client/renderer/mod.ts";
|
||||
import { ID_MASK, SLOT_SIZE, STATE_SHIFT } from "@/common/constants.ts";
|
||||
import { AIR_ID } from "@/common/protocol.ts";
|
||||
import { TIMES_OF_DAY } from "@/common/time.ts";
|
||||
import { type BlockRegistry, EverythingRegistry, RENDER_LAYERS } from "@/common/everything_registry.ts";
|
||||
import type { EntityJson } from "@/common/mod_data.ts";
|
||||
import type { ModListing } from "@/common/mod_loader.ts";
|
||||
import { ItemStack } from "@/common/inventory.ts";
|
||||
import { display_name } from "@/common/utils.ts";
|
||||
import {
|
||||
bench_blocks,
|
||||
type BenchBlocks,
|
||||
|
||||
+5
-5
@@ -22,11 +22,11 @@ import { InputManager } from "./input_manager.ts";
|
||||
import { Connection } from "./network.ts";
|
||||
import { PauseScreen } from "./gui/pause_screen.ts";
|
||||
import { back_to_title } from "./gui/title_screen.ts";
|
||||
import { TICK_DELTA } from "$/common/constants.ts";
|
||||
import { Container } from "$/common/inventory.ts";
|
||||
import { PLAYER_MENU } from "$/common/protocol.ts";
|
||||
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
|
||||
import type { EntityJson } from "$/common/mod_data.ts";
|
||||
import { TICK_DELTA } from "@/common/constants.ts";
|
||||
import { Container } from "@/common/inventory.ts";
|
||||
import { PLAYER_MENU } from "@/common/protocol.ts";
|
||||
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
|
||||
import type { EntityJson } from "@/common/mod_data.ts";
|
||||
import { tick_texture_animations } from "./texture_animations.ts";
|
||||
import type { RenderBenchmark } from "./benchmark/benchmark.ts";
|
||||
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { point_inside_rec } from "$/common/utils.ts";
|
||||
import { InputManager } from "$/client/input_manager.ts";
|
||||
import { TextInput } from "$/client/gui/widgets.ts";
|
||||
import { point_inside_rec } from "@/common/utils.ts";
|
||||
import { InputManager } from "@/client/input_manager.ts";
|
||||
import { TextInput } from "@/client/gui/widgets.ts";
|
||||
import { begin_clip, draw_rect, draw_rect_stroke, draw_text, end_clip } from "./renderer/mod.ts";
|
||||
|
||||
const HEADER_HEIGHT = 24;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { physics } from "$/common/physics.ts";
|
||||
import { physics } from "@/common/physics.ts";
|
||||
import type { ClientLevel } from "../level/client_level.ts";
|
||||
|
||||
// anything that exists in the level and moves, like minecraft's Entity. position is the middle of its feet.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import type { EntityInfo } from "$/common/protocol.ts";
|
||||
import { ItemStack } from "@/common/inventory.ts";
|
||||
import type { EntityInfo } from "@/common/protocol.ts";
|
||||
import type { ClientLevel } from "../level/client_level.ts";
|
||||
import { Entity } from "./entity.ts";
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { PLAYER_EYE_HEIGHT, PLAYER_HEIGHT, PLAYER_SWIM_EYE_HEIGHT, TICK_DELTA } from "$/common/constants.ts";
|
||||
import { physics } from "$/common/physics.ts";
|
||||
import { PLAYER_EYE_HEIGHT, PLAYER_HEIGHT, PLAYER_SWIM_EYE_HEIGHT, TICK_DELTA } from "@/common/constants.ts";
|
||||
import { physics } from "@/common/physics.ts";
|
||||
import type { Client } from "../client.ts";
|
||||
import { InputManager } from "../input_manager.ts";
|
||||
import { ClientInventories } from "../inventory.ts";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { PLAYER_EYE_HEIGHT, PLAYER_HEIGHT, PLAYER_SWIM_HEIGHT, PLAYER_WIDTH } from "$/common/constants.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import { PLAYER_EYE_HEIGHT, PLAYER_HEIGHT, PLAYER_SWIM_HEIGHT, PLAYER_WIDTH } from "@/common/constants.ts";
|
||||
import { ItemStack } from "@/common/inventory.ts";
|
||||
import type { ClientLevel } from "../level/client_level.ts";
|
||||
import type { Texture } from "../renderer/mod.ts";
|
||||
import { decode_skin } from "../skins.ts";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { EntityData, EntityEvent, EntityInfo } from "$/common/protocol.ts";
|
||||
import type { EntityJson } from "$/common/mod_data.ts";
|
||||
import { EverythingRegistry } from "$/common/everything_registry.ts";
|
||||
import { wrap_angle } from "$/common/utils.ts";
|
||||
import type { EntityData, EntityEvent, EntityInfo } from "@/common/protocol.ts";
|
||||
import type { EntityJson } from "@/common/mod_data.ts";
|
||||
import { EverythingRegistry } from "@/common/everything_registry.ts";
|
||||
import { wrap_angle } from "@/common/utils.ts";
|
||||
import type { ClientLevel } from "../level/client_level.ts";
|
||||
import { Entity } from "./entity.ts";
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { EntityEvent, PlayerInfo } from "$/common/protocol.ts";
|
||||
import { TICK_DELTA } from "$/common/constants.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import type { EntityEvent, PlayerInfo } from "@/common/protocol.ts";
|
||||
import { TICK_DELTA } from "@/common/constants.ts";
|
||||
import { ItemStack } from "@/common/inventory.ts";
|
||||
import type { ClientLevel } from "../level/client_level.ts";
|
||||
import { Player } from "./player.ts";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// the fluids' rules from the mods' shared scripts on this client, the same as the server's (see common/fluids.ts), for
|
||||
// drawing fluids and naming them in tooltips. its own module so those don't import client/mods.ts, which loads the mods
|
||||
// and makes it again for each server's
|
||||
import { FluidRules } from "$/common/fluids.ts";
|
||||
import { FluidRules } from "@/common/fluids.ts";
|
||||
|
||||
export let fluid_rules = new FluidRules(() => undefined);
|
||||
|
||||
|
||||
+7
-7
@@ -1,16 +1,16 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { AIR, FACE_OFFSETS, TICK_DELTA } from "$/common/constants.ts";
|
||||
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "@/common/everything_registry.ts";
|
||||
import { AIR, FACE_OFFSETS, TICK_DELTA } from "@/common/constants.ts";
|
||||
import type { Client } from "./client.ts";
|
||||
import type { BlockHitResult } from "./level/client_level.ts";
|
||||
import type { Container } from "$/common/inventory.ts";
|
||||
import { AIR_ID } from "$/common/protocol.ts";
|
||||
import { box_overlaps_block, can_place, fluid_block, placement_target, waterlog_placement } from "$/common/utils.ts";
|
||||
import type { Container } from "@/common/inventory.ts";
|
||||
import { AIR_ID } from "@/common/protocol.ts";
|
||||
import { box_overlaps_block, can_place, fluid_block, placement_target, waterlog_placement } from "@/common/utils.ts";
|
||||
import { block_rules, predict_neighbors } from "./mods.ts";
|
||||
import { collision_shape_at } from "$/common/block_shapes.ts";
|
||||
import type { EntityJson } from "$/common/mod_data.ts";
|
||||
import { collision_shape_at } from "@/common/block_shapes.ts";
|
||||
import type { EntityJson } from "@/common/mod_data.ts";
|
||||
import { RemoteEntity } from "./entity/remote_entity.ts";
|
||||
import { Player } from "./entity/player.ts";
|
||||
import type { Entity } from "./entity/entity.ts";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { canvas, draw_rect, draw_text } from "$/client/renderer/mod.ts";
|
||||
import { canvas, draw_rect, draw_text } from "@/client/renderer/mod.ts";
|
||||
|
||||
const LINE_HEIGHT = 24;
|
||||
const VISIBLE_SECONDS = 10;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { Marked } from "marked";
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import { mod_credits } from "$/client/mods.ts";
|
||||
import { canvas, draw_rect } from "$/client/renderer/mod.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import { mod_credits } from "@/client/mods.ts";
|
||||
import { canvas, draw_rect } from "@/client/renderer/mod.ts";
|
||||
import { GuiScreen } from "./gui_screen.ts";
|
||||
|
||||
// credits come from servers' mods, so markdown only: raw html is shown as text and links can't run code
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { Client } from "$/client/client.ts";
|
||||
import { DebugUI } from "$/client/debug_ui.ts";
|
||||
import { format_clock } from "$/common/time.ts";
|
||||
import { profiler, type SectionStats } from "$/client/profiler.ts";
|
||||
import { canvas, gpu_timer, render_debug, render_stats } from "$/client/renderer/mod.ts";
|
||||
import { RENDER_LAYERS } from "$/common/everything_registry.ts";
|
||||
import { atlas_png } from "$/client/atlas.ts";
|
||||
import { RenderBenchmark } from "$/client/benchmark/benchmark.ts";
|
||||
import { format_report } from "$/client/benchmark/report.ts";
|
||||
import type { Client } from "@/client/client.ts";
|
||||
import { DebugUI } from "@/client/debug_ui.ts";
|
||||
import { format_clock } from "@/common/time.ts";
|
||||
import { profiler, type SectionStats } from "@/client/profiler.ts";
|
||||
import { canvas, gpu_timer, render_debug, render_stats } from "@/client/renderer/mod.ts";
|
||||
import { RENDER_LAYERS } from "@/common/everything_registry.ts";
|
||||
import { atlas_png } from "@/client/atlas.ts";
|
||||
import { RenderBenchmark } from "@/client/benchmark/benchmark.ts";
|
||||
import { format_report } from "@/client/benchmark/report.ts";
|
||||
|
||||
// how often the totals that go through every chunk are worked out again, so the overlay doesn't slow the frames it's
|
||||
// measuring
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "$/client/renderer/mod.ts";
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "@/client/renderer/mod.ts";
|
||||
import { GuiScreen } from "./gui_screen.ts";
|
||||
import { back_to_title } from "./title_screen.ts";
|
||||
import { Button, TEXT_HEIGHT, TEXT_SCALE } from "./widgets.ts";
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { GuiScreen } from "./gui_screen.ts";
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "$/client/renderer/mod.ts";
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "@/client/renderer/mod.ts";
|
||||
import { InputManager } from "../input_manager.ts";
|
||||
import type { Client } from "../client.ts";
|
||||
import { MAX_CHAT_LENGTH, type ServerMessage } from "$/common/protocol.ts";
|
||||
import type { Suggestion } from "$/common/commands.ts";
|
||||
import { MAX_CHAT_LENGTH, type ServerMessage } from "@/common/protocol.ts";
|
||||
import type { Suggestion } from "@/common/commands.ts";
|
||||
import { TEXT_HEIGHT, TextInput } from "./widgets.ts";
|
||||
|
||||
const SCALE = 2;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// screens mods' client scripts make, see docs/modding/gui/index.md: the screens of their menus, and screens with no
|
||||
// menu. a mod's screen that throws is closed, with the error in the console
|
||||
import { TICK_DELTA } from "$/common/constants.ts";
|
||||
import type { ClientMenu as ModClientMenu, MenuScreen, Screen } from "$/common/mod_api/client.ts";
|
||||
import { TICK_DELTA } from "@/common/constants.ts";
|
||||
import type { ClientMenu as ModClientMenu, MenuScreen, Screen } from "@/common/mod_api/client.ts";
|
||||
import { canvas } from "../renderer/mod.ts";
|
||||
import type { Client } from "../client.ts";
|
||||
import type { ClientMenu } from "../menu.ts";
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
import { GuiMenuScreen } from "./gui_screen.ts";
|
||||
import type { LocalPlayer } from "../entity/local_player.ts";
|
||||
import { EverythingRegistry } from "$/common/everything_registry.ts";
|
||||
import type { EffectJson } from "$/common/mod_data.ts";
|
||||
import { TICKS_PER_SECOND } from "$/common/constants.ts";
|
||||
import { display_name } from "$/common/utils.ts";
|
||||
import { ClientMessage, PLAYER_MENU_EXTRA } from "$/common/protocol.ts";
|
||||
import { EverythingRegistry } from "@/common/everything_registry.ts";
|
||||
import type { EffectJson } from "@/common/mod_data.ts";
|
||||
import { TICKS_PER_SECOND } from "@/common/constants.ts";
|
||||
import { display_name } from "@/common/utils.ts";
|
||||
import { ClientMessage, PLAYER_MENU_EXTRA } from "@/common/protocol.ts";
|
||||
import { player_menu } from "../menu.ts";
|
||||
import type { ModGraphics } from "./mod_graphics.ts";
|
||||
import { draw_gui_player } from "../rendering/gui_player.ts";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { SLOT_SIZE } from "$/common/constants.ts";
|
||||
import { SLOT_SIZE } from "@/common/constants.ts";
|
||||
import { draw_gui_sprite, GUI_SCALE } from "./gui_sprites.ts";
|
||||
import { click_slot } from "$/common/inventory.ts";
|
||||
import { ClientMessage, CRAFTING_RESULT_SLOT, PLAYER_MENU } from "$/common/protocol.ts";
|
||||
import { click_slot } from "@/common/inventory.ts";
|
||||
import { ClientMessage, CRAFTING_RESULT_SLOT, PLAYER_MENU } from "@/common/protocol.ts";
|
||||
import { point_inside_rec } from "../../common/utils.ts";
|
||||
import { InputManager } from "../input_manager.ts";
|
||||
import { ClientInventories } from "../inventory.ts";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import type { Texture } from "$/client/renderer/mod.ts";
|
||||
import { draw_nine_slice } from "$/client/rendering/render_utils.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import type { Texture } from "@/client/renderer/mod.ts";
|
||||
import { draw_nine_slice } from "@/client/rendering/render_utils.ts";
|
||||
import { GUI_ATLAS, type GuiSprite } from "./gui_atlas.ts";
|
||||
|
||||
// gui sprites are drawn 3 times bigger, like minecraft at gui scale 3. SLOT_SIZE is its 18 pixel slot at this scale
|
||||
|
||||
+8
-8
@@ -1,14 +1,14 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { Client } from "$/client/client.ts";
|
||||
import type { LocalPlayer } from "$/client/entity/local_player.ts";
|
||||
import type { ClientInventories } from "$/client/inventory.ts";
|
||||
import { draw_item } from "$/client/rendering/render_utils.ts";
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "$/client/renderer/mod.ts";
|
||||
import { display_name } from "$/common/utils.ts";
|
||||
import { clock } from "$/common/time.ts";
|
||||
import { biome_season } from "$/common/worldgen/biomes.ts";
|
||||
import type { Client } from "@/client/client.ts";
|
||||
import type { LocalPlayer } from "@/client/entity/local_player.ts";
|
||||
import type { ClientInventories } from "@/client/inventory.ts";
|
||||
import { draw_item } from "@/client/rendering/render_utils.ts";
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "@/client/renderer/mod.ts";
|
||||
import { display_name } from "@/common/utils.ts";
|
||||
import { clock } from "@/common/time.ts";
|
||||
import { biome_season } from "@/common/worldgen/biomes.ts";
|
||||
import { TEXT_HEIGHT, TEXT_SCALE } from "./widgets.ts";
|
||||
import { draw_gui_sprite, GUI_SCALE } from "./gui_sprites.ts";
|
||||
|
||||
|
||||
+10
-10
@@ -4,13 +4,13 @@
|
||||
// the immediate mode drawing mods' client scripts get (Graphics in common/mod_api/client.ts), on top of the renderer.
|
||||
// one per screen, so text inputs keep their text and focus while it's open. mods work in gui pixels, GUI_SCALE canvas
|
||||
// pixels each
|
||||
import { EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import type { Color, Graphics } from "$/common/mod_api/client.ts";
|
||||
import type { FluidVariant, KeyCode } from "$/common/mod_api/shared.ts";
|
||||
import { point_inside_rec } from "$/common/utils.ts";
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import { InputManager, type KeyCode as InputKey } from "$/client/input_manager.ts";
|
||||
import { EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
|
||||
import { ItemStack } from "@/common/inventory.ts";
|
||||
import type { Color, Graphics } from "@/common/mod_api/client.ts";
|
||||
import type { FluidVariant, KeyCode } from "@/common/mod_api/shared.ts";
|
||||
import { point_inside_rec } from "@/common/utils.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import { InputManager, type KeyCode as InputKey } from "@/client/input_manager.ts";
|
||||
import {
|
||||
begin_clip,
|
||||
canvas,
|
||||
@@ -20,9 +20,9 @@ import {
|
||||
end_clip,
|
||||
measure_text,
|
||||
Texture,
|
||||
} from "$/client/renderer/mod.ts";
|
||||
import { draw_fluid, draw_item } from "$/client/rendering/render_utils.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
} from "@/client/renderer/mod.ts";
|
||||
import { draw_fluid, draw_item } from "@/client/rendering/render_utils.ts";
|
||||
import { get_sprite_region } from "@/client/sprites.ts";
|
||||
import { draw_tooltip, item_tooltip, type TooltipLine } from "./tooltip.ts";
|
||||
import { TEXT_HEIGHT, TEXT_SCALE, TextInput } from "./widgets.ts";
|
||||
import { GUI_ATLAS } from "./gui_atlas.ts";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { Client } from "$/client/client.ts";
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "$/client/renderer/mod.ts";
|
||||
import type { Client } from "@/client/client.ts";
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "@/client/renderer/mod.ts";
|
||||
import { GuiScreen } from "./gui_screen.ts";
|
||||
import { Button, TEXT_HEIGHT } from "./widgets.ts";
|
||||
import { CreditsScreen } from "./credits_screen.ts";
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { MAX_NAME_LENGTH } from "$/common/protocol.ts";
|
||||
import { InputManager } from "$/client/input_manager.ts";
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "$/client/renderer/mod.ts";
|
||||
import { default_server, HandshakeError, server_address, ServerAddress } from "$/client/handshake.ts";
|
||||
import { default_player_name } from "$/client/network.ts";
|
||||
import { MAX_NAME_LENGTH } from "@/common/protocol.ts";
|
||||
import { InputManager } from "@/client/input_manager.ts";
|
||||
import { canvas, draw_rect, draw_text, measure_text } from "@/client/renderer/mod.ts";
|
||||
import { default_server, HandshakeError, server_address, ServerAddress } from "@/client/handshake.ts";
|
||||
import { default_player_name } from "@/client/network.ts";
|
||||
import { GuiScreen } from "./gui_screen.ts";
|
||||
import { CreditsScreen } from "./credits_screen.ts";
|
||||
import { Button, EditBox, TEXT_HEIGHT, TEXT_SCALE, TextInput } from "./widgets.ts";
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
|
||||
// the box next to the mouse saying what an item is, like minecraft's: its name, the fluid in it, what it's worth, then
|
||||
// its lore
|
||||
import { EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { contained_fluid, type ItemStack, sell_value } from "$/common/inventory.ts";
|
||||
import { display_name } from "$/common/utils.ts";
|
||||
import { fluid_rules } from "$/client/fluid_rules.ts";
|
||||
import { canvas, draw_text, draw_texture_region, measure_text, type Texture } from "$/client/renderer/mod.ts";
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import type { MenuTank } from "$/common/protocol.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
import { EverythingRegistry, ItemRegistry } from "@/common/everything_registry.ts";
|
||||
import { contained_fluid, type ItemStack, sell_value } from "@/common/inventory.ts";
|
||||
import { display_name } from "@/common/utils.ts";
|
||||
import { fluid_rules } from "@/client/fluid_rules.ts";
|
||||
import { canvas, draw_text, draw_texture_region, measure_text, type Texture } from "@/client/renderer/mod.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import type { MenuTank } from "@/common/protocol.ts";
|
||||
import { get_sprite_region } from "@/client/sprites.ts";
|
||||
import { draw_gui_sprite, GUI_SCALE } from "./gui_sprites.ts";
|
||||
import { TEXT_HEIGHT, TEXT_SCALE } from "./widgets.ts";
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { point_inside_rec } from "$/common/utils.ts";
|
||||
import { InputManager, type KeyCode } from "$/client/input_manager.ts";
|
||||
import { draw_rect, draw_text, measure_text } from "$/client/renderer/mod.ts";
|
||||
import { point_inside_rec } from "@/common/utils.ts";
|
||||
import { InputManager, type KeyCode } from "@/client/input_manager.ts";
|
||||
import { draw_rect, draw_text, measure_text } from "@/client/renderer/mod.ts";
|
||||
import { draw_gui_sprite } from "./gui_sprites.ts";
|
||||
|
||||
export const TEXT_SCALE = 2;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
// connecting to a server and getting what it needs before joining, see docs/modding/networking/index.md:
|
||||
// hello -> welcome, download and check everything, ready -> join
|
||||
import { ClientMessage, PROTOCOL_VERSION, ServerMessage } from "$/common/protocol.ts";
|
||||
import { ClientMessage, PROTOCOL_VERSION, ServerMessage } from "@/common/protocol.ts";
|
||||
|
||||
const CONNECT_TIMEOUT_MS = 5000;
|
||||
const TRUST_KEY_PREFIX = "bworld:trusted:";
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { Container, Cursor } from "$/common/inventory.ts";
|
||||
import type { MenuSlotInfo } from "$/common/protocol.ts";
|
||||
import { Container, Cursor } from "@/common/inventory.ts";
|
||||
import type { MenuSlotInfo } from "@/common/protocol.ts";
|
||||
|
||||
// the local copies of the containers the server syncs to this player
|
||||
export class ClientInventories {
|
||||
|
||||
@@ -8,10 +8,10 @@ import {
|
||||
fluid_block,
|
||||
fluid_in_cell,
|
||||
is_waterlogged,
|
||||
} from "$/common/utils.ts";
|
||||
import { AIR_ID } from "$/common/protocol.ts";
|
||||
import { decode_level_chunk } from "$/common/chunk_streaming.ts";
|
||||
import { DEFAULT_WATER_COLOR, foliage_color, grass_color, water_color } from "$/common/worldgen/biome_colors.ts";
|
||||
} from "@/common/utils.ts";
|
||||
import { AIR_ID } from "@/common/protocol.ts";
|
||||
import { decode_level_chunk } from "@/common/chunk_streaming.ts";
|
||||
import { DEFAULT_WATER_COLOR, foliage_color, grass_color, water_color } from "@/common/worldgen/biome_colors.ts";
|
||||
import {
|
||||
block_light_emission,
|
||||
block_light_opacity,
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
is_fluid_block,
|
||||
RENDER_LAYERS,
|
||||
RenderLayer,
|
||||
} from "$/common/everything_registry.ts";
|
||||
} from "@/common/everything_registry.ts";
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, Faces, ID_MASK, VOID } from "../../common/constants.ts";
|
||||
import { AssetManager } from "../assets.ts";
|
||||
import { ChunkWorkerPool } from "../chunk_workers.ts";
|
||||
@@ -29,8 +29,8 @@ import { create_index_buffer, create_vertex_buffer, destroy_buffer, Texture } fr
|
||||
import { crosses_planes } from "../workers/translucent_sort.ts";
|
||||
import { Camera } from "../camera.ts";
|
||||
import type { Entity } from "../entity/entity.ts";
|
||||
import type { ModelJson } from "$/common/block_models.ts";
|
||||
import { clip_shape, collision_shape_at, FULL_SHAPE, type Shape, shape_at } from "$/common/block_shapes.ts";
|
||||
import type { ModelJson } from "@/common/block_models.ts";
|
||||
import { clip_shape, collision_shape_at, FULL_SHAPE, type Shape, shape_at } from "@/common/block_shapes.ts";
|
||||
import { BlockPredictions } from "./block_predictions.ts";
|
||||
import { block_visuals, Visuals } from "../rendering/visuals.ts";
|
||||
|
||||
|
||||
+2
-2
@@ -10,8 +10,8 @@ import { connect, HandshakeError, is_trusted, join, remember_trust, ServerAddres
|
||||
import { build_atlas, engine_textures } from "./atlas.ts";
|
||||
import { confirm_mods } from "./confirm_mods.ts";
|
||||
import { set_texture_animations } from "./texture_animations.ts";
|
||||
import type { TextureJson } from "$/common/texture_animation.ts";
|
||||
import { ModLoadError } from "$/common/mod_loader.ts";
|
||||
import type { TextureJson } from "@/common/texture_animation.ts";
|
||||
import { ModLoadError } from "@/common/mod_loader.ts";
|
||||
import {
|
||||
begin_drawing,
|
||||
canvas,
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@
|
||||
|
||||
// the client's copy of a menu, like neoforge's client menu: built from what the server sent when it opened, kept up
|
||||
// to date with what it syncs. clicks go to the server, which decides what they do
|
||||
import { Container } from "$/common/inventory.ts";
|
||||
import { Container } from "@/common/inventory.ts";
|
||||
import {
|
||||
CRAFTING_RESULT_SLOT,
|
||||
type MenuFluidSlotInfo,
|
||||
@@ -11,9 +11,9 @@ import {
|
||||
type MenuTank,
|
||||
PLAYER_MENU,
|
||||
PLAYER_MENU_EXTRA,
|
||||
} from "$/common/protocol.ts";
|
||||
} from "@/common/protocol.ts";
|
||||
import type { ClientInventories } from "./inventory.ts";
|
||||
import type { ItemStack as ApiItemStack } from "$/common/mod_api/client.ts";
|
||||
import type { ItemStack as ApiItemStack } from "@/common/mod_api/client.ts";
|
||||
|
||||
export interface ClientSlot {
|
||||
// where its item is on this client
|
||||
|
||||
+16
-16
@@ -3,9 +3,9 @@
|
||||
|
||||
// loads the mods the server lists: downloads their .bmod files, registers their data, then runs their client scripts.
|
||||
// see docs/modding/networking/index.md
|
||||
import { AIR } from "$/common/constants.ts";
|
||||
import { BlockRegistry, EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import type { ClientContext, ClientMenu, InventoryOverlay, KeyMappings, MenuScreen } from "$/common/mod_api/client.ts";
|
||||
import { AIR } from "@/common/constants.ts";
|
||||
import { BlockRegistry, EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
|
||||
import type { ClientContext, ClientMenu, InventoryOverlay, KeyMappings, MenuScreen } from "@/common/mod_api/client.ts";
|
||||
import {
|
||||
check_recipe_types,
|
||||
ModListing,
|
||||
@@ -14,25 +14,25 @@ import {
|
||||
RecipeBook,
|
||||
register_mod_data,
|
||||
shared_recipes_api,
|
||||
} from "$/common/mod_loader.ts";
|
||||
import { type Bmod, read_bmod } from "$/common/bmod.ts";
|
||||
import { get_state_value, set_state_value, shared_items_api } from "$/common/utils.ts";
|
||||
import { BlockRules } from "$/common/block_rules.ts";
|
||||
import { fluid_exists, FluidRules, same_fluid } from "$/common/fluids.ts";
|
||||
} from "@/common/mod_loader.ts";
|
||||
import { type Bmod, read_bmod } from "@/common/bmod.ts";
|
||||
import { get_state_value, set_state_value, shared_items_api } from "@/common/utils.ts";
|
||||
import { BlockRules } from "@/common/block_rules.ts";
|
||||
import { fluid_exists, FluidRules, same_fluid } from "@/common/fluids.ts";
|
||||
import { fluid_rules, set_fluid_rules } from "./fluid_rules.ts";
|
||||
import { covers_face, EMPTY_SHAPE, FULL_SHAPE, is_solid } from "$/common/block_shapes.ts";
|
||||
import type { SharedContext, SharedWorld } from "$/common/mod_api/shared.ts";
|
||||
import { tag_api } from "$/common/tags.ts";
|
||||
import { AIR_ID } from "$/common/protocol.ts";
|
||||
import { covers_face, EMPTY_SHAPE, FULL_SHAPE, is_solid } from "@/common/block_shapes.ts";
|
||||
import type { SharedContext, SharedWorld } from "@/common/mod_api/shared.ts";
|
||||
import { tag_api } from "@/common/tags.ts";
|
||||
import { AIR_ID } from "@/common/protocol.ts";
|
||||
import type { Client } from "./client.ts";
|
||||
import { code_url, fetch_verified } from "./handshake.ts";
|
||||
import { GuiModScreen } from "./gui/gui_mod_screens.ts";
|
||||
import { clear_hooks, expose_engine, loading_mod } from "$/common/hooks.ts";
|
||||
import { common_engine } from "$/common/engine_modules.ts";
|
||||
import { clear_hooks, expose_engine, loading_mod } from "@/common/hooks.ts";
|
||||
import { common_engine } from "@/common/engine_modules.ts";
|
||||
import { client_engine } from "./engine_modules.ts";
|
||||
import { block_visuals } from "./rendering/visuals.ts";
|
||||
import { biome_season } from "$/common/worldgen/biomes.ts";
|
||||
import type { LootTableJson } from "$/common/loot.ts";
|
||||
import { biome_season } from "@/common/worldgen/biomes.ts";
|
||||
import type { LootTableJson } from "@/common/loot.ts";
|
||||
|
||||
// each loaded mod's credits file, for the credits screen
|
||||
export const mod_credits: { name: string; version: string; text: string }[] = [];
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { ClientMessage, EntityInfo, MenuSlotInfo, PlayerInfo, ServerMessage } from "$/common/protocol.ts";
|
||||
import type { ModListing } from "$/common/mod_loader.ts";
|
||||
import { ClientMessage, EntityInfo, MenuSlotInfo, PlayerInfo, ServerMessage } from "@/common/protocol.ts";
|
||||
import type { ModListing } from "@/common/mod_loader.ts";
|
||||
import type { Join, ServerSocket, Welcome } from "./handshake.ts";
|
||||
|
||||
export class Connection {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { ServerMessage } from "$/common/protocol.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import type { ServerMessage } from "@/common/protocol.ts";
|
||||
import { ItemStack } from "@/common/inventory.ts";
|
||||
import type { Client } from "./client.ts";
|
||||
import { GuiModMenuScreen } from "./gui/gui_mod_screens.ts";
|
||||
import { ClientMenu } from "./menu.ts";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Camera } from "../camera.ts";
|
||||
import { mat4 } from "gl-matrix";
|
||||
import type { RenderLayer } from "$/common/everything_registry.ts";
|
||||
import type { RenderLayer } from "@/common/everything_registry.ts";
|
||||
import { TERRAIN_VERTEX_BYTES } from "../workers/chunk_messages.ts";
|
||||
import { GpuTimer } from "./gpu_timing.ts";
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
// lighting entities like minecraft: one light level per entity each frame, at its eyes, looked up in the same lightmap
|
||||
// as terrain and multiplied into its vertex colors. burning ones have full block light
|
||||
import type { Entity } from "$/client/entity/entity.ts";
|
||||
import type { ClientLevel } from "$/client/level/client_level.ts";
|
||||
import { light_color } from "$/client/renderer/mod.ts";
|
||||
import type { Entity } from "@/client/entity/entity.ts";
|
||||
import type { ClientLevel } from "@/client/level/client_level.ts";
|
||||
import { light_color } from "@/client/renderer/mod.ts";
|
||||
import type { Vec3 } from "./player_renderer.ts";
|
||||
|
||||
// the color for the light at a point, times tint (like the hurt flash)
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
// animation files yet: the model turns to the entity's yaw, a bone named "head" to where it looks, and bones named
|
||||
// like minecraft's humanoid ones (right_arm, left_arm, right_leg, left_leg) swing as it walks, the right arm when it
|
||||
// attacks too. entities without a model are their texture facing the camera, like minecraft's fishing hook
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import type { Camera } from "$/client/camera.ts";
|
||||
import type { RemoteEntity } from "$/client/entity/remote_entity.ts";
|
||||
import { push_vertex, type Texture } from "$/client/renderer/mod.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
import type { SpriteRegion } from "$/common/constants.ts";
|
||||
import { EverythingRegistry } from "$/common/everything_registry.ts";
|
||||
import type { EntityBoneJson, EntityJson, EntityModelJson } from "$/common/mod_data.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import type { Camera } from "@/client/camera.ts";
|
||||
import type { RemoteEntity } from "@/client/entity/remote_entity.ts";
|
||||
import { push_vertex, type Texture } from "@/client/renderer/mod.ts";
|
||||
import { get_sprite_region } from "@/client/sprites.ts";
|
||||
import type { SpriteRegion } from "@/common/constants.ts";
|
||||
import { EverythingRegistry } from "@/common/everything_registry.ts";
|
||||
import type { EntityBoneJson, EntityJson, EntityModelJson } from "@/common/mod_data.ts";
|
||||
import { HURT_TINT } from "./player_renderer.ts";
|
||||
import { IDENTITY, model_pivot, multiply, rotation_around, type Vec3 } from "./model_math.ts";
|
||||
import { push_model } from "./model_renderer.ts";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { Client } from "$/client/client.ts";
|
||||
import type { Camera } from "$/client/camera.ts";
|
||||
import type { ClientLevel } from "$/client/level/client_level.ts";
|
||||
import type { Client } from "@/client/client.ts";
|
||||
import type { Camera } from "@/client/camera.ts";
|
||||
import type { ClientLevel } from "@/client/level/client_level.ts";
|
||||
import {
|
||||
begin_mode_3d,
|
||||
canvas,
|
||||
@@ -12,14 +12,14 @@ import {
|
||||
end_mode_3d,
|
||||
set_render_time,
|
||||
update_lightmap,
|
||||
} from "$/client/renderer/mod.ts";
|
||||
import { daylight } from "$/common/time.ts";
|
||||
import { Hud } from "$/client/gui/hud.ts";
|
||||
import { DebugOverlay } from "$/client/gui/debug_overlay.ts";
|
||||
} from "@/client/renderer/mod.ts";
|
||||
import { daylight } from "@/common/time.ts";
|
||||
import { Hud } from "@/client/gui/hud.ts";
|
||||
import { DebugOverlay } from "@/client/gui/debug_overlay.ts";
|
||||
import { LevelRenderer } from "./level_renderer.ts";
|
||||
import { HandRenderer } from "./hand_renderer.ts";
|
||||
import { render_nameplates } from "./nameplate_renderer.ts";
|
||||
import { profiler } from "$/client/profiler.ts";
|
||||
import { profiler } from "@/client/profiler.ts";
|
||||
|
||||
// the sky at noon and in the middle of the night
|
||||
const DAY_SKY = [0.69, 0.8, 1];
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// they wear, like their curios. the gui has no depth buffer, so the faces are drawn back to front with the ones facing
|
||||
// away left out, like 3d items in slots
|
||||
import { push_vertex, type Texture, use_texture } from "../renderer/mod.ts";
|
||||
import type { ItemStack } from "$/common/inventory.ts";
|
||||
import type { ItemStack } from "@/common/inventory.ts";
|
||||
import { AssetManager } from "../assets.ts";
|
||||
import { rotation_around } from "./model_math.ts";
|
||||
import { part_point, PARTS, type PlayerPose, pose_at, pose_to_world, SLIM_PARTS } from "./player_model.ts";
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
// ItemInHandRenderer. with empty hands it's their right arm, in their skin, like minecraft's
|
||||
// FirstPersonHandsAndItemsRenderer.renderPlayerArm
|
||||
import { mat4, vec3 } from "gl-matrix";
|
||||
import type { ItemStack } from "$/common/inventory.ts";
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import type { LocalPlayer } from "$/client/entity/local_player.ts";
|
||||
import type { ItemStack } from "@/common/inventory.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import type { LocalPlayer } from "@/client/entity/local_player.ts";
|
||||
import {
|
||||
begin_view_model,
|
||||
end_mode_3d,
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
set_current_texture,
|
||||
Texture,
|
||||
use_texture,
|
||||
} from "$/client/renderer/mod.ts";
|
||||
} from "@/client/renderer/mod.ts";
|
||||
import { display_transform, drawn_as_model, item_model_of, push_item } from "./item_renderer.ts";
|
||||
import { push_cube, type Vec3 } from "./player_renderer.ts";
|
||||
import { right_arm } from "./player_model.ts";
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// the 3d model of a flat item, like minecraft's item/generated: its sprite on the front and back, one pixel apart, with
|
||||
// a side face along every edge between a pixel that can be seen and one that can't (or the sprite's border)
|
||||
import { TEXTURE_SIZE } from "$/common/constants.ts";
|
||||
import { opaque_pixels, type OpaqueMask } from "$/client/atlas.ts";
|
||||
import { TEXTURE_SIZE } from "@/common/constants.ts";
|
||||
import { opaque_pixels, type OpaqueMask } from "@/client/atlas.ts";
|
||||
|
||||
export interface ItemQuad {
|
||||
// 4 corners counter clockwise seen from outside. x from -0.5 to 0.5 and y from 0 to 1 across the sprite, z its
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { mat4, vec3 } from "gl-matrix";
|
||||
import type { SpriteRegion } from "$/common/constants.ts";
|
||||
import { BlockRegistry, EverythingRegistry, type ItemLayer, ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
import type { ItemEntity } from "$/client/entity/item_entity.ts";
|
||||
import { contained_fluid, type ItemData, ItemStack } from "$/common/inventory.ts";
|
||||
import type { FluidVariant } from "$/common/mod_api/shared.ts";
|
||||
import type { FluidJson } from "$/common/mod_data.ts";
|
||||
import { light_color, push_vertex, Texture } from "$/client/renderer/mod.ts";
|
||||
import type { SpriteRegion } from "@/common/constants.ts";
|
||||
import { BlockRegistry, EverythingRegistry, type ItemLayer, ItemRegistry } from "@/common/everything_registry.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import { get_sprite_region } from "@/client/sprites.ts";
|
||||
import type { ItemEntity } from "@/client/entity/item_entity.ts";
|
||||
import { contained_fluid, type ItemData, ItemStack } from "@/common/inventory.ts";
|
||||
import type { FluidVariant } from "@/common/mod_api/shared.ts";
|
||||
import type { FluidJson } from "@/common/mod_data.ts";
|
||||
import { light_color, push_vertex, Texture } from "@/client/renderer/mod.ts";
|
||||
import {
|
||||
bake_model,
|
||||
type BakedQuad,
|
||||
@@ -24,15 +24,15 @@ import {
|
||||
item_tint,
|
||||
type ModelDisplay,
|
||||
type ModelJson,
|
||||
} from "$/common/block_models.ts";
|
||||
} from "@/common/block_models.ts";
|
||||
import { item_model, type ItemQuad } from "./item_model.ts";
|
||||
import { get_state_value, item_texture } from "$/common/utils.ts";
|
||||
import { ID_MASK, TEXTURE_SIZE } from "$/common/constants.ts";
|
||||
import type { ClientLevel } from "$/client/level/client_level.ts";
|
||||
import { get_state_value, item_texture } from "@/common/utils.ts";
|
||||
import { ID_MASK, TEXTURE_SIZE } from "@/common/constants.ts";
|
||||
import type { ClientLevel } from "@/client/level/client_level.ts";
|
||||
import { entity_tint } from "./entity_light.ts";
|
||||
import type { Vec3 } from "./player_renderer.ts";
|
||||
import { fluid_rules } from "$/client/fluid_rules.ts";
|
||||
import { color_rgb, tint_without_biome, type TintColor } from "$/common/worldgen/biome_colors.ts";
|
||||
import { fluid_rules } from "@/client/fluid_rules.ts";
|
||||
import { color_rgb, tint_without_biome, type TintColor } from "@/common/worldgen/biome_colors.ts";
|
||||
|
||||
// how big items on the ground are drawn, minecraft's ground transform
|
||||
const BLOCK_SCALE = 0.25;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { type Chunk, CHUNK_SIZE, type ChunkMesh, ClientLevel } from "$/client/level/client_level.ts";
|
||||
import { profiler } from "$/client/profiler.ts";
|
||||
import { Camera } from "$/client/camera.ts";
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
import type { MultiPlayerGameMode } from "$/client/game_mode.ts";
|
||||
import type { Entity } from "$/client/entity/entity.ts";
|
||||
import { RemotePlayer } from "$/client/entity/remote_player.ts";
|
||||
import { ItemEntity } from "$/client/entity/item_entity.ts";
|
||||
import { type Chunk, CHUNK_SIZE, type ChunkMesh, ClientLevel } from "@/client/level/client_level.ts";
|
||||
import { profiler } from "@/client/profiler.ts";
|
||||
import { Camera } from "@/client/camera.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import { get_sprite_region } from "@/client/sprites.ts";
|
||||
import type { MultiPlayerGameMode } from "@/client/game_mode.ts";
|
||||
import type { Entity } from "@/client/entity/entity.ts";
|
||||
import { RemotePlayer } from "@/client/entity/remote_player.ts";
|
||||
import { ItemEntity } from "@/client/entity/item_entity.ts";
|
||||
import { render_block_items, render_item_entity } from "./item_renderer.ts";
|
||||
import { HURT_TINT, player_pose, render_player } from "./player_renderer.ts";
|
||||
import { render_worn } from "./worn_renderer.ts";
|
||||
@@ -17,7 +17,7 @@ import type { PlayerPose } from "./player_model.ts";
|
||||
import type { Vec3 } from "./model_math.ts";
|
||||
import { render_mod_entity } from "./entity_renderer.ts";
|
||||
import { entity_tint } from "./entity_light.ts";
|
||||
import { RemoteEntity } from "$/client/entity/remote_entity.ts";
|
||||
import { RemoteEntity } from "@/client/entity/remote_entity.ts";
|
||||
import {
|
||||
draw_terrain,
|
||||
flush_batch,
|
||||
@@ -28,14 +28,14 @@ import {
|
||||
use_texture,
|
||||
view_projection,
|
||||
white_tex,
|
||||
} from "$/client/renderer/mod.ts";
|
||||
import { type BlockRegistry, EverythingRegistry, type RenderLayer } from "$/common/everything_registry.ts";
|
||||
import { bake_block, type BakedQuad, FACE_INDEX, looks_by_state, type ModelJson } from "$/common/block_models.ts";
|
||||
import { BREAK_STAGES, ID_MASK } from "$/common/constants.ts";
|
||||
import { type Shape, shape_at } from "$/common/block_shapes.ts";
|
||||
import type { BlockHitResult } from "$/client/level/client_level.ts";
|
||||
import { FACE_GROUPS, UNALIGNED_GROUP } from "$/client/workers/chunk_messages.ts";
|
||||
import { FACE_AXIS, FACE_NORMALS } from "$/client/workers/translucent_sort.ts";
|
||||
} from "@/client/renderer/mod.ts";
|
||||
import { type BlockRegistry, EverythingRegistry, type RenderLayer } from "@/common/everything_registry.ts";
|
||||
import { bake_block, type BakedQuad, FACE_INDEX, looks_by_state, type ModelJson } from "@/common/block_models.ts";
|
||||
import { BREAK_STAGES, ID_MASK } from "@/common/constants.ts";
|
||||
import { type Shape, shape_at } from "@/common/block_shapes.ts";
|
||||
import type { BlockHitResult } from "@/client/level/client_level.ts";
|
||||
import { FACE_GROUPS, UNALIGNED_GROUP } from "@/client/workers/chunk_messages.ts";
|
||||
import { FACE_AXIS, FACE_NORMALS } from "@/client/workers/translucent_sort.ts";
|
||||
import { Frustum } from "./frustum.ts";
|
||||
import { draw_visuals } from "./visuals.ts";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
// turning and moving the parts of models: entity models' bones, the player's parts and what's worn on them. no
|
||||
// drawing here, so tests can use it
|
||||
import type { EntityBoneJson, EntityModelJson } from "$/common/mod_data.ts";
|
||||
import type { EntityBoneJson, EntityModelJson } from "@/common/mod_data.ts";
|
||||
|
||||
export type Vec3 = [number, number, number];
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// entity models' boxes, for mod entities and for what players wear. the atlas has to be the current texture
|
||||
import type { Texture } from "$/client/renderer/mod.ts";
|
||||
import type { SpriteRegion } from "$/common/constants.ts";
|
||||
import type { EntityBoneJson, EntityModelJson } from "$/common/mod_data.ts";
|
||||
import type { Texture } from "@/client/renderer/mod.ts";
|
||||
import type { SpriteRegion } from "@/common/constants.ts";
|
||||
import type { EntityBoneJson, EntityModelJson } from "@/common/mod_data.ts";
|
||||
import { apply, bone_matrices, type Matrix, type Vec3 } from "./model_math.ts";
|
||||
import { push_box, type VertexSink } from "./player_renderer.ts";
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { Camera } from "$/client/camera.ts";
|
||||
import type { Entity } from "$/client/entity/entity.ts";
|
||||
import type { ClientLevel } from "$/client/level/client_level.ts";
|
||||
import { RemotePlayer } from "$/client/entity/remote_player.ts";
|
||||
import { draw_rect_3d, draw_text_3d, flush_batch, measure_text, type Plane3d } from "$/client/renderer/mod.ts";
|
||||
import type { Camera } from "@/client/camera.ts";
|
||||
import type { Entity } from "@/client/entity/entity.ts";
|
||||
import type { ClientLevel } from "@/client/level/client_level.ts";
|
||||
import { RemotePlayer } from "@/client/entity/remote_player.ts";
|
||||
import { draw_rect_3d, draw_text_3d, flush_batch, measure_text, type Plane3d } from "@/client/renderer/mod.ts";
|
||||
|
||||
// how big a font pixel is, in blocks. m6x11's letters are 11 pixels tall, so about a quarter of a block
|
||||
const SCALE = 0.022;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
// minecraft's player model and how it's posed each frame, for drawing players and what they wear. no drawing here, so
|
||||
// tests can use it
|
||||
import { PLAYER_HEIGHT, PLAYER_SWIM_HEIGHT } from "$/common/constants.ts";
|
||||
import { PLAYER_PARTS, type WornProperties } from "$/common/everything_registry.ts";
|
||||
import type { EntityBoneJson, EntityModelJson } from "$/common/mod_data.ts";
|
||||
import { PLAYER_HEIGHT, PLAYER_SWIM_HEIGHT } from "@/common/constants.ts";
|
||||
import { PLAYER_PARTS, type WornProperties } from "@/common/everything_registry.ts";
|
||||
import type { EntityBoneJson, EntityModelJson } from "@/common/mod_data.ts";
|
||||
import { apply, IDENTITY, type Matrix, multiply, rotation_around, type Vec3 } from "./model_math.ts";
|
||||
|
||||
export type PartName = typeof PLAYER_PARTS[number];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { Player } from "$/client/entity/player.ts";
|
||||
import { push_vertex, type Texture } from "$/client/renderer/mod.ts";
|
||||
import type { Player } from "@/client/entity/player.ts";
|
||||
import { push_vertex, type Texture } from "@/client/renderer/mod.ts";
|
||||
import type { Vec3 } from "./model_math.ts";
|
||||
import {
|
||||
type ModelPart,
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { mat4, vec3 } from "gl-matrix";
|
||||
import { SLOT_SIZE } from "$/common/constants.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import type { FluidVariant } from "$/common/mod_api/shared.ts";
|
||||
import { item_texture } from "$/common/utils.ts";
|
||||
import { SLOT_SIZE } from "@/common/constants.ts";
|
||||
import { get_sprite_region } from "@/client/sprites.ts";
|
||||
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "@/common/everything_registry.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import { ItemStack } from "@/common/inventory.ts";
|
||||
import type { FluidVariant } from "@/common/mod_api/shared.ts";
|
||||
import { item_texture } from "@/common/utils.ts";
|
||||
import {
|
||||
cube_face_texture,
|
||||
cube_face_tint,
|
||||
type DisplayTransform,
|
||||
ITEM_FACE_SHADE,
|
||||
item_tint,
|
||||
} from "$/common/block_models.ts";
|
||||
} from "@/common/block_models.ts";
|
||||
import {
|
||||
display_matrix,
|
||||
fluid_look,
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
push_vertex,
|
||||
Texture,
|
||||
use_texture,
|
||||
} from "$/client/renderer/mod.ts";
|
||||
} from "@/client/renderer/mod.ts";
|
||||
|
||||
// the corners keep their size (times scale), the edges stretch along and the middle fills the rest, like minecraft's
|
||||
// nine slice gui sprites. borders are in source pixels
|
||||
|
||||
@@ -16,8 +16,8 @@ import type {
|
||||
TransformedInstance,
|
||||
Visual,
|
||||
VisualBlock,
|
||||
} from "$/common/mod_api/client.ts";
|
||||
import { type BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
|
||||
} from "@/common/mod_api/client.ts";
|
||||
import { type BlockRegistry, EverythingRegistry } from "@/common/everything_registry.ts";
|
||||
import {
|
||||
bake_block,
|
||||
bake_model,
|
||||
@@ -27,11 +27,11 @@ import {
|
||||
type ModelElementJson,
|
||||
type ModelJson,
|
||||
states_of,
|
||||
} from "$/common/block_models.ts";
|
||||
import { CHUNK_AREA, CHUNK_SIZE, ID_MASK } from "$/common/constants.ts";
|
||||
import type { ModelFace } from "$/common/mod_data.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import { chunk_key, item_texture } from "$/common/utils.ts";
|
||||
} from "@/common/block_models.ts";
|
||||
import { CHUNK_AREA, CHUNK_SIZE, ID_MASK } from "@/common/constants.ts";
|
||||
import type { ModelFace } from "@/common/mod_data.ts";
|
||||
import { ItemStack } from "@/common/inventory.ts";
|
||||
import { chunk_key, item_texture } from "@/common/utils.ts";
|
||||
import {
|
||||
create_vertex_buffer,
|
||||
destroy_buffer,
|
||||
@@ -40,8 +40,8 @@ import {
|
||||
MODEL_VERTEX_BYTES,
|
||||
type Texture,
|
||||
write_buffer,
|
||||
} from "$/client/renderer/mod.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
} from "@/client/renderer/mod.ts";
|
||||
import { get_sprite_region } from "@/client/sprites.ts";
|
||||
import { fluid_look, ground_transform, item_layers, push_item, sprite_u, sprite_v } from "./item_renderer.ts";
|
||||
|
||||
export interface VisualRegistration {
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
// what players wear, like curios' render layer: each worn item's model (see WornProperties) on the player, its bones
|
||||
// named like the player's parts turned the way those parts are, so it moves with them like minecraft's
|
||||
// TransformCopyingHumanoidModel. see docs/modding/items/index.md
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import type { Player } from "$/client/entity/player.ts";
|
||||
import type { ItemStack } from "$/common/inventory.ts";
|
||||
import type { Texture } from "$/client/renderer/mod.ts";
|
||||
import { get_sprite_region } from "$/client/sprites.ts";
|
||||
import { EverythingRegistry, type ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import type { EntityBoneJson, EntityModelJson } from "$/common/mod_data.ts";
|
||||
import { AssetManager } from "@/client/assets.ts";
|
||||
import type { Player } from "@/client/entity/player.ts";
|
||||
import type { ItemStack } from "@/common/inventory.ts";
|
||||
import type { Texture } from "@/client/renderer/mod.ts";
|
||||
import { get_sprite_region } from "@/client/sprites.ts";
|
||||
import { EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
|
||||
import type { EntityBoneJson, EntityModelJson } from "@/common/mod_data.ts";
|
||||
import { IDENTITY, type Vec3 } from "./model_math.ts";
|
||||
import { push_model } from "./model_renderer.ts";
|
||||
import type { VertexSink } from "./player_renderer.ts";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { type SpriteRegion, TEXTURE_SIZE } from "$/common/constants.ts";
|
||||
import { type SpriteRegion, TEXTURE_SIZE } from "@/common/constants.ts";
|
||||
import { AssetManager } from "./assets.ts";
|
||||
|
||||
type TexturesInfo = Record<string, SpriteRegion>;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// animated textures play like minecraft's: the atlas holds one frame of each, and every tick the ones whose frame
|
||||
// changed copy the new frame's pixels over it. models never change, only the atlas does
|
||||
import type { SpriteRegion } from "$/common/constants.ts";
|
||||
import type { Animation } from "$/common/texture_animation.ts";
|
||||
import type { SpriteRegion } from "@/common/constants.ts";
|
||||
import type { Animation } from "@/common/texture_animation.ts";
|
||||
|
||||
// pixels to copy into a texture's place in the atlas: frame_width × frame_height of them, starting at offset bytes
|
||||
// into data, rows bytes_per_row apart
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { BlockRegistry } from "$/common/everything_registry.ts";
|
||||
import type { SpriteRegion } from "$/common/constants.ts";
|
||||
import type { ModelJson } from "$/common/block_models.ts";
|
||||
import type { BlockRegistry } from "@/common/everything_registry.ts";
|
||||
import type { SpriteRegion } from "@/common/constants.ts";
|
||||
import type { ModelJson } from "@/common/block_models.ts";
|
||||
import type { SortType } from "./translucent_sort.ts";
|
||||
|
||||
// messages between the main thread and the chunk workers
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
block_light_opacity,
|
||||
type BlockRegistry,
|
||||
type RenderLayer,
|
||||
} from "$/common/everything_registry.ts";
|
||||
} from "@/common/everything_registry.ts";
|
||||
import {
|
||||
AIR,
|
||||
CHUNK_AREA,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
ID_MASK,
|
||||
type SpriteRegion,
|
||||
TEXTURE_SIZE,
|
||||
} from "$/common/constants.ts";
|
||||
} from "@/common/constants.ts";
|
||||
import type { Texture } from "../renderer/types.ts";
|
||||
import {
|
||||
FACE_GROUPS,
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
is_tinted,
|
||||
looks_by_state,
|
||||
type ModelJson,
|
||||
} from "$/common/block_models.ts";
|
||||
} from "@/common/block_models.ts";
|
||||
import {
|
||||
choose_sort_type,
|
||||
FACE_AXIS,
|
||||
@@ -56,7 +56,7 @@ import {
|
||||
REGION_VOID,
|
||||
} from "./lighting.ts";
|
||||
import { cell_index, fluid_quads, type FluidCell } from "./fluid_mesh.ts";
|
||||
import { fluid_height, fluid_textures } from "$/common/everything_registry.ts";
|
||||
import { fluid_height, fluid_textures } from "@/common/everything_registry.ts";
|
||||
|
||||
type TexturesInfo = Record<string, SpriteRegion>;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// fluids drawn like luanti's flowing fluids (MapblockMeshGenerator::drawLiquidNode in its content_mapblock.cpp): each
|
||||
// corner of the surface is as high as the fluid around it, so it slopes down where it flows away from a source. the
|
||||
// sides between two cells of it are left out, except where it pours down past the surface of the one beside it
|
||||
import { FACE_CORNERS } from "$/common/block_models.ts";
|
||||
import { FACE_CORNERS } from "@/common/block_models.ts";
|
||||
|
||||
// one of the 3x3 cells around a fluid and level with it, and the cell above that one
|
||||
export interface FluidCell {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// 3x3 chunks around the chunk being meshed, which gives the same result: light reaches at most 15
|
||||
// blocks, so nothing outside those chunks can light the middle one or its border
|
||||
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, ID_MASK } from "$/common/constants.ts";
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, ID_MASK } from "@/common/constants.ts";
|
||||
|
||||
export const REGION_SIZE = CHUNK_SIZE * 3;
|
||||
export const REGION_LAYER = REGION_SIZE * REGION_SIZE;
|
||||
|
||||
+2
-2
@@ -238,9 +238,9 @@ export function read_bmod(bytes: Uint8Array, file: string): Bmod {
|
||||
scripts[side as ScriptSide] = code;
|
||||
}
|
||||
}
|
||||
// what the bworld/engine shim reads, so it's in the bundle of every script that imports it
|
||||
// what the cubi/engine shim reads, so it's in the bundle of every script that imports it
|
||||
if (!manifest.engine_access && Object.values(scripts).some((code) => code.includes(ENGINE_GLOBAL))) {
|
||||
problems.push(`a script uses bworld/engine, which needs "engine_access": true in manifest.json`);
|
||||
problems.push(`a script uses cubi/engine, which needs "engine_access": true in manifest.json`);
|
||||
}
|
||||
const credits = manifest.credits === undefined ? undefined : text(manifest.credits);
|
||||
if (manifest.credits !== undefined && credits === undefined) {
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
// generating a chunk: the terrain from the generator's data (common/worldgen), then ores, then mods' features.
|
||||
// only the server generates, players get finished chunks
|
||||
import { Alea } from "@paulaboks/rng";
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, ID_MASK } from "$/common/constants.ts";
|
||||
import type { FeatureChunk, Position } from "$/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "$/common/mod_data.ts";
|
||||
import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, ID_MASK } from "@/common/constants.ts";
|
||||
import type { FeatureChunk, Position } from "@/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "@/common/mod_data.ts";
|
||||
import { generate_overworld } from "./worldgen/overworld.ts";
|
||||
import type { Generator } from "./worldgen/generator.ts";
|
||||
import { named_noise_2d, named_noise_3d } from "./worldgen/noise.ts";
|
||||
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// engine access: hooks on the engine's own methods, like neoforge's mixins, and the global the bworld/engine shim reads.
|
||||
// engine access: hooks on the engine's own methods, like neoforge's mixins, and the global the cubi/engine shim reads.
|
||||
// see docs/modding/misc/engine.md and docs/modding_plan.md
|
||||
import { GAME_VERSION } from "./constants.ts";
|
||||
|
||||
@@ -199,7 +199,7 @@ export function clear_hooks() {
|
||||
hooked.clear();
|
||||
}
|
||||
|
||||
// runs fn as the mod: hook knows whose hooks it makes, and bworld/engine refuses mods without engine_access
|
||||
// runs fn as the mod: hook knows whose hooks it makes, and cubi/engine refuses mods without engine_access
|
||||
export async function loading_mod<T>(mod: string, engine_access: boolean, fn: () => Promise<T>): Promise<T> {
|
||||
const previous = loading;
|
||||
loading = { mod, engine_access };
|
||||
@@ -217,7 +217,7 @@ export interface EngineModules {
|
||||
client?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// what bworld/engine reads, see common/mod_api/engine.ts
|
||||
// what cubi/engine reads, see common/mod_api/engine.ts
|
||||
export interface EngineGlobal {
|
||||
version: string;
|
||||
engine: EngineModules;
|
||||
@@ -226,9 +226,9 @@ export interface EngineGlobal {
|
||||
check_access(): void;
|
||||
}
|
||||
|
||||
export const ENGINE_GLOBAL = "__bworld_engine";
|
||||
export const ENGINE_GLOBAL = "__cubi_engine";
|
||||
|
||||
// puts a side's modules where bworld/engine finds them. a realm with the server and a client in it, like tests, gets
|
||||
// puts a side's modules where cubi/engine finds them. a realm with the server and a client in it, like tests, gets
|
||||
// both
|
||||
export function expose_engine(modules: EngineModules) {
|
||||
const global = globalThis as unknown as Record<string, EngineGlobal | undefined>;
|
||||
@@ -242,9 +242,9 @@ export function expose_engine(modules: EngineModules) {
|
||||
engine: { ...modules },
|
||||
hook,
|
||||
check_access() {
|
||||
if (!loading) throw new Error("bworld/engine can only be imported by a mod's script");
|
||||
if (!loading) throw new Error("cubi/engine can only be imported by a mod's script");
|
||||
if (!loading.engine_access) {
|
||||
throw new Error(`${loading.mod} imports bworld/engine without "engine_access" in its manifest`);
|
||||
throw new Error(`${loading.mod} imports cubi/engine without "engine_access" in its manifest`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { EverythingRegistry, ItemRegistry } from "@/common/everything_registry.ts";
|
||||
import type { FluidRules } from "./fluids.ts";
|
||||
import type { FluidVariant } from "./mod_api/shared.ts";
|
||||
import { is_object } from "./schema.ts";
|
||||
|
||||
@@ -125,7 +125,7 @@ export interface VisualBlock {
|
||||
readonly z: number;
|
||||
// they stay the same for the visual's life, it's made again when they change
|
||||
readonly states: Readonly<Record<string, number>>;
|
||||
// a field of its client data now, a copy, see BlockRef.set_client_data in bworld/server
|
||||
// a field of its client data now, a copy, see BlockRef.set_client_data in cubi/server
|
||||
get_client_data<T>(field: string): T | undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// bworld/engine: engine access, for what the game api doesn't cover yet. a mod needs "engine_access": true and a
|
||||
// cubi/engine: engine access, for what the game api doesn't cover yet. a mod needs "engine_access": true and a
|
||||
// game_version within one minor version in its manifest. see docs/modding/misc/engine.md
|
||||
//
|
||||
// this is bundled into each mod that imports it, so it only imports types: the engine and hook are the game's own,
|
||||
@@ -21,8 +21,8 @@ export interface Engine {
|
||||
client: ReturnType<typeof client_engine>;
|
||||
}
|
||||
|
||||
const api = (globalThis as unknown as Record<string, EngineGlobal | undefined>)["__bworld_engine"];
|
||||
if (!api) throw new Error("bworld/engine only works in a mod's script, loaded by the game");
|
||||
const api = (globalThis as unknown as Record<string, EngineGlobal | undefined>)["__cubi_engine"];
|
||||
if (!api) throw new Error("cubi/engine only works in a mod's script, loaded by the game");
|
||||
api.check_access();
|
||||
|
||||
export const engine = api.engine as Engine;
|
||||
|
||||
@@ -118,7 +118,7 @@ export interface BlockComponent<P = any> {
|
||||
// particular when it's undefined, like neoforge's Capabilities.FluidHandler.BLOCK. undefined when it has none
|
||||
// there. see ServerFluidApi.block_handler
|
||||
fluid_handler?(block: BlockRef, params: P, face: Face | undefined): FluidHandler | undefined;
|
||||
// placing and neighbor rules are in shared scripts, see BlockRules in bworld/shared
|
||||
// placing and neighbor rules are in shared scripts, see BlockRules in cubi/shared
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ const manifest_schema = (folder_name: string) =>
|
||||
version: z.string("must be semver, like 1.0.0").regex(/^\d+\.\d+\.\d+/),
|
||||
authors: z.array(z.string()).optional(),
|
||||
game_version: z.string().optional(),
|
||||
// imports bworld/engine to reach into the engine and hook its methods. needs game_version within one minor version
|
||||
// imports cubi/engine to reach into the engine and hook its methods. needs game_version within one minor version
|
||||
engine_access: z.boolean().optional(),
|
||||
dependencies: z.array(z.object({ id: z.string(), version: z.string() })).optional(),
|
||||
scripts: z.strictObject({
|
||||
|
||||
@@ -83,7 +83,7 @@ export interface ModListing {
|
||||
// where it's served from, relative to the server's root. named by its hash, so it never changes
|
||||
file: string;
|
||||
size: number;
|
||||
// it imports bworld/engine, see docs/modding/misc/engine.md. the confirm screen for other sites says so
|
||||
// it imports cubi/engine, see docs/modding/misc/engine.md. the confirm screen for other sites says so
|
||||
engine_access?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// noise cells), caves cut out of it, then each column's biome, its surface blocks and fluids. what all of it is comes
|
||||
// from the generator's noise settings, see OverworldTerrain and docs/modding/worldgen/terrain.md. trees and the rest
|
||||
// are features, after it
|
||||
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts";
|
||||
import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "@/common/constants.ts";
|
||||
import { get_biome } from "./biomes.ts";
|
||||
import type { OverworldTerrain, TerrainColumn } from "./terrain.ts";
|
||||
import {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// imports mods' worldgen scripts and collects what they and mods' data add to generation: the generator, ores, and
|
||||
// features, code and data, in the order they run. used by the game server
|
||||
import type { FeatureBiome, FeatureChunk, FeatureStep, WorldgenContext } from "$/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "$/common/mod_data.ts";
|
||||
import type { FeatureBiome, FeatureChunk, FeatureStep, WorldgenContext } from "@/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "@/common/mod_data.ts";
|
||||
import type { SetupFeature, WorldgenSetup } from "./generation.ts";
|
||||
import { EverythingRegistry } from "./everything_registry.ts";
|
||||
import { ModLoadError } from "./mod_loader.ts";
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
"exclude": ["desktop/*.md"]
|
||||
},
|
||||
"imports": {
|
||||
"$/": "./",
|
||||
"bworld/server": "./common/mod_api/server.ts",
|
||||
"bworld/client": "./common/mod_api/client.ts",
|
||||
"bworld/worldgen": "./common/mod_api/worldgen.ts",
|
||||
"bworld/shared": "./common/mod_api/shared.ts",
|
||||
"bworld/engine": "./common/mod_api/engine.ts",
|
||||
"@/": "./",
|
||||
"cubi/server": "./common/mod_api/server.ts",
|
||||
"cubi/client": "./common/mod_api/client.ts",
|
||||
"cubi/worldgen": "./common/mod_api/worldgen.ts",
|
||||
"cubi/shared": "./common/mod_api/shared.ts",
|
||||
"cubi/engine": "./common/mod_api/engine.ts",
|
||||
"@gfx/canvas-wasm": "jsr:@gfx/canvas-wasm@^0.4.2",
|
||||
"@paulaboks/rng": "jsr:@paulaboks/rng@^0.0.3",
|
||||
"@std/assert": "jsr:@std/assert@^1.0.0",
|
||||
|
||||
@@ -23,7 +23,7 @@ A block can list several. Their handlers run in the listed order.
|
||||
In the server script:
|
||||
|
||||
```ts
|
||||
import type { ServerContext } from "bworld/server";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
|
||||
interface OxidizesParams {
|
||||
seconds: number;
|
||||
@@ -150,7 +150,7 @@ run them too: that's how a player sees a fence join its neighbors the moment the
|
||||
when the server answers. A component can have rules, handlers, or both, and a block can list one that only has rules.
|
||||
|
||||
```ts
|
||||
import type { SharedContext } from "bworld/shared";
|
||||
import type { SharedContext } from "cubi/shared";
|
||||
|
||||
export function setup(ctx: SharedContext) {
|
||||
ctx.components.register_block("copper_tools:pipe", {
|
||||
|
||||
@@ -8,7 +8,7 @@ draws its machines with.
|
||||
## Registering
|
||||
|
||||
```ts
|
||||
import type { ClientContext } from "bworld/client";
|
||||
import type { ClientContext } from "cubi/client";
|
||||
|
||||
export function setup(ctx: ClientContext) {
|
||||
ctx.render.register_visual("copper_tools:shaft", (block, instances) => {
|
||||
|
||||
@@ -13,7 +13,7 @@ Every event is a signal you subscribe to. Events come in two kinds:
|
||||
- **After events** fire once it has happened. They're for reacting, and can't change anything.
|
||||
|
||||
```ts
|
||||
import type { ServerContext } from "bworld/server";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
|
||||
export function setup(ctx: ServerContext) {
|
||||
// nobody breaks blocks within 16 blocks of the world's center
|
||||
|
||||
@@ -46,7 +46,7 @@ on every client, before any script runs. See [Registries](registries.md).
|
||||
### Server Scripts
|
||||
|
||||
```ts
|
||||
import type { ServerContext } from "bworld/server";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
|
||||
export function setup(ctx: ServerContext) {
|
||||
// register components and commands, subscribe to events
|
||||
@@ -64,7 +64,7 @@ world, through [tile data](../blocks/tiledata.md), [containers](../inventories/c
|
||||
### Client Scripts
|
||||
|
||||
```ts
|
||||
import type { ClientContext } from "bworld/client";
|
||||
import type { ClientContext } from "cubi/client";
|
||||
|
||||
export function setup(ctx: ClientContext) {
|
||||
ctx.ui.add_inventory_overlay({ on_render(g, screen) {/* ... */} });
|
||||
@@ -81,7 +81,7 @@ Client code is visible to players and can be changed by them. Never trust it for
|
||||
### Shared Scripts
|
||||
|
||||
```ts
|
||||
import type { SharedContext } from "bworld/shared";
|
||||
import type { SharedContext } from "cubi/shared";
|
||||
|
||||
export function setup(ctx: SharedContext) {
|
||||
ctx.components.register_block("copper_tools:pipe", {
|
||||
|
||||
@@ -48,7 +48,7 @@ An effect that does something each tick lists components, with their parameters:
|
||||
The server script registers them during `setup`, in the mod's own namespace:
|
||||
|
||||
```ts
|
||||
import type { ServerContext } from "bworld/server";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
|
||||
export function setup(ctx: ServerContext) {
|
||||
ctx.components.register_effect<{ every: number }>("copper_tools:rusting", {
|
||||
|
||||
@@ -81,7 +81,7 @@ matter, the `id` inside does, except for [tags](../resources/tags.md), whose id
|
||||
| `version` | yes | The mod's own version, semver like `1.0.0`. |
|
||||
| `authors` | no | A list of names. |
|
||||
| `game_version` | no | The bworld versions the mod works with, as a semver range. Only checked for mods with `engine_access`. |
|
||||
| `engine_access` | no | `true` lets the scripts import `bworld/engine` and hook the engine. See [Engine Access](../misc/engine.md). |
|
||||
| `engine_access` | no | `true` lets the scripts import `cubi/engine` and hook the engine. See [Engine Access](../misc/engine.md). |
|
||||
| `dependencies` | no | Other mods, `{ "id", "version" }`. A missing dependency is an error, and dependencies load first. The version range isn't checked yet. |
|
||||
| `scripts` | no | Paths to the `server`, `client`, `shared` and `worldgen` scripts. See [Sides](../concepts/sides.md). |
|
||||
| `credits` | no | A markdown file for licenses and thanks, shown on the Credits screen. Raw HTML in it is shown as text. |
|
||||
@@ -102,11 +102,11 @@ so they can import other files and packages, but code imported by several script
|
||||
|
||||
When a mod's folder has a `deno.json`, its scripts are bundled and typechecked with it, so the mod can have its own
|
||||
imports and npm or JSR packages. Mods without one use the `deno.json` of the folder the build runs in, like the mods in
|
||||
this repository. That config maps the API types, which scripts import as `bworld/server`, `bworld/client`,
|
||||
`bworld/shared` and `bworld/worldgen`, and [`bworld/engine`](../misc/engine.md):
|
||||
this repository. That config maps the API types, which scripts import as `cubi/server`, `cubi/client`, `cubi/shared` and
|
||||
`cubi/worldgen`, and [`cubi/engine`](../misc/engine.md):
|
||||
|
||||
```ts
|
||||
import type { ServerContext } from "bworld/server";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
```
|
||||
|
||||
## `.bmod` Files
|
||||
|
||||
@@ -53,7 +53,7 @@ the screen, like Just Enough Items' item list. A menu screen with `inventory_ove
|
||||
game's fishing minigame. `mods/recipe_viewer` is one.
|
||||
|
||||
```ts
|
||||
import type { ClientContext } from "bworld/client";
|
||||
import type { ClientContext } from "cubi/client";
|
||||
|
||||
export function setup(ctx: ClientContext) {
|
||||
ctx.ui.add_inventory_overlay({
|
||||
|
||||
@@ -11,7 +11,7 @@ Each argument type reads its part of the text and suggests what could go there.
|
||||
In the server script's `setup`:
|
||||
|
||||
```ts
|
||||
import type { Player, ServerContext } from "bworld/server";
|
||||
import type { Player, ServerContext } from "cubi/server";
|
||||
|
||||
export function setup(ctx: ServerContext) {
|
||||
const { literal, argument, types } = ctx.commands;
|
||||
|
||||
@@ -29,7 +29,7 @@ can change has to be in this file with its default.
|
||||
`ctx.config` in the server script holds the settings, with the server's changes made:
|
||||
|
||||
```ts
|
||||
import type { ServerContext } from "bworld/server";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
|
||||
interface Config {
|
||||
max_speed: number;
|
||||
|
||||
@@ -15,14 +15,14 @@ Prefer the Game API. Many mods hooking the same thing is a sign it should become
|
||||
`game_version` has to be one minor version: `~0.1.0` (0.1.0 and later 0.1 patches) or an exact `0.1.2`. Loading the mod
|
||||
on another version is a load error, so the server doesn't start with it.
|
||||
|
||||
Without `engine_access`, importing `bworld/engine` is an error in `check-mods`, when a `.bmod` loads, and when the
|
||||
script runs. When players join from another site, the confirm screen marks mods that change the engine.
|
||||
Without `engine_access`, importing `cubi/engine` is an error in `check-mods`, when a `.bmod` loads, and when the script
|
||||
runs. When players join from another site, the confirm screen marks mods that change the engine.
|
||||
|
||||
## Hooking
|
||||
|
||||
```ts
|
||||
// server.ts: broken blocks drop twice
|
||||
import { engine, hook } from "bworld/engine";
|
||||
import { engine, hook } from "cubi/engine";
|
||||
|
||||
export function setup() {
|
||||
hook(engine.server.GameServer.prototype, "pop_item", {
|
||||
@@ -60,8 +60,8 @@ made changes too. It returns a function that unhooks it.
|
||||
| `client` | client scripts | `Client`, `LocalPlayer`, `ClientLevel`, `GameRenderer`, `Camera`, `GuiScreen` |
|
||||
|
||||
The full lists are in `common/engine_modules.ts`, `server/game/engine_modules.ts` and `client/engine_modules.ts`. The
|
||||
types are the engine's own source, so `check-mods` typechecks against exactly the engine the mod runs on.
|
||||
`bworld/engine` also exports `game_version`, the version of the game that's running.
|
||||
types are the engine's own source, so `check-mods` typechecks against exactly the engine the mod runs on. `cubi/engine`
|
||||
also exports `game_version`, the version of the game that's running.
|
||||
|
||||
- Module exports can't be reassigned, so functions mods may want to change are on plain objects the engine calls
|
||||
through: `engine.common.physics.move_body` is how every entity moves, on the server and on clients.
|
||||
|
||||
@@ -52,7 +52,7 @@ A fluid's name, color and value can depend on its data. The mod's [shared script
|
||||
gives one of its fluids rules for that, like NeoForge's `FluidType.getDescription` and `FluidTintSource.colorAsStack`:
|
||||
|
||||
```ts
|
||||
import type { SharedContext } from "bworld/shared";
|
||||
import type { SharedContext } from "cubi/shared";
|
||||
|
||||
interface SyrupData {
|
||||
tree?: string;
|
||||
|
||||
@@ -177,7 +177,7 @@ Those become the `bworld:season`, `bworld:biome` and `bworld:time` conditions, w
|
||||
Server scripts roll tables, fill containers, and add conditions, functions and changes of their own:
|
||||
|
||||
```ts
|
||||
import type { ServerContext } from "bworld/server";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
|
||||
export function setup(ctx: ServerContext) {
|
||||
// "condition": "my_mod:night" in any table
|
||||
|
||||
@@ -166,7 +166,7 @@ recipes. What their fields mean is up to the mod, which registers the type from
|
||||
[shared script](../concepts/sides.md#shared-scripts), like NeoForge's `RecipeType` with its serializer:
|
||||
|
||||
```ts
|
||||
import type { ItemStack, SharedContext } from "bworld/shared";
|
||||
import type { ItemStack, SharedContext } from "cubi/shared";
|
||||
|
||||
interface SmithingRecipe {
|
||||
tool: string;
|
||||
@@ -228,7 +228,7 @@ A recipe that follows from other data, like one for every item with a component,
|
||||
adds one like a file in `recipes/` with that `type` would, with the rest of its fields from `json`:
|
||||
|
||||
```ts
|
||||
import type { SharedContext } from "bworld/shared";
|
||||
import type { SharedContext } from "cubi/shared";
|
||||
|
||||
export function setup(ctx: SharedContext) {
|
||||
// a sieve recipe for every item that says what it sifts into
|
||||
|
||||
@@ -115,4 +115,4 @@ ctx.components.register_block("my_mod:crop", {
|
||||
});
|
||||
```
|
||||
|
||||
`Season` is exported from `bworld/server`, `bworld/client` and `bworld/shared`.
|
||||
`Season` is exported from `cubi/server`, `cubi/client` and `cubi/shared`.
|
||||
|
||||
@@ -77,7 +77,7 @@ order they were registered. The base game's trees are in `vegetal_decoration`, s
|
||||
The worldgen script registers them:
|
||||
|
||||
```ts
|
||||
import type { WorldgenContext } from "bworld/worldgen";
|
||||
import type { WorldgenContext } from "cubi/worldgen";
|
||||
|
||||
export function setup(gen: WorldgenContext) {
|
||||
gen.register_feature("copper_tools:boulders", (chunk) => {
|
||||
|
||||
+13
-13
@@ -15,11 +15,11 @@ bworld's modding takes from three places:
|
||||
|
||||
A mod is built from up to three layers. Most mods only need the first one or two:
|
||||
|
||||
| Layer | Like | What a mod writes | Stability |
|
||||
| ----------------- | ---------------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------- |
|
||||
| **Data** | Bedrock behavior packs | JSON in `blocks/`, `items/`, `models/`, `recipes/`, ... | Versioned by `format_version` |
|
||||
| **Game API** | Minetest's Lua API, Bedrock's Script API | TypeScript against `bworld/server`, `bworld/client`, `bworld/worldgen` | Only breaks with the game's major version |
|
||||
| **Engine access** | NeoForge's mixins | `import { engine, hook } from "bworld/engine"` | None, tied to one game version |
|
||||
| Layer | Like | What a mod writes | Stability |
|
||||
| ----------------- | ---------------------------------------- | ---------------------------------------------------------------- | ----------------------------------------- |
|
||||
| **Data** | Bedrock behavior packs | JSON in `blocks/`, `items/`, `models/`, `recipes/`, ... | Versioned by `format_version` |
|
||||
| **Game API** | Minetest's Lua API, Bedrock's Script API | TypeScript against `cubi/server`, `cubi/client`, `cubi/worldgen` | Only breaks with the game's major version |
|
||||
| **Engine access** | NeoForge's mixins | `import { engine, hook } from "cubi/engine"` | None, tied to one game version |
|
||||
|
||||
## Status
|
||||
|
||||
@@ -43,15 +43,15 @@ The code is in `common/mod_loader.ts`, `common/mod_data.ts`, `common/mod_check.t
|
||||
|
||||
**Not built at all:** common scripts, the registry freeze and hash, overrides.
|
||||
|
||||
**Engine access** is built (phase 3): `bworld/engine`, `hook`, `engine_access` and its checks, and `physics` as the
|
||||
first plain object mods can hook. See [Engine Access](modding/misc/engine.md). The code is in `common/hooks.ts`,
|
||||
**Engine access** is built (phase 3): `cubi/engine`, `hook`, `engine_access` and its checks, and `physics` as the first
|
||||
plain object mods can hook. See [Engine Access](modding/misc/engine.md). The code is in `common/hooks.ts`,
|
||||
`common/mod_api/engine.ts` and the `engine_modules.ts` of each side.
|
||||
|
||||
**Known gaps:**
|
||||
|
||||
- Manifest `dependencies` version ranges aren't checked, and `game_version` only is for engine access mods.
|
||||
- Mods can't throw a `CommandError` the server recognizes: it's checked with `instanceof`, and the class isn't in the
|
||||
API, so a mod's bundled copy is a different class. Export it from `bworld/server`, or recognize it by `name`.
|
||||
API, so a mod's bundled copy is a different class. Export it from `cubi/server`, or recognize it by `name`.
|
||||
- Tools only lose durability when their owner dies. Nothing else uses it.
|
||||
- The GUI scale is always 3: screens work in GUI pixels like NeoForge's, but there's no option to change it yet.
|
||||
- Worn models haven't been looked at in the game yet, only tested: Artifacts' power glove and feral claws and the giant
|
||||
@@ -170,7 +170,7 @@ asks for it in its manifest:
|
||||
|
||||
```ts
|
||||
// server.ts: broken blocks drop twice
|
||||
import { engine, hook } from "bworld/engine";
|
||||
import { engine, hook } from "cubi/engine";
|
||||
|
||||
export function setup() {
|
||||
hook(engine.server.GameServer.prototype, "pop_item", {
|
||||
@@ -196,8 +196,8 @@ function hook<T, K extends keyof T>(target: T, method: K, handlers: {
|
||||
```
|
||||
|
||||
- `engine` holds the live modules on each side: `engine.common` everywhere, `engine.server` in server scripts,
|
||||
`engine.client` in client scripts. The engine puts them on the global object at startup, and `bworld/engine` in a
|
||||
mod's bundle is a shim that reads them, so a hook on a prototype changes every instance already made.
|
||||
`engine.client` in client scripts. The engine puts them on the global object at startup, and `cubi/engine` in a mod's
|
||||
bundle is a shim that reads them, so a hook on a prototype changes every instance already made.
|
||||
- Types are the engine's own source, so `check-mods` typechecks against exactly the engine the mod will run on.
|
||||
- Several mods can hook one method: `before` hooks run in priority order, `replace` hooks nest, `after` hooks chain
|
||||
results. A hook that throws is logged under its mod and skipped.
|
||||
@@ -210,7 +210,7 @@ function hook<T, K extends keyof T>(target: T, method: K, handlers: {
|
||||
- Hooks reach one JavaScript realm. Chunk workers run their own copy of the engine, so a client hook doesn't change
|
||||
meshing.
|
||||
- It isn't a stable API. A mod with `engine_access` must set `game_version` within one minor version, and loading it on
|
||||
another is a load error. Without `engine_access`, importing `bworld/engine` is an error.
|
||||
another is a load error. Without `engine_access`, importing `cubi/engine` is an error.
|
||||
- A server mod with engine access controls the game worker completely, but the worker still has no Deno permissions. The
|
||||
confirm screen for other sites lists which mods use it.
|
||||
- Prefer the Game API. Many mods hooking the same thing is a sign it should become part of the Game API.
|
||||
@@ -340,7 +340,7 @@ server and a client end up with equal registries and hashes.
|
||||
`check-mods` rules. Check: a test mod adds a component to `bworld:grass_block`, changes `bworld:glass`'s toughness and
|
||||
replaces the chest recipe, on both sides and in the hash.
|
||||
|
||||
**Phase 3: engine access.** The global engine modules and the `bworld/engine` shim, `hook`, `engine_access` in the
|
||||
**Phase 3: engine access.** The global engine modules and the `cubi/engine` shim, `hook`, `engine_access` in the
|
||||
manifest and its checks, and making the engine hookable where mods will want it. Check: test mods hook a server, a
|
||||
client and a worldgen method, hooks on one method run in priority order, and a throwing hook is logged without breaking
|
||||
the game.
|
||||
|
||||
@@ -16,7 +16,7 @@ import type {
|
||||
MenuScreen,
|
||||
Visual,
|
||||
VisualBlock,
|
||||
} from "bworld/client";
|
||||
} from "cubi/client";
|
||||
import { MINIGAMES } from "./minigames/mod.ts";
|
||||
import { JUICER_CAPACITY, JUICER_PRESSES } from "./shared.ts";
|
||||
import { STONECUTTING, stonecutting_options, type StonecuttingRecipe } from "./stonecutting.ts";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// container the meal needs (a bowl), or straight out when it needs none. the cutting board, like its
|
||||
// CuttingBoardBlockEntity, holds a stack of anything and cuts it one at a time with the right tool
|
||||
|
||||
import type { BlockRef, Container, ItemStack, ServerContext } from "bworld/server";
|
||||
import type { BlockRef, Container, ItemStack, ServerContext } from "cubi/server";
|
||||
import { COOKING, type CookingRecipe, CUTTING, type CuttingRecipe, INGREDIENT_SLOTS } from "./cooking_recipes.ts";
|
||||
|
||||
// stove
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
// the kitchen's recipe types, registered by the shared script: what the cooking pot cooks, found by the items in its
|
||||
// ingredient slots, and what the cutting board cuts, found by the item on it. see cooking.ts
|
||||
import type { SharedContext } from "bworld/shared";
|
||||
import type { SharedContext } from "cubi/shared";
|
||||
|
||||
export const COOKING = "bworld:cooking";
|
||||
export const CUTTING = "bworld:cutting";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// a container of their own, and fall out when they die like the rest of what they carry. items with the
|
||||
// bworld:curio_modifiers component change the wearer's attributes, like curios' attribute modifiers, and ones with
|
||||
// bworld:curio_unhurt_effect give them an effect once they've gone a while without being hurt
|
||||
import type { AttributeModifier, Container, ItemStack, Player, ServerContext, TagApi } from "bworld/server";
|
||||
import type { AttributeModifier, Container, ItemStack, Player, ServerContext, TagApi } from "cubi/server";
|
||||
|
||||
// where the left column of slots goes, from the inventory screen's left edge. the panel around them ends just left of it
|
||||
const COLUMNS_X = -45;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
// what the base game's effects do over time, see mods/bworld/effects. speed and slowness are only attribute
|
||||
// modifiers, and resistance and water breathing work where damage and air happen, like minecraft's
|
||||
import type { ServerContext } from "bworld/server";
|
||||
import type { ServerContext } from "cubi/server";
|
||||
|
||||
// every n ticks, n halving with each level: minecraft's regeneration and poison
|
||||
function every(ticks: number, amplifier: number, n: number) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// fermentable recipes: a fluid that ferments into another over a number of ticks, like juice into wine in the keg. the
|
||||
// shared script registers one for every juice, and mods can add more like any recipe, as files or from their shared
|
||||
// scripts. they're found by the fluid that ferments
|
||||
import type { FluidStack, FluidVariant, SharedContext } from "bworld/shared";
|
||||
import type { FluidStack, FluidVariant, SharedContext } from "cubi/shared";
|
||||
import type { JuiceableParams } from "./shared.ts";
|
||||
|
||||
export const FERMENTABLE = "bworld:fermentable";
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
// fishing, like minecraft's: right click with a rod to throw its hook forward. when it lands in a block with
|
||||
// bworld:fishable, like water, it floats there until something bites, and right clicking again before it gets away
|
||||
// reels it in. a hook that lands on anything else lies there until it's reeled in, with nothing on it
|
||||
import type { EntityRef, ItemStack, Player, Season, ServerContext } from "bworld/server";
|
||||
import type { Position } from "bworld/shared";
|
||||
import type { EntityRef, ItemStack, Player, Season, ServerContext } from "cubi/server";
|
||||
import type { Position } from "cubi/shared";
|
||||
import { MINIGAMES } from "./minigames/mod.ts";
|
||||
|
||||
const FISHING_ROD = "bworld:fishing_rod";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// bworld:juiceable, its own juice, and mods can add more like any recipe, as files or from their shared scripts.
|
||||
// whatever makes juice finds them by the item, like the juicer. with create installed, each is also a create:compacting
|
||||
// recipe, so its press can make juice in a basin
|
||||
import type { FluidStack, SharedContext } from "bworld/shared";
|
||||
import type { FluidStack, SharedContext } from "cubi/shared";
|
||||
import type { JuiceableParams } from "./shared.ts";
|
||||
|
||||
export const JUICING = "bworld:juicing";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
// a lichess mate in one: the board after the opponent's move, and the player has SOLVE_TIME to play the mate. it's
|
||||
// all played on the screen, which says how it went: button 1 for the mate, 0 for any other move
|
||||
import type { Color, Graphics } from "bworld/client";
|
||||
import type { Color, Graphics } from "cubi/client";
|
||||
import { FishingMinigame, type MinigameArgs, type MinigameScreen, SOLVE_TIME, time_bar } from "./minigame.ts";
|
||||
|
||||
export class ChessMinigame extends FishingMinigame {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// what every fishing minigame shares. each minigame is a file here with both its halves: a class the server builds
|
||||
// the minigame's menu with, and the screen client.ts draws it with. mod.ts lists them by name
|
||||
import type { ItemStack, MenuBuilder, Player } from "bworld/server";
|
||||
import type { ClientMenu, Graphics, MenuScreen } from "bworld/client";
|
||||
import type { ItemStack, MenuBuilder, Player } from "cubi/server";
|
||||
import type { ClientMenu, Graphics, MenuScreen } from "cubi/client";
|
||||
|
||||
// how long the puzzle minigames give the player, the maze and chess, whatever the difficulty
|
||||
export const SOLVE_TIME = 8 * 20;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type { Color, Graphics } from "bworld/client";
|
||||
import type { Color, Graphics } from "cubi/client";
|
||||
import { FishingMinigame, type MinigameArgs, type MinigameScreen } from "./minigame.ts";
|
||||
|
||||
// gray rings, and a thin green one growing out from the middle, faster the harder the fish is: like hold's bar
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// the base game's block and item behavior, written against the same api as any other mod
|
||||
import type { BlockRef, Container, FluidHandler, FluidStack, Player, Season, ServerContext } from "bworld/server";
|
||||
import type { BlockRef, Container, FluidHandler, FluidStack, Player, Season, ServerContext } from "cubi/server";
|
||||
import { register_curios } from "./curios.ts";
|
||||
import { register_effects } from "./effects.ts";
|
||||
import { register_fishing } from "./fishing.ts";
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user