Trapdoors

This commit is contained in:
2026-10-03 17:52:58 -03:00
parent 91655c28c5
commit 63e6248f9f
35 changed files with 927 additions and 23 deletions
+13
View File
@@ -52,6 +52,9 @@ export interface BlockComponent<P = any> {
// a block next to it (on any of the 6 sides) was placed, broken or changed its states, like minecraft's
// updateShape. neighbor is where, and what's there now
on_neighbor_change?(block: BlockRef, params: P, neighbor: Position & { readonly id: Id }): void;
// the states it's placed with when a player places it, like minecraft's getStateForPlacement. states it doesn't
// return keep their defaults, and a 2 bit "facing" faces the player
state_for_placement?(placement: BlockPlacement, params: P): Record<string, number> | void;
}
// deno-lint-ignore no-explicit-any
@@ -141,9 +144,19 @@ export interface BlockPlaceEvent {
readonly player: Player;
readonly block: { readonly id: Id } & Position;
readonly face: Face;
// where on the clicked block the player clicked, 0 to 1 on each axis
readonly hit: readonly [number, number, number];
readonly item: ItemStack | undefined;
}
// a player placing a block at x y z by clicking face of the block next to it, at hit (0 to 1 on each axis of that
// block), like minecraft's BlockPlaceContext
export interface BlockPlacement extends Position {
readonly player: Player;
readonly face: Face;
readonly hit: readonly [number, number, number];
}
export interface BlockInteractEvent {
readonly player: Player;
readonly block: BlockRef;