import * as mc from "@minecraft/server";
import * as utils from "./utils/index";
import { InitializeCraftee } from "./setup_craftee";
import { initializeHat } from "./hats/index";
const START = mc.system.currentTick;
/**
 * @remarks This is the entry point for the codebase
 */
async function main() {
    utils.GlobalNamespace.Namespace = 'ldz_crcomp';
    await utils.waitForWorldLoad();
    utils.mclog("Loading (Craftee Companion)");
    mc.system.afterEvents.scriptEventReceive.subscribe(addDebugTags);
    InitializeCraftee();
    initializeHat();
    utils.setVersionNumber("v1.1.10");
}
function addDebugTags(event) {
    if (event.id === utils.GlobalNamespace.Namespace + 'debug' && event.sourceEntity) {
        const player = new utils.SafetyCheckedEntity(event.sourceEntity);
        if (player.hasTag("dev")) {
            utils.mclog(`Removed ${player.nameTag}'s Dev Tags`);
            player.removeTag("dev");
            player.removeTag("npc");
        }
        else {
            player.addTag("dev");
            player.addTag("npc");
            utils.mclog(`Added ${player.nameTag}'s Dev Tags`);
        }
    }
    if (event.id === utils.GlobalNamespace.Namespace + 'update' && event.sourceEntity) {
        const player = new utils.SafetyCheckedEntity(event.sourceEntity);
        utils.clearDynamicProperty(player, "version");
    }
}
// Runs main on the next tick
mc.system.run(main);
