You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
492 B
JavaScript

// core/events.js; central place/break dispatch.
import { world } from "./mc.js";
const placeHandlers = [];
const breakHandlers = [];
export function onPlace(fn) { placeHandlers.push(fn); }
export function onBreak(fn) { breakHandlers.push(fn); }
world.afterEvents.playerPlaceBlock?.subscribe((ev) => { for (const fn of placeHandlers) { try { fn(ev); } catch {} } });
world.afterEvents.playerBreakBlock?.subscribe((ev) => { for (const fn of breakHandlers) { try { fn(ev); } catch {} } });