Chest (no texture
This commit is contained in:
+25
-9
@@ -1,4 +1,5 @@
|
|||||||
import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
|
import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts";
|
||||||
|
import { register_block_item } from "$/common/utils.ts";
|
||||||
import { Container, Inventory } from "../inventory.ts";
|
import { Container, Inventory } from "../inventory.ts";
|
||||||
import { PlayerComponent } from "../player.ts";
|
import { PlayerComponent } from "../player.ts";
|
||||||
import { GuiChest } from "$/client/gui/gui_chest.ts";
|
import { GuiChest } from "$/client/gui/gui_chest.ts";
|
||||||
@@ -7,22 +8,37 @@ interface TileChestData {
|
|||||||
inventory: Inventory;
|
inventory: Inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
EverythingRegistry.register<BlockRegistry>("blocks", "bworld:chest", {
|
const block = EverythingRegistry.register<BlockRegistry>("blocks", "bworld:chest", {
|
||||||
id: "bworld:chest",
|
id: "bworld:chest",
|
||||||
textures: "bworld:chest",
|
textures: "bworld:planks",
|
||||||
toughness: 10,
|
toughness: 8,
|
||||||
requires_tool: false,
|
requires_tool: false,
|
||||||
tool_to_break: "axe",
|
tool_to_break: "axe",
|
||||||
|
drop_table: "bworld:chest",
|
||||||
|
|
||||||
has_collision: false,
|
has_collision: false,
|
||||||
/*on_interact(dimension, tile) {
|
on_interact(dimension, block) {
|
||||||
const [player] = dimension.world.get_tag("player")!;
|
const [player] = dimension.world.get_tag("player")!;
|
||||||
const player_component = player.get(PlayerComponent)!;
|
const player_component = player.get(PlayerComponent)!;
|
||||||
if (tile.data && tile.data.inventory) {
|
const block_data = dimension.get_block_data<TileChestData>(block.x, block.y, block.z);
|
||||||
player_component.screens.push(new GuiChest(tile.data.inventory, player_component.player_inventory));
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user