import * as mc from "@minecraft/server";
import * as utils from "../utils/index";
import { MOB_DATA, snapToSurface } from "../shared/index";
utils.afterEvents.scriptEventRecieve.subscribe("ldz_250121:test", async (e) => {
    var _a, _b;
    const player = (_a = e.sourceEntity) === null || _a === void 0 ? void 0 : _a.getPlayer();
    if (!player)
        return;
    const origin = snapToSurface(player.dimension, player.location.add(player.getViewDirection().multiply(5)), player.location.y).up().center();
    for (const [key, value] of Object.entries(MOB_DATA)) {
        try {
            const victim = value.debugEntity ? value.debugEntity(player.dimension, origin) : utils.overworld.spawnEntity(key, origin);
            if (!victim)
                continue;
            await utils.waitForTicks(10);
            victim.applyDamage(1000, { cause: mc.EntityDamageCause.entityAttack, damagingEntity: player.UnsafeEntity });
            await utils.waitForTicks(((_b = value.duration) !== null && _b !== void 0 ? _b : 2.0) * 20);
            await utils.waitForTicks(10);
        }
        catch (error) { }
    }
});
