Scheduled ticks !!

This commit is contained in:
2026-10-20 13:50:35 -03:00
parent 77cd327f94
commit 1c2dcd0dbc
7 changed files with 444 additions and 1 deletions
+8
View File
@@ -78,6 +78,8 @@ export interface BlockComponent<P = any> {
// 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;
// the tick ServerWorld.schedule_tick asked for came, like neoforge's tick from scheduleTick
on_scheduled_tick?(block: BlockRef, params: P): void;
// placing and neighbor rules are in shared scripts, see BlockRules in bworld/shared
}
@@ -255,6 +257,12 @@ export interface ServerWorld {
// like neoforge's neighborChanged. for a block whose effect on others changed without it changing, or for blocks
// it reaches that aren't beside it. it hears once the change going on is done, like the blocks beside one do
neighbor_changed(x: number, y: number, z: number, from: Position): void;
// runs the block's components' on_scheduled_tick in delay ticks (at least 1), if the same kind of block is still
// there, like neoforge's scheduleTick. one per block: scheduling while one waits does nothing. of those due on the
// same tick, lower priority (-8 to 7, 0 when not given) runs first, then the order they were scheduled in. saved
// with the world. they only run within 6 chunks of a player, the rest wait until one comes near
schedule_tick(x: number, y: number, z: number, delay: number, priority?: number): void;
has_scheduled_tick(x: number, y: number, z: number): boolean;
// whether the block's side is a full square things can attach to, like minecraft's isFaceSturdy: its collision
// shape covers the whole face. false for air, plants, water and the sides of a slab
is_face_sturdy(x: number, y: number, z: number, face: Face): boolean;