Crafting and chest

This commit is contained in:
2026-03-10 19:53:15 -03:00
parent 9e2b2bcb42
commit e9da307841
11 changed files with 234 additions and 21 deletions
+24
View File
@@ -0,0 +1,24 @@
import { EverythingRegistry, TileRegistry } from "$/common/everything_registry.ts";
import { Container, Inventory } from "../inventory.ts";
import { PlayerComponent } from "../player.ts";
import { GuiChest } from "$/client/gui/gui_chest.ts";
interface TileChestData {
inventory: Inventory;
}
EverythingRegistry.register<TileRegistry<TileChestData>>("tiles", "bworld:chest", {
texture_id: "bworld:chest",
has_collision: false,
on_interact(world, tile) {
const [player] = 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));
}
},
on_create(_, tile) {
tile.data = { inventory: new Inventory(new Container(9 * 3)) };
},
});