From 4683b09e104cb2a308483ec5e0404f65e07a8e99 Mon Sep 17 00:00:00 2001 From: Paula Date: Wed, 4 Nov 2026 21:54:01 -0300 Subject: [PATCH] Change the asset keys --- client/gui/credits_screen.ts | 2 +- client/gui/gui_player_inventory.ts | 2 +- client/gui/gui_screen.ts | 2 +- client/gui/gui_sprites.ts | 2 +- client/gui/mod_graphics.ts | 2 +- client/gui/tooltip.ts | 2 +- client/level/client_level.ts | 4 ++-- client/main.ts | 14 +++++++------- client/renderer/text.ts | 4 ++-- client/rendering/entity_renderer.ts | 2 +- client/rendering/gui_player.ts | 2 +- client/rendering/hand_renderer.ts | 6 +++--- client/rendering/item_renderer.ts | 4 ++-- client/rendering/level_renderer.ts | 4 ++-- client/rendering/render_utils.ts | 8 ++++---- client/rendering/worn_renderer.ts | 4 ++-- client/sprites.ts | 2 +- tests/gui_player_test.ts | 4 ++-- tests/juice_test.ts | 2 +- tests/visuals_test.ts | 6 +++--- 20 files changed, 39 insertions(+), 39 deletions(-) diff --git a/client/gui/credits_screen.ts b/client/gui/credits_screen.ts index 119b0ae..0cd055c 100644 --- a/client/gui/credits_screen.ts +++ b/client/gui/credits_screen.ts @@ -73,7 +73,7 @@ export class CreditsScreen extends GuiScreen { } #sections() { - const sections = [{ heading: "bworld", text: AssetManager.instance.get("bworld:assets_text") ?? "" }]; + const sections = [{ heading: "bworld", text: AssetManager.instance.get("cubi:assets_text") ?? "" }]; for (const mod of mod_credits) { sections.push({ heading: `${mod.name} ${mod.version}`, text: mod.text }); } diff --git a/client/gui/gui_player_inventory.ts b/client/gui/gui_player_inventory.ts index 389f5d5..598875d 100644 --- a/client/gui/gui_player_inventory.ts +++ b/client/gui/gui_player_inventory.ts @@ -64,7 +64,7 @@ export class GuiPlayerInventory extends GuiMenuScreen { #render_player(g: ModGraphics) { const { x, y, size } = PLAYER_BOX; g.rect(x, y, size, size, PLAYER_BOX_COLOR); - const skin = this.#player.skin ?? AssetManager.instance.get("bworld:skin"); + const skin = this.#player.skin ?? AssetManager.instance.get("cubi:skin"); const mouse = InputManager.get_mouse_position(); draw_gui_player( skin, diff --git a/client/gui/gui_screen.ts b/client/gui/gui_screen.ts index 43fa61e..8f4c6ca 100644 --- a/client/gui/gui_screen.ts +++ b/client/gui/gui_screen.ts @@ -167,7 +167,7 @@ export abstract class GuiMenuScreen extends GuiScreen { } else if (slot.icon) { // where an item's sprite would be const icon = get_sprite_region(slot.icon); - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); const [x, y, size] = [this.#slot_x(slot) + 3, this.#slot_y(slot) + 3, SLOT_SIZE - 6]; draw_texture_region(atlas, icon.x, icon.y, icon.width, icon.height, x, y, size, size); } diff --git a/client/gui/gui_sprites.ts b/client/gui/gui_sprites.ts index 2e3e61d..c8af091 100644 --- a/client/gui/gui_sprites.ts +++ b/client/gui/gui_sprites.ts @@ -19,7 +19,7 @@ export function draw_gui_sprite( height?: number, color = [1, 1, 1, 1], ) { - const texture = AssetManager.instance.get("bworld:gui"); + const texture = AssetManager.instance.get("cubi:gui"); const sprite = GUI_ATLAS[name]; const [left, top, right, bottom] = sprite.border; draw_nine_slice( diff --git a/client/gui/mod_graphics.ts b/client/gui/mod_graphics.ts index cacd61f..da96d73 100644 --- a/client/gui/mod_graphics.ts +++ b/client/gui/mod_graphics.ts @@ -121,7 +121,7 @@ export class ModGraphics implements Graphics { } texture(id: string, x: number, y: number, w: number, h: number, part = [0, 0, 1, 1]) { - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); const region = get_sprite_region(id); const [u, v, pw, ph] = part; draw_texture_region( diff --git a/client/gui/tooltip.ts b/client/gui/tooltip.ts index 3eeb4ba..e0a80fb 100644 --- a/client/gui/tooltip.ts +++ b/client/gui/tooltip.ts @@ -92,7 +92,7 @@ export function draw_tooltip(lines: TooltipLine[], mouse_x: number, mouse_y: num y = Math.max(0, y); draw_gui_sprite("tooltip", x, y, width, height); - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); lines.forEach((line, i) => { const line_y = y + PADDING + i * (line_height + LINE_GAP); if (line.icon) { diff --git a/client/level/client_level.ts b/client/level/client_level.ts index 76776f8..d0870bb 100644 --- a/client/level/client_level.ts +++ b/client/level/client_level.ts @@ -118,7 +118,7 @@ export const FULL_SKY_LIGHT = 15; // what minecraft calls the ClientLevel: this client's copy of the world, its chunks and the entities in it. the // chunks are what the server sent, see common/chunk_streaming.ts export class ClientLevel { - image: Texture = AssetManager.instance.get("bworld:textures"); + image: Texture = AssetManager.instance.get("cubi:textures"); chunks = new Map(); // the chunks request_meshes and update_translucent_sorting look at, so they don't go through every chunk each frame #dirty = new Set(); @@ -170,7 +170,7 @@ export class ClientLevel { type: "init", blocks_registry: strip_functions(EverythingRegistry.get_registry("blocks")), models: Object.fromEntries(EverythingRegistry.entries("models")), - textures_info: AssetManager.instance.get("bworld:textures_info"), + textures_info: AssetManager.instance.get("cubi:textures_info"), image: { width: this.image.width, height: this.image.height }, visuals: [...block_visuals].map(([nid, visual]) => [nid, visual.replaces_model]), }); diff --git a/client/main.ts b/client/main.ts index 68b297e..3a68955 100644 --- a/client/main.ts +++ b/client/main.ts @@ -192,8 +192,8 @@ async function join_server(address: ServerAddress, name: string, status: (text: loaded_mods = true; const atlas_texture = load_texture(atlas.image); set_texture_animations(atlas_texture.tex, device.queue, atlas.animated); - AssetManager.instance.assets["bworld:textures"] = atlas_texture; - AssetManager.instance.assets["bworld:textures_info"] = atlas.regions; + AssetManager.instance.assets["cubi:textures"] = atlas_texture; + AssetManager.instance.assets["cubi:textures_info"] = atlas.regions; await load_client_mods(welcome.mods, bmods); console.log(`Mods: ${welcome.mods.map((mod) => `${mod.id} ${mod.version}`).join(", ") || "none"}`); @@ -234,13 +234,13 @@ self.addEventListener("resize", resize_canvas); resize_canvas(); canvas.addEventListener("contextmenu", (event) => event.preventDefault()); -AssetManager.instance.load("bworld:assets_text", "/assets/ASSETS.md"); +AssetManager.instance.load("cubi:assets_text", "/assets/ASSETS.md"); -AssetManager.instance.load("bworld:skin", "/assets/sprites/skin_template.png"); -AssetManager.instance.load("bworld:gui", "/assets/sprites/gui.png"); +AssetManager.instance.load("cubi:skin", "/assets/sprites/skin_template.png"); +AssetManager.instance.load("cubi:gui", "/assets/sprites/gui.png"); -AssetManager.instance.load("bworld:m6x11", "/assets/fonts/m6x11.png"); -AssetManager.instance.load("bworld:m6x11_fnt", "/assets/fonts/m6x11.fnt"); +AssetManager.instance.load("cubi:m6x11", "/assets/fonts/m6x11.png"); +AssetManager.instance.load("cubi:m6x11_fnt", "/assets/fonts/m6x11.fnt"); await AssetManager.instance.load_all(); diff --git a/client/renderer/text.ts b/client/renderer/text.ts index 633323f..1bd3084 100644 --- a/client/renderer/text.ts +++ b/client/renderer/text.ts @@ -10,9 +10,9 @@ let font_texture: Texture; let font_fnt: FntFont; export function init_font() { - font_texture = AssetManager.instance.get("bworld:m6x11"); + font_texture = AssetManager.instance.get("cubi:m6x11"); - font_fnt = parse_fnt(AssetManager.instance.get("bworld:m6x11_fnt")); + font_fnt = parse_fnt(AssetManager.instance.get("cubi:m6x11_fnt")); } // bmfont's text format. glyphs in the image have transparent padding around them, which their offsets don't count, so diff --git a/client/rendering/entity_renderer.ts b/client/rendering/entity_renderer.ts index b3ff207..26ea369 100644 --- a/client/rendering/entity_renderer.ts +++ b/client/rendering/entity_renderer.ts @@ -25,7 +25,7 @@ const PIXEL = 1 / 16; export function render_mod_entity(entity: RemoteEntity, camera: Camera, partial_tick: number) { const json = EverythingRegistry.get("entities", entity.type); if (!json) return; - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); const region = get_sprite_region(json.texture); const hurt = entity.hurt_time > 0 || entity.dead ? HURT_TINT : undefined; const tint = entity_tint(entity, partial_tick, hurt, entity.data.on_fire === true); diff --git a/client/rendering/gui_player.ts b/client/rendering/gui_player.ts index 33c616d..5196a8e 100644 --- a/client/rendering/gui_player.ts +++ b/client/rendering/gui_player.ts @@ -70,7 +70,7 @@ export function gui_player_faces(skin: Texture, slim: boolean, dx: number, dy: n push_cube(skin, part, part.overlay, part.inflate, transform, undefined, emit_skin); } if (worn.length > 0) { - push_worn(worn, pose, undefined, collect(AssetManager.instance.get("bworld:textures"))); + push_worn(worn, pose, undefined, collect(AssetManager.instance.get("cubi:textures"))); } return faces diff --git a/client/rendering/hand_renderer.ts b/client/rendering/hand_renderer.ts index 10dcf24..d4c8c5a 100644 --- a/client/rendering/hand_renderer.ts +++ b/client/rendering/hand_renderer.ts @@ -64,7 +64,7 @@ export class HandRenderer { const tint = entity_tint(player, partial_tick); begin_view_model(FOV); if (item) { - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); set_current_texture(atlas.tex); const display = item_model_of(item)?.display.firstperson_righthand; const transform = display @@ -72,7 +72,7 @@ export class HandRenderer { : pose(item, (1 - equip) * 0.6, Math.sin(swing_progress * Math.PI)); push_item(atlas, item, transform, tint); } else { - const skin = player.skin ?? AssetManager.instance.get("bworld:skin"); + const skin = player.skin ?? AssetManager.instance.get("cubi:skin"); const arm = right_arm(player.slim); const transform = arm_pose(arm.pivot, 1 - equip, swing_progress); set_current_texture(skin.tex); @@ -80,7 +80,7 @@ export class HandRenderer { push_cube(skin, arm, arm.overlay, arm.inflate, transform, tint); // what's worn on it goes over it, from the atlas if (player.worn.length > 0) { - use_texture(AssetManager.instance.get("bworld:textures").tex); + use_texture(AssetManager.instance.get("cubi:textures").tex); render_worn_arm(player, transform, tint); } } diff --git a/client/rendering/item_renderer.ts b/client/rendering/item_renderer.ts index 97675e2..07ac83c 100644 --- a/client/rendering/item_renderer.ts +++ b/client/rendering/item_renderer.ts @@ -92,7 +92,7 @@ export function ground_transform(item: ItemStack): ItemTransform { // the atlas has to be the current texture export function render_item_entity(entity: ItemEntity, partial_tick: number) { - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); // spinning and bobbing, like minecraft's ItemEntityRenderer const time = entity.age + partial_tick; @@ -130,7 +130,7 @@ const shown_stacks = new WeakMap(); // every item blocks with item_display show on top of them, their "item" client data, see BlockRegistry.item_display. // the atlas has to be the current texture export function render_block_items(level: ClientLevel) { - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); const blocks = EverythingRegistry.get_registry("blocks"); for (const in_chunk of level.block_data.values()) { for (const { x, y, z, data } of in_chunk.values()) { diff --git a/client/rendering/level_renderer.ts b/client/rendering/level_renderer.ts index c6e58c9..2a79d36 100644 --- a/client/rendering/level_renderer.ts +++ b/client/rendering/level_renderer.ts @@ -128,7 +128,7 @@ export class LevelRenderer { this.#drawn_entities = 0; if (!this.draw.entities) return; flush_batch(); - const default_skin = AssetManager.instance.get("bworld:skin"); + const default_skin = AssetManager.instance.get("cubi:skin"); // what they wear is drawn with the atlas, after every skin const posed: { player: RemotePlayer; pose: PlayerPose; tint: Vec3 }[] = []; for (const entity of level.entities.values()) { @@ -203,7 +203,7 @@ export class LevelRenderer { if (!info) { return; } - const tex = AssetManager.instance.get("bworld:textures"); + const tex = AssetManager.instance.get("cubi:textures"); const region = get_sprite_region(`cubi:break_${stage}`); for (const quad of this.#destroy_quads(info, value)) { push_decal_quad(tex, quad, x, y, z, region); diff --git a/client/rendering/render_utils.ts b/client/rendering/render_utils.ts index a1506a6..cca02f0 100644 --- a/client/rendering/render_utils.ts +++ b/client/rendering/render_utils.ts @@ -142,7 +142,7 @@ function draw_item_item(item: ItemStack, item_info: ItemRegistry, x: number, y: const draw = (texture_id: string, [r, g, b] = [1, 1, 1]) => { const sprite_region = get_sprite_region(texture_id); draw_texture_region( - AssetManager.instance.get("bworld:textures"), + AssetManager.instance.get("cubi:textures"), sprite_region.x, sprite_region.y, sprite_region.width, @@ -172,7 +172,7 @@ export function draw_fluid(fluid: FluidVariant, x: number, y: number, filled = 1 const region = get_sprite_region(texture); const size = SLOT_SIZE - 6; draw_texture_region( - AssetManager.instance.get("bworld:textures"), + AssetManager.instance.get("cubi:textures"), region.x, region.y + region.height * (1 - done), region.width, @@ -212,7 +212,7 @@ const model_icons = new WeakMap(); // an item's model in a slot: its faces that face the viewer, back to front function draw_item_model(model: ItemModel, x: number, y: number) { - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); use_texture(atlas.tex); let icon = model_icons.get(model); if (!icon) { @@ -277,7 +277,7 @@ function draw_item_block(block_info: BlockRegistry, x: number, y: number) { const front_texture = cube_face_texture(block_info, "front"); const left_texture = cube_face_texture(block_info, "side"); - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); const top = get_sprite_region(top_texture); const front = get_sprite_region(front_texture); diff --git a/client/rendering/worn_renderer.ts b/client/rendering/worn_renderer.ts index 9f6533c..1e8ebad 100644 --- a/client/rendering/worn_renderer.ts +++ b/client/rendering/worn_renderer.ts @@ -24,7 +24,7 @@ export function render_worn(player: Player, pose: PlayerPose, tint?: Vec3) { // what's worn on a player in that pose, its vertices to emit, the batch by default, like the player in the inventory export function push_worn(worn_items: ItemStack[], pose: PlayerPose, tint?: Vec3, emit?: VertexSink) { if (worn_items.length === 0) return; - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); const to_world = pose_to_world(pose); for (const stack of worn_items) { const worn = EverythingRegistry.get("items", stack.type_id)?.worn; @@ -48,7 +48,7 @@ export function push_worn(worn_items: ItemStack[], pose: PlayerPose, tint?: Vec3 // what's worn on a player's right arm, in first person, like artifacts' renderFirstPersonArm. transform is the arm's, // from points around its pivot (see hand_renderer's arm_pose). the atlas has to be the current texture export function render_worn_arm(player: Player, transform: (x: number, y: number, z: number) => Vec3, tint?: Vec3) { - const atlas = AssetManager.instance.get("bworld:textures"); + const atlas = AssetManager.instance.get("cubi:textures"); const [px, py, pz] = right_arm(player.slim).pivot; // the model's pixels, standing still, to around the arm's pivot const to_arm = (x: number, y: number, z: number) => transform(x - px, y - py, z - pz); diff --git a/client/sprites.ts b/client/sprites.ts index 53fce3a..f7cf80f 100644 --- a/client/sprites.ts +++ b/client/sprites.ts @@ -7,7 +7,7 @@ import { AssetManager } from "./assets.ts"; type TexturesInfo = Record; export function get_sprite_region(id: string): SpriteRegion { - const textures_info = AssetManager.instance.get("bworld:textures_info"); + const textures_info = AssetManager.instance.get("cubi:textures_info"); return textures_info?.[id] ?? textures_info?.["cubi:missing"] ?? { x: 0, y: 0, width: TEXTURE_SIZE, height: TEXTURE_SIZE }; } diff --git a/tests/gui_player_test.ts b/tests/gui_player_test.ts index 6928d6e..038fc71 100644 --- a/tests/gui_player_test.ts +++ b/tests/gui_player_test.ts @@ -49,9 +49,9 @@ Deno.test("what the player wears is drawn on them too, with the atlas, in among await test_game("mods"); const skin = { width: 64, height: 64, tex: "skin" } as unknown as Texture; const atlas = { width: 256, height: 256, tex: "atlas" } as unknown as Texture; - AssetManager.instance.assets["bworld:textures"] = atlas as never; + AssetManager.instance.assets["cubi:textures"] = atlas as never; // where each texture is in the atlas, none known: the renderer falls back to a spot of its own - AssetManager.instance.assets["bworld:textures_info"] = {} as never; + AssetManager.instance.assets["cubi:textures_info"] = {} as never; const plain = gui_player_faces(skin, false, 0, 0); const gloved = gui_player_faces(skin, false, 0, 0, [new ItemStack("artifacts:power_glove", 1)]); assert(plain.every((face) => face.texture === skin)); diff --git a/tests/juice_test.ts b/tests/juice_test.ts index 8697143..ea44ad8 100644 --- a/tests/juice_test.ts +++ b/tests/juice_test.ts @@ -281,7 +281,7 @@ Deno.test("a broken bworld:fermentable recipe stops the server from starting", a // server's rules, the same as a client's async function drawn_juicer() { const { game } = await setup(); - AssetManager.instance.assets["bworld:textures_info"] = {}; + AssetManager.instance.assets["cubi:textures_info"] = {}; const client_rules = fluid_rules; set_fluid_rules(game.mods.fluid_rules); // bworld's client script, with only what it needs for its visuals diff --git a/tests/visuals_test.ts b/tests/visuals_test.ts index 1ac8d6a..4f5432e 100644 --- a/tests/visuals_test.ts +++ b/tests/visuals_test.ts @@ -74,7 +74,7 @@ async function registries() { write_testmod(dir); await test_game(dir); Deno.removeSync(dir, { recursive: true }); - AssetManager.instance.assets["bworld:textures_info"] = {}; + AssetManager.instance.assets["cubi:textures_info"] = {}; const nid = (id: string) => EverythingRegistry.get_id("blocks", id)!; const value = (id: string, state = 0) => block_value(nid(id), state); return { nid, value }; @@ -336,7 +336,7 @@ Deno.test("an item is drawn the size it is on the ground, with one model for eve Deno.test("a fluid's box is its texture cut to fit and tinted in its color, a model of its own that goes with it", async () => { const { nid, value } = await registries(); - AssetManager.instance.assets["bworld:textures_info"] = { + AssetManager.instance.assets["cubi:textures_info"] = { "testmod:syrup_still": { x: 32, y: 0, width: 16, height: 16 }, }; let box: FluidInstance | undefined; @@ -434,7 +434,7 @@ Deno.test({ shade: true, }; // the atlas is just its texture - AssetManager.instance.assets["bworld:textures_info"] = { + AssetManager.instance.assets["cubi:textures_info"] = { "testmod:shaft": { x: 0, y: 0, width: 16, height: 16 }, }; const quads = instance_quads([quad], () => [1, 1, 1]);