import { system } from "@minecraft/server";
import ItemModule from "./config/items";
import AmbienceModule from "./config/ambience";
import FormModule from './modules/formModule';
import DynamicEffectModule from './config/dynamicEffect';
import PlayerJoinModule from './modules/playerJoinModule';
import WorldEventModule from './config/worldEvents';
const modules = [
    new ItemModule(),
    new AmbienceModule(),
    new WorldEventModule(),
    new FormModule(),
    new DynamicEffectModule(),
    new PlayerJoinModule(),
];
let currentTick = 0;
function setupModuleTickIntervals() {
    system.runInterval(() => {
        modules.forEach((module) => {
            module.tickIntervals.forEach((callback, tickInterval) => {
                if (currentTick % tickInterval === 0) {
                    try {
                        callback.call(module);
                    }
                    catch (error) {
                        console.error(`[${module.constructor.name}] Error:`);
                        throw error;
                    }
                }
            });
        });
        currentTick++;
    }, 1); // Run this every tick
}
modules.forEach((module) => {
    module.initialize();
});
setupModuleTickIntervals();
