This commit is contained in:
2026-10-22 19:55:59 -03:00
parent 1b30d71a47
commit 4cd29a17b3
37 changed files with 427 additions and 155 deletions
+19 -1
View File
@@ -67,6 +67,9 @@ export interface BlockComponent<P = any> {
on_click?(block: BlockRef, params: P, player: Player): void;
// return true if it did something, so no block gets placed
on_interact?(block: BlockRef, params: P, player: Player): boolean;
// the player turned the mouse wheel while looking at it, for a block whose json has "scrollable": true, like a
// setting turned up and down. the wheel doesn't change their hotbar slot then
on_scroll?(block: BlockRef, params: P, player: Player, scroll: BlockScroll): void;
on_tick?(block: BlockRef, params: P, dt: number): void;
on_second?(block: BlockRef, params: P, dt: number): void;
// every morning at 06:00, for every block with data in the world, near a player or not. day is ServerWorld.day
@@ -318,6 +321,21 @@ export interface ServerWorld {
set_time(time: number): void;
}
// the mouse wheel turned at a block, see BlockComponent.on_scroll
export interface BlockScroll {
// how many notches, more than 0 turned up and less than 0 down
readonly amount: number;
readonly face: Face;
// where on the block they look, 0 to 1 on each axis, like BlockInteraction's
readonly hit: readonly [number, number, number];
}
export interface MessageOptions {
// shows it above their hotbar for a moment instead of in chat, like neoforge's overlay messages. for something
// that changes as they do it, like a setting they're scrolling through
overlay?: boolean;
}
export interface SetStateOptions {
// true when not given
update_neighbors?: boolean;
@@ -389,7 +407,7 @@ export interface Player {
readonly held_item: ItemStack | undefined;
// what doesn't fit in the inventory drops at their feet
give_item(id: Id, count?: number, data?: unknown): void;
send_message(text: string): void;
send_message(text: string, options?: MessageOptions): void;
// items drawn on them, under a key so each mod keeps its own list, like "bworld:curios". replaces what that key
// had, [] clears it. only items whose json has worn show. not saved: set it again when they join
set_worn(key: string, items: ItemStack[]): void;