Scheduled ticks !!
This commit is contained in:
@@ -58,6 +58,7 @@ import {
|
||||
} from "$/common/commands.ts";
|
||||
import { AIR_ID } from "$/common/protocol.ts";
|
||||
import type { GameServer } from "./game_server.ts";
|
||||
import { MAX_PRIORITY, MIN_PRIORITY } from "./scheduled_ticks.ts";
|
||||
import type { ServerPlayer } from "./player.ts";
|
||||
import { Menu, type MenuSlot } from "./menu.ts";
|
||||
import { damage_source, type Entity } from "./entity/entity.ts";
|
||||
@@ -746,6 +747,16 @@ export class ModRuntime {
|
||||
},
|
||||
neighbor_changed: (x, y, z, from) =>
|
||||
this.rules.neighbor_changed(x, y, z, { x: from.x, y: from.y, z: from.z }),
|
||||
schedule_tick: (x, y, z, delay, priority = 0) => {
|
||||
if (!Number.isInteger(delay) || delay < 1) {
|
||||
throw new Error(`a tick is scheduled at least 1 tick ahead, in whole ticks, not ${delay}`);
|
||||
}
|
||||
if (!Number.isInteger(priority) || priority < MIN_PRIORITY || priority > MAX_PRIORITY) {
|
||||
throw new Error(`a tick's priority is ${MIN_PRIORITY} to ${MAX_PRIORITY}, not ${priority}`);
|
||||
}
|
||||
game().schedule_tick(x, y, z, delay, priority);
|
||||
},
|
||||
has_scheduled_tick: (x, y, z) => game().has_scheduled_tick(x, y, z),
|
||||
is_face_sturdy: (x, y, z, face) => covers_face(game().world.collision_shape(x, y, z), face),
|
||||
get_block_data: (x, y, z) => game().world.get_tile(x, y, z)?.mod_data as never,
|
||||
get_block_ref: (x, y, z) => {
|
||||
|
||||
Reference in New Issue
Block a user