From 510073f89b9afbbfdb2576ef7df0e012d18ebd5e Mon Sep 17 00:00:00 2001 From: paulaboks Date: Mon, 30 Mar 2026 14:54:48 -0300 Subject: [PATCH] Chest (no texture --- client/blocks/chest.ts | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/client/blocks/chest.ts b/client/blocks/chest.ts index 3871f3b..2964579 100644 --- a/client/blocks/chest.ts +++ b/client/blocks/chest.ts @@ -1,4 +1,5 @@ import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts"; +import { register_block_item } from "$/common/utils.ts"; import { Container, Inventory } from "../inventory.ts"; import { PlayerComponent } from "../player.ts"; import { GuiChest } from "$/client/gui/gui_chest.ts"; @@ -7,22 +8,37 @@ interface TileChestData { inventory: Inventory; } -EverythingRegistry.register("blocks", "bworld:chest", { +const block = EverythingRegistry.register("blocks", "bworld:chest", { id: "bworld:chest", - textures: "bworld:chest", - toughness: 10, + textures: "bworld:planks", + toughness: 8, requires_tool: false, tool_to_break: "axe", + drop_table: "bworld:chest", has_collision: false, - /*on_interact(dimension, tile) { + on_interact(dimension, block) { const [player] = dimension.world.get_tag("player")!; const player_component = player.get(PlayerComponent)!; - if (tile.data && tile.data.inventory) { - player_component.screens.push(new GuiChest(tile.data.inventory, player_component.player_inventory)); + const block_data = dimension.get_block_data(block.x, block.y, block.z); + if (block_data && block_data.data.inventory) { + const gui = new GuiChest(block_data.data.inventory, player_component.player_inventory); + player_component.screens.push(gui); + return true; } + return false; + }, + on_create(dimension, block) { + dimension.add_block_data({ + id: block.id, + x: block.x, + y: block.y, + z: block.z, + data: { + inventory: new Inventory(new Container(9 * 3)), + }, + }); }, - on_create(_, tile) { - tile.data = { inventory: new Inventory(new Container(9 * 3)) }; - },*/ }); + +register_block_item(block);