New hooks

This commit is contained in:
2026-10-20 13:22:03 -03:00
parent c7a2392591
commit 0af35d1e17
7 changed files with 253 additions and 19 deletions
+7
View File
@@ -71,6 +71,13 @@ export interface BlockComponent<P = any> {
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
on_new_day?(block: BlockRef, params: P, day: number): void;
// a block on one of its 6 sides was placed, broken or changed its states, like neoforge's neighborChanged. after
// the shared rules' on_neighbor_change, so it sees what they changed, and can do what rules can't: read tile data,
// change other blocks. neighbor is where, and what's there now
on_neighbor_change?(block: BlockRef, params: P, neighbor: { readonly id: Id } & Position): void;
// its own states changed without it being replaced, by set_state or a rule, like a clutch another mod powers.
// before is what they were. it runs right away, before the blocks beside it hear of the change
on_state_change?(block: BlockRef, params: P, before: Readonly<Record<string, number>>): void;
// placing and neighbor rules are in shared scripts, see BlockRules in bworld/shared
}