import { World } from './world'; import { addBridge } from 'scriptcraft-core'; /** * Tick Event */ export class TickEvent { /** * Instance */ static INSTANCE: TickEvent = new TickEvent(); /** * @internal */ #listeners: ((world: World) => void)[]; /** * Add Event Listener * @param listener Event Listener */ addListener(listener: (world: World) => void): void { this.#listeners.push(listener); } /** * @internal */ run(world: World): void { for (const listener of this.#listeners) { listener(world); } } } addBridge('Event.tick', (world: JavaObject) => TickEvent.INSTANCE.run(new World(world)));