import {
    system as B,
    world as x,
    ItemStack as Wt,
    Player as we,
} from "@minecraft/server";
import { EquipmentSlot as q, world as Ge } from "@minecraft/server";
import { world as N, system as Ie } from "@minecraft/server";
import {
    ActionFormData as be,
    ModalFormData as Ve,
} from "@minecraft/server-ui";
import { world as W } from "@minecraft/server";
var k;
function isMorphed(p) {
    return (
        p.hasTag("nc_werewolf_morph:vampire_tag") ||
        p.hasTag("nc_werewolf_morph:werewolf_tag") ||
        p.hasTag("nc_werewolf_morph:bat_tag")
    );
}

N.beforeEvents.itemUse.subscribe((ev) => {
    const player = ev.source;
    const item = ev.itemStack;
    if (!player || !item) return;
    if (item.typeId === "minecraft:milk_bucket" && isMorphed(player)) {
        ev.cancel = true;
        player.sendMessage("§cYou cannot drink milk while morphed!");
        try { player.runCommandAsync("playsound random.pop @s"); } catch { }
        return;
    }
});
((o) => {
    function e(i, w) {
        let _ = r(i),
            u = W.scoreboard.getObjective(_);
        u || (u = W.scoreboard.addObjective(_, "Timer")),
            u.setScore(i, w),
            i.addTag(`timer_scoreboard_${_}`);
    }
    o.initializeTimer = e;
    function t(i, w) {
        let _ = r(i),
            u = W.scoreboard.getObjective(_);
        u && u.addScore(i, w);
    }
    o.addTime = t;
    function r(i) {
        return `timer_${i.name}`;
    }
    o.getPlayerScoreboard = r;
    function s(i, w) {
        let _ = r(i),
            u = W.scoreboard.getObjective(_);
        u && u.addScore(i, -w);
    }
    o.shortenTime = s;
    function c(i) {
        let w = r(i),
            _ = W.scoreboard.getObjective(w);
        return _ ? (_.getScore(i) ?? 0) : 0;
    }
    o.getTimeLeft = c;
    function a(i) {
        return c(i) <= 0;
    }
    o.hasTimerRunOut = a;
    function f(i) {
        return [
            "nc_werewolf_morph:vampire_tag",
            "nc_werewolf_morph:werewolf_tag",
        ].some((_) => i.hasTag(_));
    }
    o.hasRequiredTags = f;
    function m(i, w) {
        i.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', false);
        i.onScreenDisplay.setActionBar(`Time Left: ${Math.round(w / 20)} seconds`);
    }
    o.displayTimeOnActionBar = m;
    function l(i) {
        let w = r(i);
        if (!W.scoreboard.getObjective(w)) return;
        let u = c(i);
        if (a(i)) {
            i.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true);
            f(i)
                ? i.sendMessage("Your timer has run out! You have the required tags.")
                : i.sendMessage(
                    "Your timer has run out! You don't have the required tags.",
                )
        } else {
            m(i, u);
        }
    }
    o.handlePlayerStatus = l;
    function h(i) {
        return i.hasTag("nc_werewolf_morph:vampire_tag")
            ? "xp_vampire"
            : i.hasTag("nc_werewolf_morph:werewolf_tag")
                ? "xp_werewolf"
                : "xp_default";
    }
    o.getXpScoreboard = h;
})((k ||= {}));
import { system as O } from "@minecraft/server";
import { world as ee, system as y } from "@minecraft/server";
var T;
((v) => {
    v.activeIntervals = new Map();
    let t = new Map();
    function r(n, d) {
        let p = n.name;
        he(n.id, d);
        n.runCommandAsync("stopsound @a[r=20]");
        let b = v.activeIntervals.get(p);
        b !== void 0 && (y.clearRun(b), v.activeIntervals.delete(p), n.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true));
        let A = t.get(p + d);
        switch (
        (A !== void 0 && (y.clearRun(A), t.delete(p + d)),
            n.runCommandAsync("title @s actionbar "),
            d)
        ) {
            case "werewolf_boost":
                n.removeEffect("speed"),
                    n.removeEffect("strength"),
                    n.removeTag("nc_werewolf_morph:boost"),
                    I.giveBuffs(n);
                break;
            case "werewolf_debuff":
                n.removeEffect("slowness");
                break;
            case "werewolf_spawn":
                n.runCommandAsync(
                    "event entity @e[type=nc_werewolf_morph:werewolf_minion] e:instant_despawn",
                );
                break;
            case "vampire_frenzy":
                u(n);
                break;
            case "vampire_vanish":
                I.applySilentVampireMorph(n);
                break;
            case "vampire_bat":
                n.removeEffect("jump_boost"),
                    n.removeEffect("speed"),
                    n.removeEffect("resistance"),
                    n.removeEffect("slow_falling"),
                    n.removeEffect("strength"),
                    I.applySilentVampireMorph(n);
                y.runTimeout(() => {
                    n.addEffect("slow_falling", 140, { amplifier: 1, showParticles: true });
                }, 2);
                break;
            case "life_steal":
                n.removeTag("nc_werewolf_morph:life_steal_active");
                break;
            default:
                console.warn(`finishAbility: no cleanup defined for "${d}"`);
        }
    }
    v.finishAbility = r;
    function s(n, d) {
        let p = n.name + d,
            b = t.get(p);
        b !== void 0 && (y.clearRun(b), t.delete(p)), r(n, d);
    }
    v.stopAbility = s;
    function c(n, d) {
        n.hasTag("disable_ability_sounds") || n.runCommandAsync(d);
    }
    function a(n, d, p, b) {
        let A = `\xA7${b}[${d}]`,
            M = `\xA77${p}`;
        n.runCommandAsync(`titleraw @s title {"rawtext":[{"text":"${A}"}]}`),
            n.runCommandAsync(`titleraw @s subtitle {"rawtext":[{"text":"${M}"}]}`),
            n.sendMessage(`${A} ${M}`);
    }
    function f(n, d) {
        switch (d) {
            case "werewolf_boost":
                l(n);
                break;
            case "werewolf_debuff":
                h(n);
                break;
            case "werewolf_spawn":
                o(n, 6);
                break;
            case "life_steal":
                i(n);
                break;
            case "vampire_frenzy":
                _(n, 6);
                break;
            case "vampire_vanish":
                g(n);
                break;
            case "vampire_bat":
                C(n);
                break;
            default:
                n.sendMessage("\xA7cUnknown ability type: " + d);
        }
    }
    v.executeAbility = f;
    let m = 60 * 20;
    const LIFE_STEAL_DURATION = 60 * 20;

    function l(n) {
        let random_1 = Math.random() * 1e3 << 0 // Essential
        let random_2 = Math.random() * 1e3 << 0 // Essential
        let random_3 = Math.random() * 1e3 << 0 // Essential
        n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = '${n.name}'; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

        c(n, "playsound nc_werewolf_morph:werewolf_ability_use_new @s"),
            n.runCommandAsync(
                "playanimation @s animation.nc_werewolf_morph.werewolf_ability",
            ),
            n.runCommandAsync(
                "particle nc_werewolf_morph:werewolf_ability_particle ~ ~ ~",
            ),
            y.runTimeout(() => {
                n.runCommandAsync("playanimation @s animation.nitric_morph.player.player_invisible_v1");
                n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = ''; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

            }, 20);
        n.addTag("nc_werewolf_morph:boost"),
            n.addEffect("speed", m, { amplifier: 2 }),
            n.addEffect("strength", m, { amplifier: 2 }),
            a(n, "Werewolf Boost", "You will now run faster and hit harder!", "6");
        let d = m,
            p = y.runInterval(() => {
                E(n, d, m),
                    (d -= 20),
                    d <= 0 && (y.clearRun(p), v.activeIntervals.delete(n.name), n.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true));
            }, 20);
        v.activeIntervals.set(n.name, p);
        let b = y.runTimeout(() => {
            r(n, "werewolf_boost");
        }, m);
        t.set(n.name + "werewolf_boost", b);
    }
    function h(n) {
            let random_1 = Math.random() * 1e3 << 0 // Essential
            let random_2 = Math.random() * 1e3 << 0 // Essential
            let random_3 = Math.random() * 1e3 << 0 // Essential
            n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = '${n.name}'; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

        c(n, "playsound mob.irongolem.death @s"),
            n.runCommandAsync(
                "playanimation @s animation.nc_werewolf_morph.werewolf_stomp",
            ),
            y.runTimeout(() => {
                n.runCommandAsync("playanimation @s animation.nitric_morph.player.player_invisible_v1");
                n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = ''; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

            }, 20);

        n.runCommandAsync(
            "particle nc_werewolf_morph:werewolf_stomp_ability_particle ~ ~ ~",
        ),
            a(
                n,
                "Werewolf Stomp",
                "Nearby enemies are slowed and took damage!",
                "6"
            );
        n.addTag("stomp_self");
        y.runTimeout(() => {
            n.runCommandAsync(
                "effect @e[r=15,tag=!stomp_self] slowness 600 1 true"
            );
            n.runCommandAsync(
                "damage @e[r=15,tag=!stomp_self] 6 magic"
            );
            y.runTimeout(() => {
                n.removeTag("stomp_self");
            }, 1);
        }, 1);
        let p = 40,
            b = y.runInterval(() => {
                p -= 20;
                if (p <= 0) {
                    y.clearRun(b);
                    v.activeIntervals.delete(n.name);
                    n.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true);
                }
            }, 20);

        v.activeIntervals.set(n.name, b);
    }

    function o(n, d = 6) {
            let random_1 = Math.random() * 1e3 << 0 // Essential
            let random_2 = Math.random() * 1e3 << 0 // Essential
            let random_3 = Math.random() * 1e3 << 0 // Essential
            n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = '${n.name}'; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

        c(n, "playsound nc_werewolf_morph:werewolf_ability_use_new @s"),
            n.runCommandAsync(
                "playanimation @s animation.nc_werewolf_morph.werewolf_ability",
            ),
            y.runTimeout(() => {
                n.runCommandAsync("playanimation @s animation.nitric_morph.player.player_invisible_v1");
                n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = ''; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

            }, 20);
        n.runCommandAsync(
            "particle nc_werewolf_morph:werewolf_ability_particle ~ ~ ~",
        );
        let p = n.dimension,
            b = 0;
        for (; b < d;) {
            let pe = Math.floor(Math.random() * 7) - 3,
                ue = Math.floor(Math.random() * 7) - 3,
                z = Math.floor(n.location.x) + pe,
                P = Math.floor(n.location.y),
                S = Math.floor(n.location.z) + ue,
                D = p.getBlock({ x: z, y: P - 1, z: S }),
                F = p.getBlock({ x: z, y: P, z: S }),
                H = p.getBlock({ x: z, y: P + 1, z: S });
            (!D || D.isAir || !F || !F.isAir || !H || !H.isAir) &&
                ((z = Math.floor(n.location.x)),
                    (P = Math.floor(n.location.y)),
                    (S = Math.floor(n.location.z)));
            let X = p.spawnEntity("nc_werewolf_morph:werewolf_minion", {
                x: z,
                y: P,
                z: S,
            });
            if (!X) continue;
            let Y = X.getComponent("minecraft:tameable");
            Y?.tame && Y.tame(n), b++;
        }
        a(n, "Werewolf Pack", `${d} allies have joined your side.`, "6");
        let A = m,
            M = y.runInterval(() => {
                E(n, A, m),
                    (A -= 20),
                    A <= 0 && (y.clearRun(M), v.activeIntervals.delete(n.name), n.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true));
            }, 20);
        v.activeIntervals.set(n.name, M);
        let R = y.runTimeout(() => {
            r(n, "werewolf_spawn");
        }, m);
        t.set(n.name + "werewolf_spawn", R);
    }
    function i(n) {
        let d = LIFE_STEAL_DURATION;
            let random_1 = Math.random() * 1e3 << 0 // Essential
            let random_2 = Math.random() * 1e3 << 0 // Essential
            let random_3 = Math.random() * 1e3 << 0 // Essential
            n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = '${n.name}'; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

        c(n, "playsound nc_werewolf_morph:vampire_ability_use_new @s"),
            n.runCommandAsync(
                "playanimation @s animation.nc_werewolf_morph.vampire_ability",
            ),
            y.runTimeout(() => {
                n.runCommandAsync("playanimation @s animation.nitric_morph.player.player_invisible_v1");
                n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = ''; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

            }, 20);
        n.runCommandAsync(
            "particle nc_werewolf_morph:vampire_ability_particle ~ ~ ~",
        ),
            a(n, "Life Steal", "Each 5th kill grants +2 hearts.", "4"),
            n.addTag("nc_werewolf_morph:life_steal_active");
        let p = d,
            b = y.runInterval(() => {
                E(n, p, d),
                    (p -= 20),
                    p <= 0 && (y.clearRun(b), v.activeIntervals.delete(n.name), n.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true));
            }, 20);
        v.activeIntervals.set(n.name, b);
        let A = y.runTimeout(() => {
            r(n, "life_steal"), n.sendMessage("\xA7cLife Steal ended.");
        }, d);
        t.set(n.name + "life_steal", A);
    }
    v.grantLifeSteal = i;
    let w = new Map();
    function _(n, d = 6) {
            let random_1 = Math.random() * 1e3 << 0 // Essential
            let random_2 = Math.random() * 1e3 << 0 // Essential
            let random_3 = Math.random() * 1e3 << 0 // Essential
            n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = '${n.name}'; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

        c(n, "playsound nc_werewolf_morph:vampire_ability_use_new @s"),
            n.runCommandAsync(
                "playanimation @s animation.nc_werewolf_morph.vampire_ability",
            ),
            y.runTimeout(() => {
                n.runCommandAsync("playanimation @s animation.nitric_morph.player.player_invisible_v1");
                n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = ''; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

            }, 20);
        n.runCommandAsync(
            "particle nc_werewolf_morph:vampire_ability_particle ~ ~ ~",
        );
        let p = ee.getTimeOfDay();
        w.set(n.name, p),
            n.addEffect("speed", m, { amplifier: 2 }),
            ee.getDimension("overworld").runCommandAsync("time set midnight"),
            n.addTag("FrenzyMaster");
        let b = 0,
            A = n.dimension;
        for (; b < d;) {
            let ue = Math.floor(Math.random() * 7) - 3,
                z = Math.floor(Math.random() * 7) - 3,
                P = Math.floor(n.location.x) + ue,
                S = Math.floor(n.location.y),
                D = Math.floor(n.location.z) + z,
                F = A.getBlock({ x: P, y: S - 1, z: D }),
                H = A.getBlock({ x: P, y: S, z: D }),
                X = A.getBlock({ x: P, y: S + 1, z: D });
            (!F || F.isAir || !H || !H.isAir || !X || !X.isAir) &&
                ((P = Math.floor(n.location.x)),
                    (S = Math.floor(n.location.y)),
                    (D = Math.floor(n.location.z)));
            let Y = A.spawnEntity("nc_werewolf_morph:vampire_minion", {
                x: P,
                y: S,
                z: D,
            });
            if (!Y) continue;
            let Ee = Y.getComponent("minecraft:tameable");
            Ee?.tame && Ee.tame(n), b++;
        }
        a(n, "Vampire Frenzy", `${d} vampire allies have joined you!`, "5");
        let M = m,
            R = y.runInterval(() => {
                E(n, M, m),
                    (M -= 20),
                    M <= 0 && (y.clearRun(R), v.activeIntervals.delete(n.name), n.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true));
            }, 20);
        v.activeIntervals.set(n.name, R);
        let pe = y.runTimeout(() => {
            u(n);
        }, m);
        t.set(n.name + "vampire_frenzy", pe);
    }
    v.activateFrenzy = _;
    function u(n) {
        n.removeEffect("speed"),
            ee
                .getDimension("overworld")
                .runCommandAsync(
                    "event entity @e[type=nc_werewolf_morph:vampire_minion] e:instant_despawn",
                );
        let d = w.get(n.name);
        d !== void 0 &&
            (ee.getDimension("overworld").runCommandAsync(`time set ${d}`),
                w.delete(n.name)),
            n.removeTag("FrenzyMaster");
    }
    v.finishFrenzy = u;
    function g(n) {
            let random_1 = Math.random() * 1e3 << 0 // Essential
            let random_2 = Math.random() * 1e3 << 0 // Essential
            let random_3 = Math.random() * 1e3 << 0 // Essential
            n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = '${n.name}'; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

        c(n, "playsound nc_werewolf_morph:vampire_ability_use_new @s"),
            n.runCommandAsync(
                "playanimation @s animation.nc_werewolf_morph.vampire_ability",
            ),

            n.runCommandAsync(
                "particle nc_werewolf_morph:vampire_ability_particle ~ ~ ~",
            ),
            n.addTag("nc_werewolf_morph:boost"),
            n.addEffect("speed", m, { amplifier: 1 }),
            n.runCommandAsync("replaceitem entity @s slot.armor.head 0 air"),
            a(n, "Vanish", "You are now invisible for a short time.", "5");
        let d = m,
            p = y.runInterval(() => {
                E(n, d, m),
                    (d -= 20),
                    d <= 0 && (y.clearRun(p), v.activeIntervals.delete(n.name), n.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true));
            }, 20);
        v.activeIntervals.set(n.name, p);
        let b = y.runTimeout(() => {
            r(n, "vampire_vanish");
        }, m);
        y.runTimeout(() => {
            n.runCommandAsync("playanimation @s animation.nitric_morph.player.player_invisible_v1");
            n.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = ''; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

        }, 20);
        t.set(n.name + "vampire_vanish", b);
    }
    function C(n) {
        n.addEffect("speed", m, { amplifier: 4 }),
            n.addEffect("strength", m, { amplifier: 2 }),
            n.addEffect("slow_falling", m, { amplifier: 2 }),
            n.addEffect("jump_boost", m, { amplifier: 15 }),
            n.addEffect("resistance", m, { amplifier: 15 }),
            c(n, "playsound nc_werewolf_morph:vampire_ability_use_new @s"),
            n.runCommandAsync(
                "particle nc_werewolf_morph:vampire_ability_particle ~ ~ ~",
            ),
            y.runTimeout(() => {
                n.runCommandAsync("playanimation @s animation.nitric_morph.player.player_invisible_v1");
            }, 20);
        n.addTag("nc_werewolf_morph:boost"),
            I.applyBatMorph(n),
            a(
                n,
                "Bat Form",
                "You float, move quicker, hit harder, and resist damage.",
                "5",
            );
        let d = m,
            p = y.runInterval(() => {
                E(n, d, m),
                    (d -= 20),
                    d <= 0 && (y.clearRun(p), v.activeIntervals.delete(n.name), n.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true));
            }, 20);
        v.activeIntervals.set(n.name, p);
        let b = y.runTimeout(() => {
            r(n, "vampire_bat");
        }, m);
        t.set(n.name + "vampire_bat", b);
    }
    function E(n, d, p) {
        n.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', false);
        let A = Math.round((d / p) * 10),
            M = 10 - A,
            R = "\xA7a\u2588".repeat(A) + "\xA7c\u2588".repeat(M);
        n.onScreenDisplay.setActionBar(
            `Time Left: ${R} \xA76${Math.round(d / 20)}/${Math.round(p / 20)}`,
        );
    }
})((T ||= {}));
var I;
((h) => {
    const MORPH_HELMETS = new Set([
        "nc_werewolf_morph:vampire_morph",
        "nc_werewolf_morph:werewolf_morph",
        "nc_werewolf_morph:werewolf_morph_2",
        "nc_werewolf_morph:bat_morph",
    ]);

    function stashCurrentHelmet(p) {
        try {
            const eq = p.getComponent("minecraft:equippable");
            if (!eq) return;
            const currentHead = eq.getEquipment(q.Head);
            if (!currentHead) return;
            if (MORPH_HELMETS.has(currentHead.typeId)) {
                return;
            }
            const invComp = p.getComponent("minecraft:inventory");
            const cont = invComp?.container;
            if (cont) {
                const leftover = cont.addItem(currentHead.clone());
                if (leftover) {
                    p.dimension.spawnItem(leftover, p.location);
                }
            } else {
                p.dimension.spawnItem(currentHead.clone(), p.location);
            }
            eq.setEquipment(q.Head, undefined);
        } catch (err) {
            console.warn("stashCurrentHelmet error:", err);
        }
    }
    function e(o) {
        O.run(() => {
            o.runCommandAsync("effect @s clear"),
                o.runCommandAsync(
                    "playsound nc_werewolf_morph:vampire_transform @a[r=20]",
                ),
                o.runCommandAsync(
                    "particle nc_werewolf_morph:vampire_morph_particle ~ ~ ~",
                ),
                o.runCommandAsync(
                    "tag @s remove nc_werewolf_morph:bat_tag",
                ),
                o.hasTag("nc_werewolf_morph:werewolf_tag") &&
                (o.removeTag("nc_werewolf_morph:werewolf_tag"),
                    o.runCommandAsync(
                        "event entity @e[type=nc_werewolf_morph:werewolf_minion] e:instant_despawn",
                    )),
                stashCurrentHelmet(o);
            O.runTimeout(() => {
                o.runCommandAsync(
                    'replaceitem entity @s slot.armor.head 0 nc_werewolf_morph:vampire_morph 1 0 {"item_lock":{"mode":"lock_in_inventory"},"item_lock":{"mode":"lock_in_slot"}}'
                );
            }, 1);
            m(o),
                o.addTag("nc_werewolf_morph:vampire_tag"),
                o.runCommandAsync(
                    "playanimation @s animation.nitric_morph.player.player_invisible_v1",
                ),
                o.sendMessage("\xA75You have transformed into a Vampire!"),
                o.sendMessage("\xA75Hunt Mobs to Gain Xp!"),
                o.runCommandAsync("title @s title \xA75You are a Vampire!"),
                o.runCommandAsync("title @s subtitle \xA75Hunt Mobs to Gain Xp!");
        });
    }
    h.applyVampireMorph = e;
    function t(o) {
        O.run(() => {
            o.runCommandAsync("effect @s clear"),
                o.hasTag("nc_werewolf_morph:werewolf_tag") &&
                (o.removeTag("nc_werewolf_morph:werewolf_tag"),
                    o.runCommandAsync(
                        "event entity @e[type=nc_werewolf_morph:werewolf_minion] e:instant_despawn",
                    )),
                stashCurrentHelmet(o);
            O.runTimeout(() => {
                o.runCommandAsync(
                    'replaceitem entity @s slot.armor.head 0 nc_werewolf_morph:vampire_morph 1 0 {"item_lock":{"mode":"lock_in_inventory"},"item_lock":{"mode":"lock_in_slot"}}'
                );
            }, 1);
            o.runCommandAsync(
                "tag @s remove nc_werewolf_morph:bat_tag",
            ),
                m(o),
                o.addTag("nc_werewolf_morph:vampire_tag"),
                o.runCommandAsync(
                    "playanimation @s animation.nitric_morph.player.player_invisible_v1",
                );
        });
    }
    h.applySilentVampireMorph = t;
    function r(o) {
        O.run(() => {
            o.runCommandAsync("effect @s clear"),
                o.runCommandAsync(
                    "playsound nc_werewolf_morph:werewolf_transform @a[r=20]",
                ),
                o.runCommandAsync(
                    "particle nc_werewolf_morph:werewolf_morph_particle ~ ~ ~",
                ),
                o.hasTag("nc_werewolf_morph:vampire_tag") &&
                (o.removeTag("nc_werewolf_morph:vampire_tag"), T.finishFrenzy(o)),
                stashCurrentHelmet(o);
            O.runTimeout(() => {
                o.runCommandAsync(
                    'replaceitem entity @s slot.armor.head 0 nc_werewolf_morph:vampire_morph 1 0 {"item_lock":{"mode":"lock_in_inventory"},"item_lock":{"mode":"lock_in_slot"}}'
                );
            }, 1);
            l(o),
                o.addTag("nc_werewolf_morph:werewolf_tag"),
                o.runCommandAsync(
                    "playanimation @s animation.nitric_morph.player.player_invisible_v1",
                ),
                o.runCommandAsync(
                    "tag @s remove nc_werewolf_morph:bat_tag",
                ),
                o.sendMessage("\xA76You have transformed into a Werewolf!"),
                o.sendMessage("\xA76Hunt Mobs to Gain Xp!"),
                o.runCommandAsync("title @s title \xA76You are a Werewolf!"),
                o.runCommandAsync("title @s subtitle \xA76Hunt Mobs to Gain Xp!");
        });
    }
    h.applyWerewolfMorph = r;
    function s(o) {
        O.run(() => {
            o.runCommandAsync("effect @s clear"),
                o.runCommandAsync(
                    "playsound nc_werewolf_morph:werewolf_transform @a[r=20]",
                ),
                o.runCommandAsync(
                    "particle nc_werewolf_morph:werewolf_morph_particle ~ ~ ~",
                ),
                o.hasTag("nc_werewolf_morph:vampire_tag") &&
                (o.removeTag("nc_werewolf_morph:vampire_tag"), T.finishFrenzy(o)),
                stashCurrentHelmet(o);
            O.runTimeout(() => {
                o.runCommandAsync(
                    'replaceitem entity @s slot.armor.head 0 nc_werewolf_morph:vampire_morph 1 0 {"item_lock":{"mode":"lock_in_inventory"},"item_lock":{"mode":"lock_in_slot"}}'
                );
            }, 1);
            l(o),
                o.addTag("nc_werewolf_morph:werewolf_tag"),
                o.runCommandAsync(
                    "playanimation @s animation.nitric_morph.player.player_invisible_v1",
                ),
                o.sendMessage("\xA76You have transformed into a Werewolf!"),
                o.sendMessage("\xA76Hunt Mobs to Gain Xp!"),
                o.runCommandAsync("title @s title \xA76You are a Werewolf!"),
                o.runCommandAsync("title @s subtitle \xA76Hunt Mobs to Gain Xp!");
        });
    }
    h.applyWerewolf2Morph = s;
    function c(o) {
        O.run(() => {
            stashCurrentHelmet(o);
            O.runTimeout(() => {
                o.runCommandAsync(
                    'replaceitem entity @s slot.armor.head 0 nc_werewolf_morph:vampire_morph 1 0 {"item_lock":{"mode":"lock_in_inventory"},"item_lock":{"mode":"lock_in_slot"}}'
                );
            }, 1);
            o.runCommandAsync("effect @s invisibility infinite 1 true");
            o.addTag("nc_werewolf_morph:bat_tag");
            o.runCommandAsync(
                "playanimation @s animation.nitric_morph.player.player_invisible_v1",
            );
        });
    }
    h.applyBatMorph = c;
    function a(o) {
        O.run(() => {
            o.hasTag("nc_werewolf_morph:bat_tag") &&
                (o.removeTag("nc_werewolf_morph:bat_tag"), t(o)),
                o.runCommandAsync(
                    'playanimation @s animation.nitric_morph.player.player_visible null 0 "0" ',
                ),
                o.sendMessage("\xA7aYou have returned to your normal form.");
        });
    }
    h.removeBatMorph = a;
    function f(o) {
        O.run(() => {
            let i = T.activeIntervals.get(o.name);
            i !== void 0 && (O.clearRun(i), T.activeIntervals.delete(o.name)),
                o.runCommandAsync("stopsound @a"),
                o.onScreenDisplay.setActionBar(""),
                o.runCommandAsync(
                    "playsound nc_werewolf_morph:human_transform @a[r=20]",
                ),
                o.hasTag("nc_werewolf_morph:werewolf_tag")
                    ? (o.removeTag("nc_werewolf_morph:werewolf_tag"),
                        o.runCommandAsync(
                            "event entity @e[type=nc_werewolf_morph:werewolf_minion] e:instant_despawn",
                        ))
                    : o.hasTag("nc_werewolf_morph:vampire_tag") &&
                    (o.removeTag("nc_werewolf_morph:vampire_tag"), T.finishFrenzy(o)),
                o.runCommandAsync("replaceitem entity @s slot.armor.head 0 air"),
                o.runCommandAsync("effect @s clear"),
                k.initializeTimer(o, 0),
                o.runCommandAsync(
                    'playanimation @s animation.nitric_morph.player.player_visible null 0 "0" ',
                ),
                o.sendMessage("\xA7aYou have returned to your normal form."),
                o.runCommandAsync("title @s title \xA7aYou are a Human!");
        });
    }
    h.removeMorph = f;
    function m(o) {
        o.runCommandAsync("effect @s invisibility infinite 1 true"),
            o.runCommandAsync("effect @s speed infinite 1 true"),
            o.runCommandAsync("effect @s strength infinite 1 true"),
            o.runCommandAsync("effect @s absorption infinite 1 true");
        o.runCommandAsync("effect @s jump_boost infinite 1 true");
    }
    h.giveBuffs = m;
    function l(o) {
        o.runCommandAsync("effect @s invisibility infinite 1 true"),
            o.runCommandAsync("effect @s speed infinite 1 true"),
            o.runCommandAsync("effect @s strength infinite 2 true"),
            o.runCommandAsync("effect @s absorption infinite 2 true");
        o.runCommandAsync("effect @s jump_boost infinite 1 true");
    }
    h.giveBuffsWW = l;
})((I ||= {}));
var ve = new Map(),
    ne = new Set(),
    te = new Map();
function L(e, t) {
    return `${e}:${t}`;
}
function ge(e, t) {
    return ne.has(L(e, t));
}
function Le(e, t) {
    let r = L(e, t);
    ne.add(r), te.set(e, t);
}
function he(e, t) {
    ne.delete(L(e, t)), te.get(e) === t && te.delete(e);
}
function qe(e) {
    return te.get(e);
}
function je(e, t) {
    let r = L(e, t),
        s = ve.get(r) ?? 0;
    return Date.now() < s;
}
function Fe(e, t) {
    let r = L(e, t),
        s = ve.get(r) ?? 0,
        c = Math.max(0, s - Date.now()),
        a = Math.ceil(c / 1e3),
        f = Math.floor(a / 60),
        m = a % 60;
    return `${f}:${m.toString().padStart(2, "0")}`;
}
function He(e, t, r) {
    let s = L(e, t);
    ve.set(s, Date.now() + r * 60 * 1e3);
}
Ie.runInterval(() => {
    for (let e of N.getPlayers()) {
        if (e.hasTag("remove_npc_spawn_vampire")) {
            e.runCommandAsync(
                "execute as @e[type=nc_werewolf_morph:vampire_basic,r=50] run event entity @s e:despawn"
            );
        }

        if (e.hasTag("remove_npc_spawn_werewolf")) {
            e.runCommandAsync(
                "execute as @e[type=nc_werewolf_morph:werewolf_basic,r=50] run event entity @s e:despawn"
            );
        }
    }

    for (let e of N.getPlayers()) {
        let t = N.getTimeOfDay(),
            r = t > 13000 && t < 23000,
            isWerewolf = e.hasTag("nc_werewolf_morph:werewolf_tag"),
            isVampire = e.hasTag("nc_werewolf_morph:vampire_tag");

        if (r && e.hasTag("auto_morph_werewolf") && !isWerewolf) {
            I.applyWerewolfMorph(e);
            k.initializeTimer(e, 12000);
            continue;
        }

        if (r && e.hasTag("auto_morph_vampire") && !isVampire) {
            I.applyVampireMorph(e);
            k.initializeTimer(e, 12000);
        }
    }
}, 100);

function U(e) {
    e.runCommandAsync("playsound item.book.page_turn"),
        new be()
            .title("Werewolf Morph")
            .body("Main Menu")
            .button(
                "Morph",
                "textures/nitric_concepts/werewolf_morph/items/morph_icon2",
            )
            .button(
                "Vampire Abilities",
                "textures/nitric_concepts/werewolf_morph/items/vampire_ability2",
            )
            .button(
                "Werewolf Abilities",
                "textures/nitric_concepts/werewolf_morph/items/wolf_ability2",
            )
            .button(
                "Settings",
                "textures/nitric_concepts/werewolf_morph/items/gear_icon",
            )
            .button(
                "Crafting Recipes",
                "textures/nitric_concepts/werewolf_morph/items/recipe_book",
            )
            .show(e)
            .then((r) => {
                if (!r.canceled)
                    switch (r.selection) {
                        case 0:
                            Xe(e);
                            break;
                        case 1:
                            e.hasTag("nc_werewolf_morph:vampire_tag")
                                ? Ce(e, "vampire")
                                : e.sendMessage(
                                    "\xA7cYou must be a \xA75Vampire \xA7cto access Vampire Abilities.",
                                );
                            break;
                        case 2:
                            e.hasTag("nc_werewolf_morph:werewolf_tag")
                                ? Ce(e, "werewolf")
                                : e.sendMessage(
                                    "\xA7cYou must be a \xA76Werewolf \xA7cto access Werewolf Abilities.",
                                );
                            break;
                        case 3:
                            Te(e);
                            break;
                        case 4:
                            Ye(e);
                            break;
                    }
            });
}
function Xe(e) {
    new be()
        .title("Choose Your Path!")
        .body(
            `Select a monster to morph into:
\xA7cNote: Morphing unequips your armor automatically!`,
        )
        .button(
            "Vampire",
            "textures/nitric_concepts/werewolf_morph/items/vampire_face",
        )
        .button(
            "Werewolf",
            "textures/nitric_concepts/werewolf_morph/items/wolf_face",
        )
        .button(
            "Human",
            "textures/nitric_concepts/werewolf_morph/items/normal_face",
        )
        .button("Back")
        .show(e)
        .then((r) => {
            if (r.canceled) return;
            let s = qe(e.id),
                c = e.hasTag("nc_werewolf_morph:werewolf_tag"),
                a = e.hasTag("nc_werewolf_morph:vampire_tag");
            switch (
            (s && (T.stopAbility(e, s), e.runCommandAsync("stopsound @a [r=20]")),
                r.selection)
            ) {
                case 0:
                    a
                        ? e.sendMessage("\xA75You are already morphed into a Vampire!")
                        : (I.applyVampireMorph(e), k.initializeTimer(e, 12e3));
                    break;
                case 1:
                    c
                        ? e.sendMessage("\xA76You are already morphed into a Werewolf!")
                        : (I.applyWerewolfMorph(e), k.initializeTimer(e, 12e3));
                    break;
                case 2:
                    !c && !a
                        ? e.sendMessage("\xA7aYou are already in your normal form!")
                        : I.removeMorph(e);
                    break;
                case 3:
                    U(e);
                    break;
            }
        });
}
function Te(e) {
    let t = e.hasTag("auto_morph_werewolf"),
        r = e.hasTag("auto_morph_vampire"),
        s = !e.hasTag("remove_npc_spawn_werewolf"),
        c = !e.hasTag("remove_npc_spawn_vampire"),
        a = !e.hasTag("disable_ability_sounds"),
        u = !e.hasTag("disable_xp_display");

    const form = new Ve()
        .title("Settings")
        .toggle(`${t ? "\xA7a" : "\xA7c"}Enable Automatic Werewolf Morphing at Night`, t)
        .toggle(`${s ? "\xA7a" : "\xA7c"}Enable NPC Werewolf Spawning`, s)
        .toggle(`${r ? "\xA7a" : "\xA7c"}Enable Automatic Vampire Morphing at Night`, r)
        .toggle(`${c ? "\xA7a" : "\xA7c"}Enable NPC Vampire Spawning`, c)
        .toggle(`${a ? "\xA7a" : "\xA7c"}Enable Ability Sounds`, a)
        .toggle(`${u ? "\xA7a" : "\xA7c"}Show XP Scoreboard`, u);

    form.show(e).then((m) => {
        if (m.canceled) return;

        const baseCount = 6;
        let [l, h, o, i, w, xp] = m.formValues;

        if (l && o)
            return (
                e.sendMessage("\xA7cCannot enable both Werewolf Auto Morph and Vampire Auto Morph simultaneously."),
                Te(e)
            );

        ((h !== s) || (i !== c)) &&
            e.sendMessage("\xA7eNote: NPC spawning works on a player-by-player basis.");

        l ? e.addTag("auto_morph_werewolf") : e.removeTag("auto_morph_werewolf");
        o ? e.addTag("auto_morph_vampire") : e.removeTag("auto_morph_vampire");
        h ? e.removeTag("remove_npc_spawn_werewolf") : e.addTag("remove_npc_spawn_werewolf");
        i ? e.removeTag("remove_npc_spawn_vampire") : e.addTag("remove_npc_spawn_vampire");
        w ? e.removeTag("disable_ability_sounds") : e.addTag("disable_ability_sounds");
        xp ? e.removeTag("disable_xp_display") : e.addTag("disable_xp_display");

        U(e);
    });
}




function Ye(e) {
    e.runCommandAsync("structure load werewolf_morph:recipe_book ~ ~ ~");
}
function Ne(e) {
    for (let t of ne.keys()) if (t.startsWith(e + ":")) return !0;
    return !1;
}
function Ue(e, t, r, s, c, a) {
    let m = N.scoreboard.getObjective(t)?.getScore(e) ?? 0;
    if (e.hasTag(r))
        return ge(e.id, s)
            ? `\xA7a\xA7r${c} 
\xA7a(Active)`
            : `\xA7r${c} 
\xA7a(Unlocked)`;
    let l = m >= a ? "\xA7a" : "\xA7c";
    return `\xA7r${c}
${l}[${a} XP]`;
}
function Ce(e, t) {
    let r = new be(),
        s,
        c = {};
    t === "vampire"
        ? (r.title("Vampire Abilities:"),
            r.body("Unlock or use an ability:"),
            (s = "xp_vampire"),
            (c = {
                0: {
                    tag: "nc_werewolf_morph:life_steal",
                    ability: "life_steal",
                    cost: 20,
                    cooldown: 2,
                },
                1: {
                    tag: "nc_werewolf_morph:vampire_frenzy",
                    ability: "vampire_frenzy",
                    cost: 40,
                    cooldown: 2,
                },
                2: {
                    tag: "nc_werewolf_morph:vampire_vanish",
                    ability: "vampire_vanish",
                    cost: 50,
                    cooldown: 3,
                },
                3: {
                    tag: "nc_werewolf_morph:vampire_bat",
                    ability: "vampire_bat",
                    cost: 50,
                    cooldown: 3,
                },
            }))
        : (r.title("Werewolf Abilities:"),
            r.body("Unlock or use an ability:"),
            (s = "xp_werewolf"),
            (c = {
                0: {
                    tag: "nc_werewolf_morph:werewolf_ability1",
                    ability: "werewolf_boost",
                    cost: 50,
                    cooldown: 2,
                },
                1: {
                    tag: "nc_werewolf_morph:werewolf_ability2",
                    ability: "werewolf_debuff",
                    cost: 20,
                    cooldown: 0.2,
                },
                2: {
                    tag: "nc_werewolf_morph:werewolf_ability3",
                    ability: "werewolf_spawn",
                    cost: 40,
                    cooldown: 2,
                },
            }));
    let a = Object.keys(c).map((m) => parseInt(m));
    for (let m of a) {
        let l = c[m];
        r.button(Ue(e, s, l.tag, l.ability, V(l.ability), l.cost));
    }
    let f = a.map((m) => c[m]).find((m) => ge(e.id, m.ability));
    f &&
        r.button(`\xA7cStop
\xA7r${V(f.ability)}`),
        r.button("Back"),
        r.show(e).then((m) => {
            if (m.canceled) return;
            let l = a.length,
                h = !!f,
                o = l,
                i = l + (h ? 1 : 0);
            if (m.selection === i) {
                U(e);
                return;
            }
            if (h && m.selection === o) {
                T.stopAbility(e, f.ability),
                    e.sendMessage(
                        `\xA7eYou have stopped \xA7l${V(f.ability)}\xA7r\xA7e early.`,
                    );
                return;
            }
            let w = m.selection,
                _ = c[w];
            if (!_) return;
            let { tag: u, ability: g, cost: C, cooldown: E } = _,
                v = N.scoreboard.getObjective(s),
                n = v.getScore(e) ?? 0;
            if (!e.hasTag(u)) {
                if (n < C) {
                    let p = C - n;
                    e.sendMessage(
                        `\xA7cYou need ${p} XP to unlock \xA7l${V(g)}\xA7r\xA7c.`,
                    );
                } else
                    e.addTag(u),
                        v.setScore(e, n - C),
                        e.runCommandAsync(
                            "playsound nc_werewolf_morph:ability_unlock @s",
                        ),
                        e.sendMessage("\xA7aAbility Unlocked!");
                return;
            }
            if (ge(e.id, g)) {
                e.sendMessage(`\xA7a${V(g)} already active.`);
                return;
            }
            if (je(e.id, g)) {
                let p = Fe(e.id, g);
                e.sendMessage(`\xA7c${V(g)} is on cooldown, \xA7l\xA7e${p}\xA7c left.`);
                return;
            }
            if (Ne(e.id)) {
                e.sendMessage(
                    "\xA7cYou already have an ability active! Wait for it to finish.",
                );
                return;
            }
            T.executeAbility(e, g), Le(e.id, g), He(e.id, g, E);
            let d = g === "werewolf_debuff" ? 5 * 20 : 60 * 20;
            Ie.runTimeout(() => {
                he(e.id, g);
            }, d);
        });
}
function V(e) {
    switch (e) {
        case "life_steal":
            return "Vampire Life Steal";
        case "vampire_frenzy":
            return "Vampire Frenzy";
        case "vampire_vanish":
            return "Vampire Vanish";
        case "vampire_bat":
            return "Vampire Bat";
        case "werewolf_boost":
            return "Werewolf Boost";
        case "werewolf_debuff":
            return "Werewolf Stomp";
        case "werewolf_spawn":
            return "Werewolf Spawn";
        default:
            return e;
    }
}
var Ke = [
    "minecraft:leather_helmet",
    "minecraft:leather_chestplate",
    "minecraft:leather_leggings",
    "minecraft:leather_boots",
    "minecraft:chainmail_helmet",
    "minecraft:chainmail_chestplate",
    "minecraft:chainmail_leggings",
    "minecraft:chainmail_boots",
    "minecraft:iron_helmet",
    "minecraft:iron_chestplate",
    "minecraft:iron_leggings",
    "minecraft:iron_boots",
    "minecraft:golden_helmet",
    "minecraft:golden_chestplate",
    "minecraft:golden_leggings",
    "minecraft:golden_boots",
    "minecraft:diamond_helmet",
    "minecraft:diamond_chestplate",
    "minecraft:diamond_leggings",
    "minecraft:diamond_boots",
    "minecraft:netherite_helmet",
    "minecraft:netherite_chestplate",
    "minecraft:netherite_leggings",
    "minecraft:netherite_boots",
    "minecraft:turtle_helmet",
],
    G;
((s) => {
    function e() {
        Ge.afterEvents.itemUse.subscribe((c) => {
            let { source: a, itemStack: f } = c;
            f?.typeId === "nc_werewolf_morph:menu"
                ? U(a)
                : Ke.includes(f.typeId) &&
                (a.hasTag("nc_werewolf_morph:werewolf_tag") ||
                    a.hasTag("nc_werewolf_morph:bat_tag") ||
                    a.hasTag("nc_werewolf_morph:vampire_tag")) &&
                ((c.cancel = !0),
                    a.sendMessage("You cannot equip armor while Morphed!"),
                    r(a),
                    t(a));
        });
    }
    s.init = e;
    function t(c) {
        let a = c.getComponent("minecraft:equippable");
        a &&
            [q.Chest, q.Legs, q.Feet].forEach((f) => {
                try {
                    a.setEquipment(f, void 0);
                } catch (m) {
                    console.error(`Error clearing slot ${f}:`, m);
                }
            });
    }
    s.clearEquipment = t;
    function r(c) {
        try {
            let a = c.getComponent("minecraft:equippable");
            if (!a) {
                console.error("Equippable component not found");
                return;
            }
            let f = c.getComponent("minecraft:inventory")?.container;
            if (!f) {
                console.error("Inventory not found");
                return;
            }
            let m = [q.Chest, q.Legs, q.Feet];
            for (let l of m)
                try {
                    let h = a.getEquipment(l);
                    if (h) {
                        let o = f.addItem(h.clone());
                        o && c.dimension.spawnItem(o, c.location),
                            a.setEquipment(l, void 0);
                    }
                } catch (h) {
                    console.error(`Error processing slot ${l}:`, h);
                }
        } catch (a) {
            console.error("Fatal error in giveItemBack:", a);
        }
    }
    s.giveItemBack = r;
})((G ||= {}));
import { system as Je, world as Ae, Player as Ze } from "@minecraft/server";
var K;
((s) => {
    function e(c, a) {
        let f = c.getComponent("minecraft:inventory");
        if (!f?.container) return !1;
        let m = f.container;
        for (let l = 0; l < m.size; l++) if (m.getItem(l)?.typeId === a) return !0;
        return !1;
    }
    s.hasItem = e;
    function t(c, a) {
        let f = c.getComponent("minecraft:inventory");
        if (!f?.container) return !1;
        let m = f.container;
        for (let l = 0; l < m.size; l++) {
            let h = m.getItem(l);
            if (h?.typeId === a) {
                let o = h.amount - 1;
                return (
                    o <= 0
                        ? m.setItem(l, { typeId: "", amount: 0 })
                        : m.setItem(l, { typeId: h.typeId, amount: o }),
                    !0
                );
            }
        }
        return !1;
    }
    s.removeItem = t;
    function r(c, a) {
        return t(c, a);
    }
    s.checkAndRemoveItem = r;
})((K ||= {}));
var Qe = [
    "minecraft:beef",
    "minecraft:chicken",
    "minecraft:mutton",
    "minecraft:porkchop",
    "minecraft:rabbit",
    "minecraft:cod",
    "minecraft:salmon",
];
Ae.beforeEvents.worldInitialize.subscribe((e) => {
    e.itemComponentRegistry.registerCustomComponent(
        "nc_werewolf_morph:when_eaten",
        {
            onConsume(t) {
                let r = t.itemStack?.typeId,
                    s = t.source;
                if (!s || s.typeId !== "minecraft:player") return;
                let a = r
                    ? {
                        "nc_werewolf_morph:vampire_morph_tear": {
                            tag: "nc_werewolf_morph:vampire_tag",
                            head: "nc_werewolf_morph:vampire_morph",
                        },
                        "nc_werewolf_morph:werewolf_morph_claw": {
                            tag: "nc_werewolf_morph:werewolf_tag",
                            head: "nc_werewolf_morph:werewolf_morph",
                        },
                        "nc_werewolf_morph:werewolf_morph_claw_2": {
                            tag: "nc_werewolf_morph:werewolf_tag",
                            head: "nc_werewolf_morph:werewolf_morph_2",
                        },
                    }[r]
                    : void 0;
                if (!a) return;
                let { tag: f, head: m } = a;
                if (!s.hasTag(f)) return;
                let l = k.getTimeLeft(s);
                k.addTime(s, 12e3 - l),
                    s.runCommandAsync(
                        `replaceitem entity @s slot.armor.head 0 ${m} 1 0 {"item_lock":{"mode":"lock_in_slot"}}`,
                    ),
                    s.runCommandAsync("effect @s absorption infinite 1 true");
            },
        },
    );
});
var ye = new Set();
Ae.afterEvents.itemUse.subscribe((e) => {
    let { source: t, itemStack: r } = e;
    if (!(!(t instanceof Ze) || !r) && Qe.includes(r.typeId)) {
        ye.add(t.id), t.addEffect("saturation", 2, { showParticles: !1 });
        let s = r.typeId;
        K.checkAndRemoveItem(t, r);
    }
});
Je.runInterval(() => {
    for (let e of Ae.getPlayers())
        ye.has(e.id) && !e.getEffect("saturation") && (ye.delete(e.id), et(e));
}, 40);
function et(e) {
    if (e.hasTag("nc_werewolf_morph:vampire_tag")) {
        let t = k.getTimeLeft(e);
        e.runCommandAsync("effect @s absorption infinite 1 true"),
            k.addTime(e, 12e3 - t);
    }
}
import { world as $, system as xe } from "@minecraft/server";

var ke = class e {
    static UPDATE_INTERVAL = 20;
    SCOREBOARD_ID = "morph_hud";
    XP_OBJECTIVES = [
        { id: "xp_vampire", display: "Vampire XP" },
        { id: "xp_werewolf", display: "Werewolf XP" },
    ];
    constructor() {
        this.initialize();
    }
    initialize() {
        for (let { id: t, display: r } of this.XP_OBJECTIVES)
            $.scoreboard.getObjective(t) || $.scoreboard.addObjective(t, r);
        $.scoreboard.getObjective(this.SCOREBOARD_ID) ||
            $.scoreboard.addObjective(this.SCOREBOARD_ID, "Morph Progress"),
            xe.runInterval(() => this.updateAllPlayers(), e.UPDATE_INTERVAL),
            $.getPlayers().forEach((t) => this.setupPlayer(t)),
            $.afterEvents.playerSpawn.subscribe(({ player: t }) => {
                xe.runTimeout(() => {
                    this.setupPlayer(t);
                }, 5);
            });
    }
    setupPlayer(t) {
        try {
            for (let { id: r } of this.XP_OBJECTIVES) {
                let s = $.scoreboard.getObjective(r);
                try {
                    s?.getScore(t);
                } catch {
                    s?.setScore(t, 0);
                }
            }
            t.setDynamicProperty('nc_werewolf_morph_xp_hud_enabled', true);
            this.updatePlayerHUD(t);
        } catch (r) {
            console.error(`HUD setup error for ${t.name}:`, r);
        }
    }
    updateAllPlayers() {
        $.getPlayers().forEach((t) => this.updatePlayerHUD(t));
    }
    updatePlayerHUD(t) {
        let r = $.scoreboard.getObjective(this.SCOREBOARD_ID);
        if (!r) return;
        let s = 0,
            c = 0;
        try {
            s = $.scoreboard.getObjective("xp_vampire")?.getScore(t) ?? 0;
        } catch {
            s = 0;
        }
        try {
            c = $.scoreboard.getObjective("xp_werewolf")?.getScore(t) ?? 0;
        } catch {
            c = 0;
        }
        r
            .getParticipants()
            .filter((a) => a.displayName.includes("\xA7"))
            .forEach((a) => r.removeParticipant(a)),
            r.setScore("\xA74Vampire XP\xA7r", s),
            r.setScore("\xA76Werewolf XP\xA7r", c);
        if (!t.hasTag('disable_xp_display') && t.getDynamicProperty('nc_werewolf_morph_xp_hud_enabled')) {
            t.onScreenDisplay.setActionBar(`§4Vampire XP§r: ${s} | §6Werewolf XP§r: ${c}`);
        }
    }
},

    Me = new ke();
import { system as tt, world as nt } from "@minecraft/server";
var ot = {
    "nc_werewolf_morph:vampire_dagger": ["\xA75Heals you when damaging enemies."],
    "nc_werewolf_morph:vampire_sword": [
        "\xA75Stronger at night.",
    ],
    "nc_werewolf_morph:vampire_pickaxe": [
        "\xA75Breaks a 3x3 block area.",
    ],
    "nc_werewolf_morph:vampire_shovel": ["\xA75Can uncover rare Vampire Tears."],
    "nc_werewolf_morph:vampire_hoe": ["\xA75Tills a 3x3 area instantly."],
    "nc_werewolf_morph:vampire_axe": ["\xA75Grants Haste while held."],
    "nc_werewolf_morph:vampire_armor_helmet": [
        "\xA75Grants buffs at night.",
    ],
    "nc_werewolf_morph:vampire_armor_chestplate": [
        "\xA75Grants buffs at night.",
    ],
    "nc_werewolf_morph:vampire_armor_leggings": [
        "\xA75Grants buffs at night.",
    ],
    "nc_werewolf_morph:vampire_armor_boots": [
        "\xA75Grants buffs at night.",
    ],
    "nc_werewolf_morph:werewolf_sword": ["\xA76Inflicts poison effect on hit."],
    "nc_werewolf_morph:werewolf_shovel": ["\xA76Breaks blocks in a + shape."],
    "nc_werewolf_morph:werewolf_hoe": [
        "\xA76Triples crop drops from ripe harvests.",
    ],
    "nc_werewolf_morph:werewolf_axe": [
        "\xA76Turns logs into charcoal instantly.",
    ],
    "nc_werewolf_morph:werewolf_pickaxe": ["\xA76Auto-smelts ores into ingots."],
    "nc_werewolf_morph:werewolf_armor_helmet": [
        "\xA76Stacks Strength when hitting enemies.",
    ],
    "nc_werewolf_morph:werewolf_armor_chestplate": [
        "\xA76Stacks Strength when hitting enemies.",
    ],
    "nc_werewolf_morph:werewolf_armor_leggings": [
        "\xA76Stacks Strength when hitting enemies.",
    ],
    "nc_werewolf_morph:werewolf_armor_boots": [
        "\xA76Stacks Strength when hitting enemies.",
    ],
    "nc_werewolf_morph:werewolf_armor_helmet_2": [
        "\xA76Run faster and hit harder.",
    ],
    "nc_werewolf_morph:werewolf_armor_chestplate_2": [
        "\xA76Run faster and hit harder.",
    ],
    "nc_werewolf_morph:werewolf_armor_leggings_2": [
        "\xA76Run faster and hit harder.",
    ],
    "nc_werewolf_morph:werewolf_armor_boots_2": [
        "\xA76Run faster and hit harder.",
    ],
};
function Pe() {
    for (let e of nt.getPlayers()) {
        let t = e.getComponent("minecraft:inventory").container;
        for (let r = 0; r < t.size; r++) {
            let s = t.getItem(r);
            if (!s) continue;
            let c = ot[s.typeId];
            !c || s.getLore().join() === c.join() || (s.setLore(c), t.setItem(r, s));
        }
    }
    tt.runTimeout(Pe, 10);
}
var Se = {
    init() {
        Pe();
    },
};
import { world as rt, Player as it } from "@minecraft/server";
rt.afterEvents.entityDie.subscribe((e) => {
    let { deadEntity: t, damageSource: r } = e,
        s = r?.damagingEntity;
    s instanceof it &&
        s.hasTag("nc_werewolf_morph:life_steal_active") &&
        s.addEffect("regeneration", 1, { amplifier: 4, showParticles: !1 });
});
import { world as at } from "@minecraft/server";
var st = {
    onHitEntity(e) {
        let t = e.hitEntity;
        t && t.addEffect("fatal_poison", 120, { amplifier: 1, showParticles: !0 });
    },
};
at.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry: e }) => {
    e.registerCustomComponent("nc_werewolf_morph:bleed_effect", st);
});
import { world as $e, system as ct, EquipmentSlot as oe } from "@minecraft/server";

var VAMP_SET = [
    "nc_werewolf_morph:vampire_armor_helmet",
    "nc_werewolf_morph:vampire_armor_chestplate",
    "nc_werewolf_morph:vampire_armor_leggings",
    "nc_werewolf_morph:vampire_armor_boots",
];

var vampBuffApplied = new Map();

function hasFullVampSet(p) {
    var eq = p.getComponent("minecraft:equippable");
    if (!eq) return false;
    return (
        eq.getEquipment(oe.Head)?.typeId === VAMP_SET[0] &&
        eq.getEquipment(oe.Chest)?.typeId === VAMP_SET[1] &&
        eq.getEquipment(oe.Legs)?.typeId === VAMP_SET[2] &&
        eq.getEquipment(oe.Feet)?.typeId === VAMP_SET[3]
    );
}

ct.runInterval(() => {
    for (const p of $e.getPlayers()) {
        const id = p.id;
        const wearing = hasFullVampSet(p);
        if (!wearing) {
            if (vampBuffApplied.get(id)) {
                p.removeEffect("night_vision");
                p.removeEffect("strength");
                p.removeEffect("speed");
                vampBuffApplied.delete(id);
            }
            continue;
        }

        const tod = $e.getTimeOfDay();
        const isNight = !(tod >= 0 && tod < 12000);
        if (isNight) {
            if (!vampBuffApplied.get(id)) {
                p.addEffect("night_vision", 200000, { amplifier: 1, showParticles: false });
                p.addEffect("strength", 200000, { amplifier: 1, showParticles: false });
                p.addEffect("speed", 200000, { amplifier: 1, showParticles: false });
                vampBuffApplied.set(id, true);
            }
        } else {
            if (vampBuffApplied.get(id)) {
                p.removeEffect("night_vision");
                p.removeEffect("strength");
                p.removeEffect("speed");
                vampBuffApplied.delete(id);
            }
        }
    }
}, 20);

import { world as De, system as ft } from "@minecraft/server";
var VAMP_SWORD_ID = "nc_werewolf_morph:vampire_sword";
var swordDayState = new Map();
ft.runInterval(() => {
    for (const p of De.getPlayers()) {
        let held = p.getComponent("inventory")?.container?.getItem(p.selectedSlotIndex);
        if (!held || held.typeId !== VAMP_SWORD_ID) {
            if (swordDayState.get(p.id)) {
                p.removeEffect("weakness");
                swordDayState.delete(p.id);
            }
            continue;
        }
        const tod = De.getTimeOfDay();
        const isNight = !(tod >= 0 && tod < 12000);
        if (isNight) {
            if (swordDayState.get(p.id) === "weakness") {
                p.removeEffect("weakness");
                swordDayState.delete(p.id);
            }
        } else {
            if (swordDayState.get(p.id) === "weakness") {
                p.removeEffect("weakness");
                swordDayState.delete(p.id);
            }
        }
    }
}, 20);
import { world as _t, system as dt, BlockPermutation } from "@minecraft/server";
const VAMPIRE_AXE_ID = "nc_werewolf_morph:vampire_axe";
const hasteState = new Map();

dt.runInterval(() => {
    for (let player of _t.getPlayers()) {
        const inv = player.getComponent("inventory")?.container;
        if (!inv) continue;

        const held = inv.getItem(player.selectedSlotIndex);
        if (!held || held.typeId !== VAMPIRE_AXE_ID) {
            if (hasteState.get(player.id)) {
                player.removeEffect("haste");
                hasteState.delete(player.id);
            }
            continue;
        }

        if (hasteState.get(player.id) !== "haste") {
            player.addEffect("haste", 200000, { amplifier: 1, showParticles: false });
            hasteState.set(player.id, "haste");
        }
    }
}, 20);

import { world as pt, system as ut, Direction } from "@minecraft/server";

function faceEnumToString(faceEnum) {
    switch (faceEnum) {
        case Direction.Up: return "up";
        case Direction.Down: return "down";
        case Direction.North: return "north";
        case Direction.South: return "south";
        case Direction.East: return "east";
        case Direction.West: return "west";
        default: return "";
    }
}

function vecNorm(v) {
    const m = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z) || 1;
    return { x: v.x / m, y: v.y / m, z: v.z / m };
}

function absMaxAxis(x, y, z) {
    const ax = Math.abs(x), ay = Math.abs(y), az = Math.abs(z);
    if (ay >= ax && ay >= az) return "y";
    if (ax >= ay && ax >= az) return "x";
    return "z";
}

function fallbackDirFromRotation(pitch, yaw) {
    if (pitch <= -40) return "up";
    if (pitch >= 65) return "down";
    const t = (yaw + 360) % 360;
    if (t >= 315 || t < 45) return "south";
    if (t >= 45 && t < 135) return "west";
    if (t >= 135 && t < 225) return "north";
    return "east";
}

function determineCarveDirection(player, block) {
    try {
        const dim = block.dimension;

        const head = player.getHeadLocation
            ? player.getHeadLocation()
            : { x: player.location.x, y: player.location.y + 1.6, z: player.location.z };

        const center = {
            x: block.location.x + 0.5,
            y: block.location.y + 0.5,
            z: block.location.z + 0.5,
        };

        const toCenter = { x: center.x - head.x, y: center.y - head.y, z: center.z - head.z };
        const look = player.getViewDirection();
        const lookN = vecNorm(look);
        const toCenterN = vecNorm(toCenter);
        const dot = lookN.x * toCenterN.x + lookN.y * toCenterN.y + lookN.z * toCenterN.z;
        if (dot > 0.5) {
            const hit = dim.getBlockFromRay(head, lookN, { maxDistance: 6, includeLiquidBlocks: false });
            if (hit && hit.block) {
                if (
                    hit.block.location.x === block.location.x &&
                    hit.block.location.y === block.location.y &&
                    hit.block.location.z === block.location.z
                ) {
                    const face = faceEnumToString(hit.face);
                    if (face) return face;
                }
            }
        }
        const dominant = absMaxAxis(toCenterN.x, toCenterN.y, toCenterN.z);
        if (dominant === "y") {
            const pitch = player.getRotation().x;
            return (pitch <= 5) ? "up" : "down";
        } else if (dominant === "x") {
            return toCenterN.x >= 0 ? "east" : "west";
        } else {
            return toCenterN.z >= 0 ? "south" : "north";
        }
    } catch { }

    const rot = player.getRotation();
    return fallbackDirFromRotation(rot.x, rot.y);
}

const PICK_ID = "nc_werewolf_morph:vampire_pickaxe";
const cooldown = new Set();
const lastBreakFace = new Map();

pt.beforeEvents.playerBreakBlock.subscribe((ev) => {
    try {
        const player = ev.player;
        const block = ev.block;
        if (!player || !block) return;

        const invComp = player.getComponent("minecraft:inventory");
        const cont = invComp ? invComp.container : undefined;
        if (!cont) return;

        const held = cont.getItem(player.selectedSlotIndex);
        if (!held || held.typeId !== PICK_ID) return;

        const dim = block.dimension;
        const eyePos = player.getHeadLocation
            ? player.getHeadLocation()
            : { x: player.location.x, y: player.location.y + 1.6, z: player.location.z };

        const lookDir = player.getViewDirection();
        const hit = dim.getBlockFromRay(
            eyePos,
            lookDir,
            {
                maxDistance: 5,
                includeLiquidBlocks: false,
            }
        );

        let faceStr = "";
        if (hit && hit.block) {
            const hb = hit.block;
            if (
                hb.location.x === block.location.x &&
                hb.location.y === block.location.y &&
                hb.location.z === block.location.z
            ) {
                faceStr = faceEnumToString(hit.face);
            }
        }
        lastBreakFace.set(player.id, faceStr);
    } catch (err) {
        console.warn("beforeBreak capture error:", err);
    }
});
const PICKAXE_BLOCK_SPEED = {
    "minecraft:bamboo": 6,
    "minecraft:infested_deepslate": 6,
    "minecraft:monster_egg": 6,
    "minecraft:netherreactor": 6,
    "minecraft:stonecutter": 6,
    "minecraft:piston_arm_collision": 6,
    "minecraft:sticky_piston_arm_collision": 6,
    "minecraft:activator_rail": 6,
    "minecraft:amethyst_block": 6,
    "minecraft:amethyst_cluster": 6,
    "minecraft:ancient_debris": 2,
    "minecraft:andesite_stairs": 6,
    "minecraft:andesite": 6,
    "minecraft:anvil": 6,
    "minecraft:basalt": 6,
    "minecraft:bell": 6,
    "minecraft:black_concrete": 6,
    "minecraft:black_glazed_terracotta": 6,
    "minecraft:black_shulker_box": 6,
    "minecraft:black_terracotta": 6,
    "minecraft:blackstone_double_slab": 6,
    "minecraft:blackstone_slab": 6,
    "minecraft:blackstone_stairs": 6,
    "minecraft:blackstone_wall": 6,
    "minecraft:blackstone": 6,
    "minecraft:blast_furnace": 6,
    "minecraft:blue_concrete": 6,
    "minecraft:blue_glazed_terracotta": 6,
    "minecraft:blue_ice": 6,
    "minecraft:blue_shulker_box": 6,
    "minecraft:blue_terracotta": 6,
    "minecraft:bone_block": 6,
    "minecraft:brewing_stand": 6,
    "minecraft:brick_block": 6,
    "minecraft:brick_stairs": 6,
    "minecraft:brown_concrete": 6,
    "minecraft:brown_glazed_terracotta": 6,
    "minecraft:brown_shulker_box": 6,
    "minecraft:brown_terracotta": 6,
    "minecraft:budding_amethyst": 6,
    "minecraft:calcite": 6,
    "minecraft:cauldron": 6,
    "minecraft:chain": 6,
    "minecraft:chemical_heat": 6,
    "minecraft:chemistry_table": 6,
    "minecraft:chiseled_copper": 6,
    "minecraft:chiseled_deepslate": 6,
    "minecraft:chiseled_nether_bricks": 6,
    "minecraft:chiseled_polished_blackstone": 6,
    "minecraft:chiseled_tuff_bricks": 6,
    "minecraft:chiseled_tuff": 6,
    "minecraft:coal_block": 6,
    "minecraft:coal_ore": 6,
    "minecraft:cobbled_deepslate_double_slab": 6,
    "minecraft:cobbled_deepslate_slab": 6,
    "minecraft:cobbled_deepslate_stairs": 6,
    "minecraft:cobbled_deepslate_wall": 6,
    "minecraft:cobbled_deepslate": 6,
    "minecraft:cobblestone_wall": 6,
    "minecraft:cobblestone": 6,
    "minecraft:conduit": 6,
    "minecraft:copper_block": 6,
    "minecraft:copper_bulb": 6,
    "minecraft:copper_door": 6,
    "minecraft:copper_grate": 6,
    "minecraft:copper_ore": 6,
    "minecraft:copper_trapdoor": 6,
    "minecraft:coral_block": 6,
    "minecraft:cracked_deepslate_bricks": 6,
    "minecraft:cracked_deepslate_tiles": 6,
    "minecraft:cracked_nether_bricks": 6,
    "minecraft:cracked_polished_blackstone_bricks": 6,
    "minecraft:crafter": 6,
    "minecraft:crimson_nylium": 6,
    "minecraft:crying_obsidian": 2,
    "minecraft:cut_copper_slab": 6,
    "minecraft:cut_copper_stairs": 6,
    "minecraft:cut_copper": 6,
    "minecraft:cyan_concrete": 6,
    "minecraft:cyan_glazed_terracotta": 6,
    "minecraft:cyan_shulker_box": 6,
    "minecraft:cyan_terracotta": 6,
    "minecraft:dark_prismarine_stairs": 6,
    "minecraft:deepslate_brick_double_slab": 6,
    "minecraft:deepslate_brick_slab": 6,
    "minecraft:deepslate_brick_stairs": 6,
    "minecraft:deepslate_brick_wall": 6,
    "minecraft:deepslate_bricks": 6,
    "minecraft:deepslate_coal_ore": 6,
    "minecraft:deepslate_copper_ore": 6,
    "minecraft:deepslate_diamond_ore": 6,
    "minecraft:deepslate_emerald_ore": 6,
    "minecraft:deepslate_gold_ore": 6,
    "minecraft:deepslate_iron_ore": 6,
    "minecraft:deepslate_lapis_ore": 6,
    "minecraft:deepslate_redstone_ore": 6,
    "minecraft:deepslate_tile_double_slab": 6,
    "minecraft:deepslate_tile_slab": 6,
    "minecraft:deepslate_tile_stairs": 6,
    "minecraft:deepslate_tile_wall": 6,
    "minecraft:deepslate_tiles": 6,
    "minecraft:deepslate": 6,
    "minecraft:detector_rail": 6,
    "minecraft:diamond_block": 6,
    "minecraft:diamond_ore": 6,
    "minecraft:diorite_stairs": 6,
    "minecraft:diorite": 6,
    "minecraft:dispenser": 6,
    "minecraft:double_cut_copper_slab": 6,
    "minecraft:double_stone_block_slab": 6,
    "minecraft:double_stone_block_slab2": 6,
    "minecraft:double_stone_block_slab3": 6,
    "minecraft:double_stone_block_slab4": 6,
    "minecraft:dripstone_block": 6,
    "minecraft:dropper": 6,
    "minecraft:emerald_block": 6,
    "minecraft:emerald_ore": 6,
    "minecraft:enchanting_table": 6,
    "minecraft:end_brick_stairs": 6,
    "minecraft:end_bricks": 6,
    "minecraft:end_stone": 6,
    "minecraft:ender_chest": 6,
    "minecraft:exposed_chiseled_copper": 6,
    "minecraft:exposed_copper_bulb": 6,
    "minecraft:exposed_copper_door": 6,
    "minecraft:exposed_copper_grate": 6,
    "minecraft:exposed_copper_trapdoor": 6,
    "minecraft:exposed_copper": 6,
    "minecraft:exposed_cut_copper_slab": 6,
    "minecraft:exposed_cut_copper_stairs": 6,
    "minecraft:exposed_cut_copper": 6,
    "minecraft:exposed_double_cut_copper_slab": 6,
    "minecraft:furnace": 6,
    "minecraft:gilded_blackstone": 6,
    "minecraft:glowingobsidian": 2,
    "minecraft:gold_block": 6,
    "minecraft:gold_ore": 6,
    "minecraft:golden_rail": 6,
    "minecraft:granite_stairs": 6,
    "minecraft:granite": 6,
    "minecraft:gray_concrete": 6,
    "minecraft:gray_glazed_terracotta": 6,
    "minecraft:gray_shulker_box": 6,
    "minecraft:gray_terracotta": 6,
    "minecraft:green_concrete": 6,
    "minecraft:green_glazed_terracotta": 6,
    "minecraft:green_shulker_box": 6,
    "minecraft:green_terracotta": 6,
    "minecraft:grindstone": 6,
    "minecraft:hardened_clay": 6,
    "minecraft:heavy_weighted_pressure_plate": 6,
    "minecraft:hopper": 6,
    "minecraft:ice": 6,
    "minecraft:iron_bars": 6,
    "minecraft:iron_block": 6,
    "minecraft:iron_door": 6,
    "minecraft:iron_ore": 6,
    "minecraft:iron_trapdoor": 6,
    "minecraft:lantern": 6,
    "minecraft:lapis_block": 6,
    "minecraft:lapis_ore": 6,
    "minecraft:large_amethyst_bud": 6,
    "minecraft:light_blue_concrete": 6,
    "minecraft:light_blue_glazed_terracotta": 6,
    "minecraft:light_blue_shulker_box": 6,
    "minecraft:light_blue_terracotta": 6,
    "minecraft:light_gray_concrete": 6,
    "minecraft:light_gray_shulker_box": 6,
    "minecraft:light_gray_terracotta": 6,
    "minecraft:light_weighted_pressure_plate": 6,
    "minecraft:lightning_rod": 6,
    "minecraft:lime_concrete": 6,
    "minecraft:lime_glazed_terracotta": 6,
    "minecraft:lime_shulker_box": 6,
    "minecraft:lime_terracotta": 6,
    "minecraft:lit_blast_furnace": 6,
    "minecraft:lit_deepslate_redstone_ore": 6,
    "minecraft:lit_furnace": 6,
    "minecraft:lit_redstone_ore": 6,
    "minecraft:lit_smoker": 6,
    "minecraft:lodestone": 6,
    "minecraft:magenta_concrete": 6,
    "minecraft:magenta_glazed_terracotta": 6,
    "minecraft:magenta_shulker_box": 6,
    "minecraft:magenta_terracotta": 6,
    "minecraft:magma": 6,
    "minecraft:medium_amethyst_bud": 6,
    "minecraft:mob_spawner": 6,
    "minecraft:mossy_cobblestone_stairs": 6,
    "minecraft:mossy_cobblestone": 6,
    "minecraft:mossy_stone_brick_stairs": 6,
    "minecraft:mud_brick_double_slab": 6,
    "minecraft:mud_brick_slab": 6,
    "minecraft:mud_brick_stairs": 6,
    "minecraft:mud_brick_wall": 6,
    "minecraft:mud_bricks": 6,
    "minecraft:nether_brick_fence": 6,
    "minecraft:nether_brick_stairs": 6,
    "minecraft:nether_brick": 6,
    "minecraft:nether_gold_ore": 6,
    "minecraft:netherite_block": 6,
    "minecraft:netherrack": 6,
    "minecraft:normal_stone_stairs": 6,
    "minecraft:observer": 6,
    "minecraft:obsidian": 2,
    "minecraft:orange_concrete": 6,
    "minecraft:orange_glazed_terracotta": 6,
    "minecraft:orange_shulker_box": 6,
    "minecraft:orange_terracotta": 6,
    "minecraft:oxidized_chiseled_copper": 6,
    "minecraft:oxidized_copper_bulb": 6,
    "minecraft:oxidized_copper_door": 6,
    "minecraft:oxidized_copper_grate": 6,
    "minecraft:oxidized_copper_trapdoor": 6,
    "minecraft:oxidized_copper": 6,
    "minecraft:oxidized_cut_copper_slab": 6,
    "minecraft:oxidized_cut_copper_stairs": 6,
    "minecraft:oxidized_cut_copper": 6,
    "minecraft:oxidized_double_cut_copper_slab": 6,
    "minecraft:packed_ice": 6,
    "minecraft:packed_mud": 6,
    "minecraft:pink_concrete": 6,
    "minecraft:pink_glazed_terracotta": 6,
    "minecraft:pink_shulker_box": 6,
    "minecraft:pink_terracotta": 6,
    "minecraft:piston": 6,
    "minecraft:pointed_dripstone": 6,
    "minecraft:polished_andesite_stairs": 6,
    "minecraft:polished_andesite": 6,
    "minecraft:polished_basalt": 6,
    "minecraft:polished_blackstone_brick_double_slab": 6,
    "minecraft:polished_blackstone_brick_slab": 6,
    "minecraft:polished_blackstone_brick_stairs": 6,
    "minecraft:polished_blackstone_brick_wall": 6,
    "minecraft:polished_blackstone_bricks": 6,
    "minecraft:polished_blackstone_button": 6,
    "minecraft:polished_blackstone_double_slab": 6,
    "minecraft:polished_blackstone_pressure_plate": 6,
    "minecraft:polished_blackstone_slab": 6,
    "minecraft:polished_blackstone_stairs": 6,
    "minecraft:polished_blackstone_wall": 6,
    "minecraft:polished_blackstone": 6,
    "minecraft:polished_deepslate_double_slab": 6,
    "minecraft:polished_deepslate_slab": 6,
    "minecraft:polished_deepslate_stairs": 6,
    "minecraft:polished_deepslate_wall": 6,
    "minecraft:polished_deepslate": 6,
    "minecraft:polished_diorite_stairs": 6,
    "minecraft:polished_diorite": 6,
    "minecraft:polished_granite_stairs": 6,
    "minecraft:polished_granite": 6,
    "minecraft:polished_tuff_double_slab": 6,
    "minecraft:polished_tuff_slab": 6,
    "minecraft:polished_tuff_stairs": 6,
    "minecraft:polished_tuff_wall": 6,
    "minecraft:polished_tuff": 6,
    "minecraft:prismarine_bricks_stairs": 6,
    "minecraft:prismarine_stairs": 6,
    "minecraft:prismarine": 6,
    "minecraft:purple_concrete": 6,
    "minecraft:purple_glazed_terracotta": 6,
    "minecraft:purple_shulker_box": 6,
    "minecraft:purple_terracotta": 6,
    "minecraft:purpur_block": 6,
    "minecraft:purpur_stairs": 6,
    "minecraft:quartz_block": 6,
    "minecraft:quartz_bricks": 6,
    "minecraft:quartz_ore": 6,
    "minecraft:quartz_stairs": 6,
    "minecraft:rail": 6,
    "minecraft:raw_copper_block": 6,
    "minecraft:raw_gold_block": 6,
    "minecraft:raw_iron_block": 6,
    "minecraft:red_concrete": 6,
    "minecraft:red_glazed_terracotta": 6,
    "minecraft:red_nether_brick_stairs": 6,
    "minecraft:red_nether_brick": 6,
    "minecraft:red_sandstone_stairs": 6,
    "minecraft:red_sandstone": 6,
    "minecraft:red_shulker_box": 6,
    "minecraft:red_terracotta": 6,
    "minecraft:redstone_block": 6,
    "minecraft:redstone_ore": 6,
    "minecraft:respawn_anchor": 2,
    "minecraft:sandstone_stairs": 6,
    "minecraft:sandstone": 6,
    "minecraft:silver_glazed_terracotta": 6,
    "minecraft:small_amethyst_bud": 6,
    "minecraft:smoker": 6,
    "minecraft:smooth_basalt": 6,
    "minecraft:smooth_quartz_stairs": 6,
    "minecraft:smooth_red_sandstone_stairs": 6,
    "minecraft:smooth_sandstone_stairs": 6,
    "minecraft:smooth_stone": 6,
    "minecraft:soul_lantern": 6,
    "minecraft:sticky_piston": 6,
    "minecraft:stone_block_slab": 6,
    "minecraft:stone_block_slab2": 6,
    "minecraft:stone_block_slab3": 6,
    "minecraft:stone_block_slab4": 6,
    "minecraft:stone_brick_stairs": 6,
    "minecraft:stone_button": 6,
    "minecraft:stone_pressure_plate": 6,
    "minecraft:stone_stairs": 6,
    "minecraft:stone": 6,
    "minecraft:stonebrick": 6,
    "minecraft:stonecutter_block": 6,
    "minecraft:tuff_brick_double_slab": 6,
    "minecraft:tuff_brick_slab": 6,
    "minecraft:tuff_brick_stairs": 6,
    "minecraft:tuff_brick_wall": 6,
    "minecraft:tuff_bricks": 6,
    "minecraft:tuff_double_slab": 6,
    "minecraft:tuff_slab": 6,
    "minecraft:tuff_stairs": 6,
    "minecraft:tuff_wall": 6,
    "minecraft:tuff": 6,
    "minecraft:undyed_shulker_box": 6,
    "minecraft:warped_nylium": 6,
    "minecraft:waxed_chiseled_copper": 6,
    "minecraft:waxed_copper_bulb": 6,
    "minecraft:waxed_copper_door": 6,
    "minecraft:waxed_copper_grate": 6,
    "minecraft:waxed_copper_trapdoor": 6,
    "minecraft:waxed_copper": 6,
    "minecraft:waxed_cut_copper_slab": 6,
    "minecraft:waxed_cut_copper_stairs": 6,
    "minecraft:waxed_cut_copper": 6,
    "minecraft:waxed_double_cut_copper_slab": 6,
    "minecraft:waxed_exposed_chiseled_copper": 6,
    "minecraft:waxed_exposed_copper_bulb": 6,
    "minecraft:waxed_exposed_copper_door": 6,
    "minecraft:waxed_exposed_copper_grate": 6,
    "minecraft:waxed_exposed_copper_trapdoor": 6,
    "minecraft:waxed_exposed_copper": 6,
    "minecraft:waxed_exposed_cut_copper_slab": 6,
    "minecraft:waxed_exposed_cut_copper_stairs": 6,
    "minecraft:waxed_exposed_cut_copper": 6,
    "minecraft:waxed_exposed_double_cut_copper_slab": 6,
    "minecraft:waxed_oxidized_chiseled_copper": 6,
    "minecraft:waxed_oxidized_copper_bulb": 6,
    "minecraft:waxed_oxidized_copper_door": 6,
    "minecraft:waxed_oxidized_copper_grate": 6,
    "minecraft:waxed_oxidized_copper_trapdoor": 6,
    "minecraft:waxed_oxidized_copper": 6,
    "minecraft:waxed_oxidized_cut_copper_slab": 6,
    "minecraft:waxed_oxidized_cut_copper_stairs": 6,
    "minecraft:waxed_oxidized_cut_copper": 6,
    "minecraft:waxed_oxidized_double_cut_copper_slab": 6,
    "minecraft:waxed_weathered_chiseled_copper": 6,
    "minecraft:waxed_weathered_copper_bulb": 6,
    "minecraft:waxed_weathered_copper_door": 6,
    "minecraft:waxed_weathered_copper_grate": 6,
    "minecraft:waxed_weathered_copper_trapdoor": 6,
    "minecraft:waxed_weathered_copper": 6,
    "minecraft:waxed_weathered_cut_copper_slab": 6,
    "minecraft:waxed_weathered_cut_copper_stairs": 6,
    "minecraft:waxed_weathered_cut_copper": 6,
    "minecraft:waxed_weathered_double_cut_copper_slab": 6,
    "minecraft:weathered_chiseled_copper": 6,
    "minecraft:weathered_copper_bulb": 6,
    "minecraft:weathered_copper_door": 6,
    "minecraft:weathered_copper_grate": 6,
    "minecraft:weathered_copper_trapdoor": 6,
    "minecraft:weathered_copper": 6,
    "minecraft:weathered_cut_copper_slab": 6,
    "minecraft:weathered_cut_copper_stairs": 6,
    "minecraft:weathered_cut_copper": 6,
    "minecraft:weathered_double_cut_copper_slab": 6,
    "minecraft:white_concrete": 6,
    "minecraft:white_glazed_terracotta": 6,
    "minecraft:white_shulker_box": 6,
    "minecraft:white_terracotta": 6,
    "minecraft:yellow_concrete": 6,
    "minecraft:yellow_glazed_terracotta": 6,
    "minecraft:yellow_shulker_box": 6,
    "minecraft:yellow_terracotta": 6
};

const PICKAXE_BLOCKS = new Set(Object.keys(PICKAXE_BLOCK_SPEED));

function isProtectedId(id) {
    return (
        id === "minecraft:bedrock" ||
        id === "minecraft:end_portal" ||
        id === "minecraft:end_portal_frame" ||
        id === "minecraft:nether_portal" ||
        id === "minecraft:command_block" ||
        id === "minecraft:repeating_command_block" ||
        id === "minecraft:chain_command_block" ||
        id === "minecraft:barrier" ||
        id === "minecraft:reinforced_deepslate"
    );
}

function isLiquidId(id) {
    return (
        id === "minecraft:water" ||
        id === "minecraft:flowing_water" ||
        id === "minecraft:lava" ||
        id === "minecraft:flowing_lava"
    );
}

function isPickaxeMineable(id) {
    if (!id) return false;
    if (isProtectedId(id) || isLiquidId(id)) return false;
    return PICKAXE_BLOCKS.has(id);
}

pt.afterEvents.playerBreakBlock.subscribe((ev) => {
    const player = ev.player;
    const block = ev.block;

    try {
        if (!player || !block) return;

        const cont = player.getComponent("minecraft:inventory")?.container;
        const held = cont?.getItem(player.selectedSlotIndex);
        if (!held || held.typeId !== PICK_ID) return;

        try {
            if (typeof player.getGameMode === "function" && player.getGameMode() === "creative") return;
        } catch { }

        if (cooldown.has(player.id)) return;
        cooldown.add(player.id);
        ut.runTimeout(() => cooldown.delete(player.id), 1);

        const dir = determineCarveDirection(player, block);
        const removed = carve3x3(block.dimension, block.location.x, block.location.y, block.location.z, dir);
        const extraUses = Math.max(0, Math.ceil((removed - 1) / 3));
        if (extraUses > 0) __damageHeldItem(player, extraUses);

    } catch (err) {
        console.warn("Vampire Pickaxe Error:", err);
        cooldown.delete(player.id);
    }
});

function carve3x3(dim, x, y, z, dir) {
    const offs = [-1, 0, 1];
    let removed = 0;

    function tryBreak(bx, by, bz) {
        const b = dim.getBlock({ x: bx, y: by, z: bz });
        if (!b || b.isAir) return;

        const id = (b.typeId || b.permutation?.type?.id || "");
        if (!isPickaxeMineable(id)) return;

        dim.runCommandAsync(`setblock ${bx} ${by} ${bz} air destroy`);
        removed++;
    }

    if (dir === "up" || dir === "down") {
        for (const dx of offs) for (const dz of offs) {
            tryBreak(x + dx, y, z + dz);
        }
    } else {
        const perpIsX = (dir === "north" || dir === "south");
        for (const dy of offs) for (const dp of offs) {
            const bx = perpIsX ? x + dp : x;
            const by = y + dy;
            const bz = perpIsX ? z : z + dp;
            tryBreak(bx, by, bz);
        }
    }
    return removed;
}
import { world as __wd } from "@minecraft/server";
function __damageHeldItem(__p, __uses = 1) {
    try {
        const __invComp = __p.getComponent("minecraft:inventory");
        const __inv = __invComp && __invComp.container;
        if (!__inv) return;

        const __slot = __p.selectedSlotIndex;
        const __item = __inv.getItem(__slot);
        if (!__item) return;
        try {
            if (typeof __p.getGameMode === "function") {
                const gm = __p.getGameMode();
                if (gm === "creative") return;
            }
        } catch (_) { }
        const __dur = __item.getComponent && __item.getComponent("minecraft:durability");
        if (!__dur) return;
        let __eff = __uses;
        try {
            const __ench = __item.getComponent && __item.getComponent("minecraft:enchantments");
            const lvl = __ench && __ench.enchantments && __ench.enchantments.getEnchantment
                ? (__ench.enchantments.getEnchantment("unbreaking")?.level || 0)
                : 0;
            if (lvl > 0) {
                let applied = 0;
                for (let k = 0; k < __uses; k++) {
                    if (Math.random() < 1 / (lvl + 1)) applied++;
                }
                __eff = applied;
            }
        } catch (_) { }

        if (__eff <= 0) return;

        __dur.damage = (__dur.damage || 0) + __eff;

        if (__dur.damage >= __dur.maxDurability) {
            __inv.setItem(__slot, undefined);
            __p.runCommandAsync("playsound random.break @s");
        } else {
            __inv.setItem(__slot, __item);
        }
    } catch (_) { }
}
const __CUSTOM_TOOLS = new Set([
    "nc_werewolf_morph:vampire_sword",
    "nc_werewolf_morph:werewolf_sword",
    "nc_werewolf_morph:vampire_pickaxe",
    "nc_werewolf_morph:werewolf_pickaxe",
    "nc_werewolf_morph:vampire_axe",
    "nc_werewolf_morph:werewolf_axe",
    "nc_werewolf_morph:vampire_shovel",
    "nc_werewolf_morph:werewolf_shovel",
    "nc_werewolf_morph:vampire_hoe",
    "nc_werewolf_morph:werewolf_hoe",
]);
__wd.afterEvents.playerBreakBlock.subscribe((ev) => {
    try {
        const p = ev.player;
        if (!p) return;
        const heldId =
            (ev.itemStackBeforeBreak && ev.itemStackBeforeBreak.typeId) ||
            (p.getComponent("minecraft:inventory")?.container?.getItem(p.selectedSlotIndex)?.typeId);

        if (!heldId || !__CUSTOM_TOOLS.has(heldId)) return;

        __damageHeldItem(p, 1);
    } catch (_) { }
});
import {
    world as Oe,
    system as vt,
    EquipmentSlot as ce,
} from "@minecraft/server";
var me = [
    "nc_werewolf_morph:werewolf_armor_helmet",
    "nc_werewolf_morph:werewolf_armor_chestplate",
    "nc_werewolf_morph:werewolf_armor_leggings",
    "nc_werewolf_morph:werewolf_armor_boots",
],
    Q = new Map(),
    Z = new Map(),
    yt = 5,
    ze = 5,
    At = ze * 20;
function Be(e) {
    let t = e.getComponent("minecraft:equippable");
    return t
        ? t.getEquipment(ce.Head)?.typeId === me[0] &&
        t.getEquipment(ce.Chest)?.typeId === me[1] &&
        t.getEquipment(ce.Legs)?.typeId === me[2] &&
        t.getEquipment(ce.Feet)?.typeId === me[3]
        : !1;
}
Oe.afterEvents.entityHitEntity.subscribe((e) => {
    let { damagingEntity: t } = e;
    if (!t || t.typeId !== "minecraft:player") return;
    let r = t,
        s = r.id;
    if (!Be(r)) return;
    let c = Q.get(s) ?? 0,
        a = Math.min(c + 1, yt);
    Q.set(s, a),
        Z.set(s, ze),
        r.addEffect("strength", At, { amplifier: a - 1, showParticles: !1 });
});
vt.runInterval(() => {
    for (let e of Oe.getPlayers()) {
        let t = e.id;
        if (!Be(e)) {
            Q.has(t) && (e.removeEffect("strength"), Q.delete(t), Z.delete(t));
            continue;
        }
        let r = Z.get(t);
        if (r === void 0) continue;
        let s = r - 1;
        Z.set(t, s),
            s <= 0 && (e.removeEffect("strength"), Q.delete(t), Z.delete(t));
    }
}, 20);
import {
    world as kt,
    system as Et,
    EquipmentSlot as fe,
} from "@minecraft/server";
var le = [
    "nc_werewolf_morph:werewolf_armor_helmet_2",
    "nc_werewolf_morph:werewolf_armor_chestplate_2",
    "nc_werewolf_morph:werewolf_armor_leggings_2",
    "nc_werewolf_morph:werewolf_armor_boots_2",
],
    _e = new Map(),
    j = "nc_werewolf_morph:werewolf_armor_full";
function Ct(e) {
    let t = e.getComponent("minecraft:equippable");
    return t
        ? t.getEquipment(fe.Head)?.typeId === le[0] &&
        t.getEquipment(fe.Chest)?.typeId === le[1] &&
        t.getEquipment(fe.Legs)?.typeId === le[2] &&
        t.getEquipment(fe.Feet)?.typeId === le[3]
        : !1;
}
const xpSidebarState = new Map();
const morphBuffState = new Map();

Et.runInterval(() => {
    for (let e of kt.getPlayers()) {
        try {
            let id = e.id;
            if (!Ct(e)) {
                if (morphBuffState.get(id)) {
                    e.removeEffect("strength");
                    e.removeEffect("speed");
                    e.removeTag(j);
                    morphBuffState.delete(id);
                }
                if (e.hasTag(j)) e.removeTag(j);
            } else {
                if (!morphBuffState.get(id)) {
                    e.addEffect("strength", 200000, { amplifier: 0, showParticles: false });
                    e.addEffect("speed", 200000, { amplifier: 0, showParticles: false });
                    e.addTag(j);
                    morphBuffState.set(id, true);
                } else if (!e.hasTag(j)) {
                    e.addTag(j);
                }
            }
            const wantsXP = !e.hasTag("disable_xp_display");
            const xpState = xpSidebarState.get(id);
            if (xpState !== wantsXP) {
                if (!wantsXP) {
                    e.onScreenDisplay.setActionBar("");
                }
                xpSidebarState.set(id, wantsXP);
            }

        } catch (err) {
            console.warn("Error processing player:", err);
        }
    }
}, 20);
import { world as It, system as sys } from "@minecraft/server";
var de = {
    AXE: {
        id: "nc_werewolf_morph:werewolf_axe",
        smeltables: {
            "minecraft:oak_log": "minecraft:charcoal",
            "minecraft:spruce_log": "minecraft:charcoal",
            "minecraft:birch_log": "minecraft:charcoal",
            "minecraft:jungle_log": "minecraft:charcoal",
            "minecraft:acacia_log": "minecraft:charcoal",
            "minecraft:dark_oak_log": "minecraft:charcoal",
            "minecraft:mangrove_log": "minecraft:charcoal",
            "minecraft:cherry_log": "minecraft:charcoal",
            "minecraft:crimson_stem": "minecraft:charcoal",
            "minecraft:warped_stem": "minecraft:charcoal",
            "minecraft:stripped_oak_log": "minecraft:charcoal",
            "minecraft:stripped_spruce_log": "minecraft:charcoal",
            "minecraft:stripped_birch_log": "minecraft:charcoal",
            "minecraft:stripped_jungle_log": "minecraft:charcoal",
            "minecraft:stripped_acacia_log": "minecraft:charcoal",
            "minecraft:stripped_dark_oak_log": "minecraft:charcoal",
            "minecraft:stripped_mangrove_log": "minecraft:charcoal",
            "minecraft:stripped_cherry_log": "minecraft:charcoal",
            "minecraft:stripped_crimson_stem": "minecraft:charcoal",
            "minecraft:stripped_warped_stem": "minecraft:charcoal",
        },
    },
    PICKAXE: {
        id: "nc_werewolf_morph:werewolf_pickaxe",
        smeltables: {
            "minecraft:iron_ore": "minecraft:iron_ingot",
            "minecraft:gold_ore": "minecraft:gold_ingot",
            "minecraft:copper_ore": "minecraft:copper_ingot",
            "minecraft:deepslate_iron_ore": "minecraft:iron_ingot",
            "minecraft:deepslate_gold_ore": "minecraft:gold_ingot",
            "minecraft:deepslate_copper_ore": "minecraft:copper_ingot",
            "minecraft:raw_iron_block": "minecraft:iron_ingot",
            "minecraft:raw_gold_block": "minecraft:gold_ingot",
            "minecraft:raw_copper_block": "minecraft:copper_ingot",
            "minecraft:raw_iron": "minecraft:iron_ingot",
            "minecraft:raw_gold": "minecraft:gold_ingot",
            "minecraft:raw_copper": "minecraft:copper_ingot",
        },
    },
};
function breakSoundFor(blockId) {
    if (
        blockId.includes("_log") ||
        blockId.includes("_stem") ||
        blockId.includes("wood")
    ) {
        return "block.wood.break";
    }
    return "block.stone.break";
}
function lootPathFor(outId) {
    return `nitric_concepts/werewolf_morph/as/${outId.replace(/:/g, "_")}`;
}

It.beforeEvents.playerBreakBlock.subscribe((e) => {
    const player = e.player;
    const inv = player.getComponent("minecraft:inventory")?.container;
    if (!inv) return;

    const blockId = e.block.permutation.type.id;
    if (!blockId) return;

    const held = inv.getItem(player.selectedSlotIndex);
    if (!held) return;

    let outId;
    if (held.typeId === de.AXE.id) {
        outId = de.AXE.smeltables[blockId];
    } else if (held.typeId === de.PICKAXE.id) {
        outId = de.PICKAXE.smeltables[blockId];
    } else {
        return;
    }
    try {
        if (typeof player.getGameMode === "function" && player.getGameMode() === "creative") return;
    } catch { }
    if (!outId) return;
    e.cancel = true;

    const { x, y, z } = e.block.location;
    const dropPos = `${x + 0.5} ${y + 0.5} ${z + 0.5}`;
    player.runCommandAsync(`setblock ${x} ${y} ${z} air replace`);
    player.runCommandAsync(`playsound ${breakSoundFor(blockId)} @a[r=16] ${x} ${y} ${z}`);
    player.runCommandAsync(`loot spawn ${dropPos} loot "${lootPathFor(outId)}"`);
    const slot = player.selectedSlotIndex;
    const toolId = held.typeId;
    sys.runTimeout(() => {
        try {
            const c = player.getComponent("minecraft:inventory")?.container;
            const cur = c?.getItem(slot);
            if (cur && cur.typeId === toolId) {
                __damageHeldItem(player, 1);
            }
        } catch { }
    }, 1);
});

import { world as Tt, system as xt } from "@minecraft/server";

const VAMP_HOE_ID = "nc_werewolf_morph:vampire_hoe";
const VAMP_HOE_CD = new Set();

function canTillId(id) {
    return (
        id === "minecraft:dirt" ||
        id === "minecraft:grass_block" ||
        id === "minecraft:dirt_path" ||
        id === "minecraft:grass_path"
    );
}


const VAMP_AXE_ID = "nc_werewolf_morph:vampire_axe";
const WOLF_AXE_ID = "nc_werewolf_morph:werewolf_axe";
const AXE_STRIP_CD = new Set();
const AXE_STRIPPABLE_SUFFIXES = ["_log", "_wood", "_stem", "_hyphae", "_block"];

function axeSplitId(blockId) {
    const i = blockId.indexOf(":");
    if (i === -1) return { ns: "minecraft", name: blockId };
    return { ns: blockId.slice(0, i), name: blockId.slice(i + 1) };
}
function axeJoinId(ns, name) {
    return ns + ":" + name;
}
function axeHasAnySuffix(name, arr) {
    return arr.some((s) => name.endsWith(s));
}
function axeStrippedTarget(blockId) {
    const { ns, name } = axeSplitId(blockId);
    if (!name) return null;
    if (name.startsWith("stripped_")) return null;
    if (!axeHasAnySuffix(name, AXE_STRIPPABLE_SUFFIXES)) return null;
    return axeJoinId(ns, "stripped_" + name);
}
function axeUnwaxTarget(blockId) {
    const { ns, name } = axeSplitId(blockId);
    if (!name.startsWith("waxed_")) return null;
    return axeJoinId(ns, name.replace(/^waxed_/, ""));
}
function axeScrapedCopperTarget(blockId) {
    const { ns, name } = axeSplitId(blockId);
    if (name.startsWith("waxed_")) return null;

    if (name.startsWith("oxidized_")) {
        return axeJoinId(ns, name.replace(/^oxidized_/, "weathered_"));
    }
    if (name.startsWith("weathered_")) {
        return axeJoinId(ns, name.replace(/^weathered_/, "exposed_"));
    }
    if (name.startsWith("exposed_")) {
        return axeJoinId(ns, name.replace(/^exposed_/, ""));
    }
    return null;
}
async function handleCustomAxeInteract(ev) {
    const player = ev.player;
    const block = ev.block;
    const item = ev.itemStack;
    if (!player || !block || !item) return;

    try {
        if (typeof player.getGameMode === "function" && player.getGameMode() === "creative") return;
    } catch { }
    if (AXE_STRIP_CD.has(player.id)) return;
    AXE_STRIP_CD.add(player.id);
    xt.runTimeout(() => AXE_STRIP_CD.delete(player.id), 2);

    const dim = block.dimension;
    const pos = block.location;
    const blockId = block.permutation?.type?.id ?? "";
    if (!blockId) return;

    const tu = axeUnwaxTarget(blockId);
    const ts = axeStrippedTarget(blockId);
    const tr = axeScrapedCopperTarget(blockId);
    const targetId = tu || ts || tr;
    if (!targetId) return;

    ev.cancel = true;

    let changed = false;
    try {
        if (typeof block.setType === "function") {
            block.setType(targetId);
            changed = true;
        } else if (typeof block.setPermutation === "function") {
            block.setPermutation(BlockPermutation.resolve(targetId));
            changed = true;
        }
    } catch { }

    if (!changed) {
        try {
            await dim.runCommandAsync(
                `setblock ${pos.x} ${pos.y} ${pos.z} ${targetId}`
            );
            changed = true;
        } catch { }
    }

    if (!changed) return;

    const sound = tu
        ? "item.axe.wax_off"
        : ts
            ? "item.axe.strip"
            : "item.axe.scrape";

    try {
        await dim.runCommandAsync(
            `playsound ${sound} @a[r=16] ${pos.x + 0.5} ${pos.y + 0.5} ${pos.z + 0.5}`
        );
    } catch { }
    try {
        __damageHeldItem(player, 1);
    } catch { }
}
Tt.beforeEvents.playerInteractWithBlock.subscribe(async (e) => {
    const item = e.itemStack;
    const block = e.block;
    const player = e.player;
    if (!item || !player || !block) return;
    if (item.typeId === VAMP_HOE_ID) {
        try {
            if (typeof player.getGameMode === "function" && player.getGameMode() === "creative") return;
        } catch { }

        if (VAMP_HOE_CD.has(player.id)) return;
        VAMP_HOE_CD.add(player.id);
        xt.runTimeout(() => VAMP_HOE_CD.delete(player.id), 3);

        const dim = player.dimension;
        const { x, y, z } = block.location;

        let changed = 0;
        for (let dx = -1; dx <= 1; dx++) {
            for (let dz = -1; dz <= 1; dz++) {
                const bx = x + dx, by = y, bz = z + dz;
                const b = dim.getBlock({ x: bx, y: by, z: bz });
                if (!b) continue;

                const id = b.permutation?.type?.id ?? "";
                if (!canTillId(id)) continue;

                const above = dim.getBlock({ x: bx, y: by + 1, z: bz });
                if (above && !above.isAir) {
                    try { await dim.runCommandAsync(`setblock ${bx} ${by + 1} ${bz} air destroy`); } catch { }
                }

                const still = dim.getBlock({ x: bx, y: by, z: bz });
                const stillId = still?.permutation?.type?.id ?? "";
                if (!stillId || !canTillId(stillId)) continue;

                try {
                    await dim.runCommandAsync(`setblock ${bx} ${by} ${bz} minecraft:farmland`);
                    changed++;
                } catch { }
            }
        }

        e.cancel = true;

        if (changed > 0) {
            try { player.runCommandAsync("playsound block.dirt.turn_to_farmland @s ~ ~ ~"); } catch { }
            const cost = Math.max(1, changed);
            try { __damageHeldItem(player, cost); } catch { }
        }
        return;
    }
    if (item.typeId === VAMP_AXE_ID || item.typeId === WOLF_AXE_ID) {
        await handleCustomAxeInteract(e);
        return;
    }
});



import { world as Re, system as xtd } from "@minecraft/server";
const WOLF_HOE_ID = "nc_werewolf_morph:werewolf_hoe";
const EXTRA_CROP_LOOT = {
    "minecraft:wheat": "nitric_concepts/werewolf_morph/as/wheat_extra",
    "minecraft:carrots": "nitric_concepts/werewolf_morph/as/carrots_extra",
    "minecraft:potatoes": "nitric_concepts/werewolf_morph/as/potatoes_extra",
    "minecraft:beetroot": "nitric_concepts/werewolf_morph/as/beetroots_extra",
    "minecraft:nether_wart": "nitric_concepts/werewolf_morph/as/nether_wart_extra",
    "minecraft:melon_block": "nitric_concepts/werewolf_morph/as/melon_extra",
    "minecraft:pumpkin": "nitric_concepts/werewolf_morph/as/pumpkin_extra",
};

const CROP_MATURE_STATE = {
    "minecraft:wheat": { key: "growth", value: 7 },
    "minecraft:carrots": { key: "growth", value: 7 },
    "minecraft:potatoes": { key: "growth", value: 7 },
    "minecraft:beetroot": { key: "growth", value: 7 },
    "minecraft:nether_wart": { key: "age", value: 3 },
    "minecraft:melon_block": null,
    "minecraft:pumpkin": null,
};

Re.afterEvents.playerBreakBlock.subscribe(async (ev) => {
    const { player, itemStackBeforeBreak, brokenBlockPermutation, block, dimension } = ev;
    if (!player || !itemStackBeforeBreak || !brokenBlockPermutation) {
        return;
    }
    if (itemStackBeforeBreak.typeId !== WOLF_HOE_ID) {
        return;
    }
    const typeId = brokenBlockPermutation.type.id;
    if (!typeId) return;

    const lootPath = EXTRA_CROP_LOOT[typeId];
    if (!lootPath) return;

    const cfg = CROP_MATURE_STATE[typeId];
    if (cfg !== null) {
        if (!cfg) {
            return;
        }

        let stage;
        try {
            stage = brokenBlockPermutation.getState(cfg.key);
        } catch (err) {
            return;
        }

        if (stage !== cfg.value) {
            return;
        }
    }
    const { x, y, z } = block.location;
    try {
        await dimension.runCommandAsync(
            `loot spawn ${x + 0.5} ${y + 0.5} ${z + 0.5} loot "${lootPath}"`
        );
    } catch (err) {
        console.warn(`[WerewolfHoe] loot spawn failed for ${lootPath}:`, err);
    }
});


Re.beforeEvents.playerInteractWithBlock.subscribe(async (e) => {
    let { itemStack: t, block: r, player: s } = e;
    if (!t || t.typeId !== "nc_werewolf_morph:werewolf_hoe") return;
    let { x: c, y: a, z: f } = r.location,
        m = r.permutation.type.id;
    (m === "minecraft:dirt" || m === "minecraft:grass_block") &&
        ((e.cancel = !0),
            await s.dimension.runCommandAsync(
                `setblock ${c} ${a} ${f} minecraft:farmland`,
            ),
            await s.dimension.runCommandAsync(`setblock ${c} ${a + 1} ${f} air`),
            s.runCommandAsync("playsound block.dirt.turn_to_farmland @s ~ ~ ~"));
    __damageHeldItem(s, 1);
});
import { world as St } from "@minecraft/server";
var $t = "nc_werewolf_morph:werewolf_shovel",
    Dt = new Set([
        "minecraft:dirt",
        "minecraft:coarse_dirt",
        "minecraft:rooted_dirt",
        "minecraft:grass_block",
        "minecraft:podzol",
        "minecraft:mycelium",
        "minecraft:dirt_path",
        "minecraft:grass_path",
        "minecraft:farmland",
        "minecraft:mud",
        "minecraft:sand",
        "minecraft:red_sand",
        "minecraft:gravel",
        "minecraft:clay",
        "minecraft:soul_sand",
        "minecraft:soul_soil",
        "minecraft:snow",
        "minecraft:snow_block",
        "minecraft:white_concrete_powder",
        "minecraft:light_gray_concrete_powder",
        "minecraft:gray_concrete_powder",
        "minecraft:black_concrete_powder",
        "minecraft:brown_concrete_powder",
        "minecraft:red_concrete_powder",
        "minecraft:orange_concrete_powder",
        "minecraft:yellow_concrete_powder",
        "minecraft:lime_concrete_powder",
        "minecraft:green_concrete_powder",
        "minecraft:cyan_concrete_powder",
        "minecraft:light_blue_concrete_powder",
        "minecraft:blue_concrete_powder",
        "minecraft:purple_concrete_powder",
        "minecraft:magenta_concrete_powder",
        "minecraft:pink_concrete_powder",
    ]);
St.afterEvents.playerBreakBlock.subscribe(async (e) => {
    const s = e.itemStackBeforeBreak;
    const p = e.player;
    if (!s || s.typeId !== $t || !p) return;
    try {
        if (typeof p.getGameMode === "function" && p.getGameMode() === "creative") return;
    } catch (_) { }
    const brokenId = e.brokenBlockPermutation?.type?.id;
    if (!brokenId || !Dt.has(brokenId)) return;
    const dim = e.dimension;
    const loc = e.block.location;
    const x = loc.x, y = loc.y, z = loc.z;
    const neighbors = [
        { dx: 1, dz: 0 },
        { dx: -1, dz: 0 },
        { dx: 0, dz: 1 },
        { dx: 0, dz: -1 },
    ];

    let broken = 0;
    for (const { dx, dz } of neighbors) {
        const bx = x + dx, by = y, bz = z + dz;
        const b = dim.getBlock({ x: bx, y: by, z: bz });
        if (!b || b.isAir) continue;
        const id = (b.permutation && b.permutation.type && b.permutation.type.id) || "";
        if (!Dt.has(id)) continue;
        try {
            await dim.runCommandAsync(`fill ${bx} ${by} ${bz} ${bx} ${by} ${bz} air destroy`);
            broken++;
        } catch (_) { }
    }
    if (broken > 0) {
        try { __damageHeldItem(p, broken); } catch (_) { }
    }
});
const MELEE_WEAPONS = new Set([
    "nc_werewolf_morph:vampire_dagger",
    "nc_werewolf_morph:vampire_sword",
    "nc_werewolf_morph:werewolf_sword",
]);
const SWING_INTENT_TAG = "wm:recent_melee_swing";
const SWING_INTENT_TICKS = 6;

const BASIC_ATTACK_DEBOUNCE_TAG = "wm:attack_anim_cd";
const BASIC_ATTACK_DEBOUNCE_TICKS = 6;

x.afterEvents.itemUse.subscribe((ev) => {
    const p = ev.source;
    const item = ev.itemStack;
    if (!(p instanceof we) || !item) return;
    if (!MELEE_WEAPONS.has(item.typeId)) return;

    if (!p.hasTag(SWING_INTENT_TAG)) {
        p.addTag(SWING_INTENT_TAG);
        B.runTimeout(() => p.removeTag(SWING_INTENT_TAG), SWING_INTENT_TICKS);
    }
});
import { world as Ot } from "@minecraft/server";
var zt = "nc_werewolf_morph:vampire_shovel",
    Bt = new Set([
        "minecraft:dirt",
        "minecraft:coarse_dirt",
        "minecraft:rooted_dirt",
        "minecraft:grass_block",
        "minecraft:podzol",
        "minecraft:mycelium",
        "minecraft:dirt_path",
        "minecraft:grass_path",
        "minecraft:farmland",
        "minecraft:mud",
        "minecraft:sand",
        "minecraft:red_sand",
        "minecraft:gravel",
        "minecraft:clay",
        "minecraft:soul_sand",
        "minecraft:soul_soil",
        "minecraft:snow",
        "minecraft:snow_block",
        "minecraft:white_concrete_powder",
        "minecraft:light_gray_concrete_powder",
        "minecraft:gray_concrete_powder",
        "minecraft:black_concrete_powder",
        "minecraft:brown_concrete_powder",
        "minecraft:red_concrete_powder",
        "minecraft:orange_concrete_powder",
        "minecraft:yellow_concrete_powder",
        "minecraft:lime_concrete_powder",
        "minecraft:green_concrete_powder",
        "minecraft:cyan_concrete_powder",
        "minecraft:light_blue_concrete_powder",
        "minecraft:blue_concrete_powder",
        "minecraft:purple_concrete_powder",
        "minecraft:magenta_concrete_powder",
        "minecraft:pink_concrete_powder",
    ]);

function Rt(e) {
    return Math.random() < e;
}
Ot.afterEvents.playerBreakBlock.subscribe(async (ev) => {
    const itemBefore = ev.itemStackBeforeBreak;
    if (!itemBefore || itemBefore.typeId !== zt) return;

    const brokenId = ev.brokenBlockPermutation?.type?.id;
    if (!Bt.has(brokenId)) return;

    if (!Rt(0.2)) return;

    const { x, y, z } = ev.block.location;
    try {
        await ev.dimension.runCommandAsync(
            `loot spawn ${x + 0.5} ${y + 0.5} ${z + 0.5} loot "nitric_concepts/werewolf_morph/vampire"`
        );
    } catch (_) { /* ignore */ }
});
const FORBIDDEN_DROP_IDS = new Set([
    "nc_werewolf_morph:vampire_morph",
    "nc_werewolf_morph:werewolf_morph",
]);
var We;
((c) => {
    c.init = () => {
        let a = new Map();
        x.afterEvents.entityDie.subscribe((o) => {
            let i = o.damageSource?.damagingEntity;
            if (!(i instanceof we)) return;
            let w = i.getComponent("minecraft:inventory");
            if (!w) return;
            let _ = w.container,
                u = i.selectedSlotIndex,
                g = _.getItem(u);
            g &&
                g.typeId === "nc_werewolf_morph:vampire_dagger" &&
                i.runCommandAsync("effect @s regeneration 4 1 true");
        });
        function f(o) {
            let i = a.get(o);
            if (!i) return;
            x
                .getDimension(i.dimensionId)
                .runCommandAsync(`setblock ${i.x} ${i.y} ${i.z} air`),
                a.delete(o);
        }
        x.afterEvents.entityDie.subscribe((o) => {
            let i = o.deadEntity.id;
            f(i);
        }),

            x.afterEvents.entityRemove.subscribe((o) => {
                f(o.removedEntityId);
            }),
            x.afterEvents.entityDie.subscribe((ev) => {
                const dead = ev.deadEntity;
                if (!(dead instanceof we)) return;

                const dim = dead.dimension;
                const deathPos = dead.location;
                B.runTimeout(() => {
                    try {
                        const nearbyItems = dim.getEntities({
                            type: "item",
                            location: deathPos,
                            maxDistance: 3,
                        });

                        for (const ent of nearbyItems) {
                            try {
                                const itemComp = ent.getComponent("minecraft:item");
                                const stack = itemComp && itemComp.itemStack;
                                if (!stack) continue;

                                if (FORBIDDEN_DROP_IDS.has(stack.typeId)) {
                                    ent.remove();
                                }
                            } catch (errInner) {
                            }
                        }
                    } catch (errOuter) {
                    }
                }, 2);
            });
        function playMorphAttackAnim(p) {
            if (p.hasTag("nc_werewolf_morph:attack_sound")) return;
            p.addTag("nc_werewolf_morph:attack_sound");
            let random_1 = Math.random() * 1e3 << 0 // Essential
            let random_2 = Math.random() * 1e3 << 0 // Essential
            let random_3 = Math.random() * 1e3 << 0 // Essential
            p.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = '${p.name}'; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

            p.addTag("nc_werewolf_morph:attack_sound"),
                p.hasTag("nc_werewolf_morph:werewolf_tag")
                    ? (p.runCommandAsync(
                        "playanimation @s animation.nc_werewolf_morph.werewolf_attack",
                    ),
                        p.runCommandAsync(
                            "playsound nc_werewolf_morph:p_werewolf_attack @a[r=20]",
                        ),
                        B.runTimeout(() => {
                            p.runCommandAsync(
                                "playanimation @s animation.nitric_morph.player.player_invisible_v1",
                            );
                        }, 2))
                    : p.hasTag("nc_werewolf_morph:vampire_tag") &&
                    (p.runCommandAsync(
                        "playanimation @s animation.nc_werewolf_morph.vampire_attack",
                    ),
                        p.runCommandAsync(
                            "playsound nc_werewolf_morph:p_vampire_attack @a[r=20]",
                        ),
                        B.runTimeout(() => {
                            p.runCommandAsync(
                                "playanimation @s animation.nitric_morph.player.player_invisible_v1",
                            );
                        }, 2)),
                B.runTimeout(() => {
                    p.removeTag("nc_werewolf_morph:attack_sound");
                    p.playAnimation('animation.nc_werewolf_morph.transfer_data', { controller: "__animation.nc_werewolf_morph.data_transfer.empty_send_data__", stopExpression: `t.player_name = ''; v.__random_1__=${random_1};v.__random_2__=${random_2};v.__random_3__=${random_3}; t.variable_transfer=${1}; return 0;` });

                }, 24);
        }
        const MELEE_CAUSES = new Set(["entity_attack", "player_attack", "mob_attack"]);
        x.afterEvents.entityHitEntity.subscribe((ev) => {
            const attacker = ev.damagingEntity;
            const target = ev.hitEntity;
            if (!(attacker instanceof we)) return;
            const isMorphed =
                attacker.hasTag("nc_werewolf_morph:werewolf_tag") ||
                attacker.hasTag("nc_werewolf_morph:vampire_tag") ||
                attacker.hasTag("nc_werewolf_morph:bat_tag");

            if (isMorphed) {
                if (
                    !attacker.hasTag("stomp_self") &&
                    !attacker.hasTag("FrenzyMaster") &&
                    !attacker.hasTag(BASIC_ATTACK_DEBOUNCE_TAG)
                ) {
                    attacker.addTag(BASIC_ATTACK_DEBOUNCE_TAG);
                    B.runTimeout(() => attacker.removeTag(BASIC_ATTACK_DEBOUNCE_TAG), BASIC_ATTACK_DEBOUNCE_TICKS);
                    playMorphAttackAnim(attacker);
                }
            }
            const hurtPlayer = ev.hurtEntity;
            if (!(hurtPlayer instanceof we)) return;
            const hb = hurtPlayer.getEffect("health_boost");
            if (!hb) return;
            const amp = hb.amplifier;
            if (amp <= 0) return;

            hurtPlayer.addEffect("health_boost", 1e6, { amplifier: amp - 1 });
            hurtPlayer.sendMessage("§c−1 Heart");
        });
        let m = [
            "minecraft:bat",
            "minecraft:bee",
            "minecraft:cat",
            "minecraft:chicken",
            "minecraft:cow",
            "minecraft:donkey",
            "minecraft:fox",
            "minecraft:horse",
            "minecraft:mooshroom",
            "minecraft:ocelot",
            "minecraft:parrot",
            "minecraft:pig",
            "minecraft:polar_bear",
            "minecraft:rabbit",
            "minecraft:sheep",
            "minecraft:squid",
            "minecraft:turtle",
            "minecraft:axolotl",
            "minecraft:dolphin",
            "minecraft:cod",
            "minecraft:salmon",
            "minecraft:pufferfish",
            "minecraft:tropical_fish",
            "minecraft:panda",
            "minecraft:villager",
            "minecraft:wandering_trader",
            "minecraft:iron_golem",
            "minecraft:llama",
            "minecraft:mule",
            "minecraft:trader_llama",
        ],
            l = [
                "minecraft:blaze",
                "minecraft:cave_spider",
                "minecraft:creeper",
                "minecraft:dragon_fireball",
                "minecraft:elder_guardian",
                "minecraft:ender_dragon",
                "minecraft:enderman",
                "minecraft:endermite",
                "minecraft:evoker",
                "minecraft:ghast",
                "minecraft:guardian",
                "minecraft:hoglin",
                "minecraft:husk",
                "minecraft:illusioner",
                "minecraft:magma_cube",
                "minecraft:phantom",
                "minecraft:pillager",
                "minecraft:ravager",
                "minecraft:shulker",
                "minecraft:silverfish",
                "minecraft:skeleton",
                "minecraft:slime",
                "minecraft:spider",
                "minecraft:stray",
                "minecraft:vex",
                "minecraft:vindicator",
                "minecraft:witch",
                "minecraft:wither",
                "minecraft:wither_skeleton",
                "minecraft:zoglin",
                "minecraft:zombie",
                "minecraft:zombie_villager",
                "minecraft:zombified_piglin",
                "minecraft:spawner_minecart",
            ],
            h = new Map();
        x.afterEvents.entityDie.subscribe((o) => {
            let { damageSource: i, deadEntity: w } = o,
                _ = i.damagingEntity;
            if (!(_ instanceof we)) return;

            let u = _.hasTag("nc_werewolf_morph:vampire_tag"),
                g = _.hasTag("nc_werewolf_morph:werewolf_tag");
            if (!u && !g) return;

            let C = u ? "xp_vampire" : "xp_werewolf",
                E = u ? "Vampire" : "Werewolf",
                v = u ? "\xA75" : "\xA76",
                n = w.typeId,
                d,
                p;

            if (
                (n === "nc_werewolf_morph:vampire_basic"
                    ? ((d = 5), (p = "Vampire"))
                    : n === "nc_werewolf_morph:werewolf_basic"
                        ? ((d = 5), (p = "Werewolf"))
                        : l.includes(n)
                            ? ((d = 3), (p = "Hostile Mob"))
                            : m.includes(n)
                                ? ((d = 1), (p = "Passive Mob"))
                                : ((d = 2), (p = "Other Mob")),
                    x.scoreboard.getObjective(C)?.addScore(_, d),
                    _.sendMessage(`${v}+${d} ${E} XP \xA77(for killing ${p})`),
                    !_.hasTag("nc_werewolf_morph:life_steal_active"))
            ) {
                return;
            }
            _.sendMessage("\xA7c+Life Steal 1 kill");

            const playerName = _.name;
            const newKills = (h.get(playerName) ?? 0) + 1;
            h.set(playerName, newKills);
            if (newKills % 5 === 0) {
                const currentAmp = _.getEffect("health_boost")?.amplifier ?? 0;
                let amf = 0
                if (currentAmp === 0) {
                    amf = 1
                } else {
                    amf = 0
                }
                _.addEffect("health_boost", 1_000_000, {
                    amplifier: currentAmp + 1,
                    showParticles: false,
                });
                _.sendMessage("\xA7a+2 Heart (5 kill bonus!)");
                B.runTimeout(() => {
                    _.addEffect("instant_health", 1, {
                        amplifier: 1,
                        showParticles: false,
                    });
                }, 1);
            }
        });

        x.afterEvents.playerSpawn.subscribe((o) => {
            let i = o.player;
            const hostExists = x.getPlayers().some(p => p.hasTag("is_host"));
            if (!hostExists) {
                i.addTag("is_host");
                i.sendMessage("\xA7e[System] You are the host of this world.");
            }

            if (!i.hasTag("nc_werewolf_morph:has_menu")) {
                i.runCommandAsync("gamerule showtags false"),
                    i.runCommandAsync("gamerule sendcommandfeedback false");

                let _ = i.getComponent("minecraft:inventory"),
                    u = K.hasItem(i, "nc_werewolf_morph:menu");

                if (_ && _.container && !u) {
                    let g = new Wt("nc_werewolf_morph:menu", 1);
                    try {
                        _.container.addItem(g),
                            i.addTag("nc_werewolf_morph:has_menu"),
                            i.sendMessage("You have received the custom menu item!");
                    } catch (C) {
                        console.warn(`Failed to add item to player inventory: ${C}`);
                    }
                }
            }

            let w = k.getTimeLeft(i);
            k.initializeTimer(i, w);
        });

        x.afterEvents.playerSpawn.subscribe(({ player: o, initialSpawn: i }) => {
            if (i && (o.hasTag("nc_werewolf_morph:werewolf_tag") ||
                o.hasTag("nc_werewolf_morph:vampire_tag") || o.hasTag("nc_werewolf_morph:bat_tag"))) {
                B.runTimeout(() => {
                    o.runCommandAsync(
                        "playanimation @s animation.nitric_morph.player.player_invisible_v1",
                    )
                }, 180);
            }
            else if (!i) {
                let w = T.activeIntervals.get(o.name);
                w !== void 0 && (B.clearRun(w), T.activeIntervals.delete(o.name)),
                    o.runCommandAsync("stopsound @s *"),
                    o.runCommandAsync("effect @s clear"),
                    o.onScreenDisplay.setActionBar(""),
                    (o.hasTag("nc_werewolf_morph:werewolf_tag") ||
                        o.hasTag("nc_werewolf_morph:vampire_tag") || o.hasTag("nc_werewolf_morph:bat_tag")) &&
                    (I.removeMorph(o));
            }
        }),
            G.init(),
            Se.init();
        try {
            B.runInterval(t);
        } catch (o) {
            console.log(o);
            B.runTimeout(() => {
                const p = x.getPlayers()?.[0];
                if (p) p.sendMessage("Fatal error: " + o);
            }, 80);
        }

        console.log("Main module initialized and running.");
    };

    function isPlayerVanishActive(p) {
        return ge(p.id, "vampire_vanish");
    }

    function t() {
        const MORPH_CONFIG = [
            {
                tag: "nc_werewolf_morph:bat_tag",
                itemId: "nc_werewolf_morph:bat_morph",
            },
            {
                tag: "nc_werewolf_morph:vampire_tag",
                itemId: "nc_werewolf_morph:vampire_morph",
            },
            {
                tag: "nc_werewolf_morph:werewolf_tag",
                itemId: "nc_werewolf_morph:werewolf_morph",
            },
        ];
        const ALL_MORPH_HEADS = new Set([
            "nc_werewolf_morph:vampire_morph",
            "nc_werewolf_morph:werewolf_morph",
            "nc_werewolf_morph:werewolf_morph_2",
            "nc_werewolf_morph:bat_morph",
        ]);

        x.getPlayers().forEach((p) => {
            Me.updatePlayerHUD(p);
            if (
                p.hasTag("nc_werewolf_morph:werewolf_tag") ||
                p.hasTag("nc_werewolf_morph:bat_tag") ||
                p.hasTag("nc_werewolf_morph:vampire_tag")
            ) {
                G.giveItemBack(p);
                G.clearEquipment(p);
            }
            let activeMorph = undefined;
            for (const cfg of MORPH_CONFIG) {
                if (p.hasTag(cfg.tag)) {
                    activeMorph = cfg;
                    break;
                }
            }
            let headItemId = undefined;
            try {
                const eq = p.getComponent("minecraft:equippable");
                if (eq) {
                    const headItem = eq.getEquipment(q.Head);
                    headItemId = headItem?.typeId;
                }
            } catch {
            }
            if (!activeMorph) {
                if (headItemId && ALL_MORPH_HEADS.has(headItemId)) {
                    p.runCommandAsync("replaceitem entity @s slot.armor.head 0 air");
                }
            } else {
                const isVampire = activeMorph.tag === "nc_werewolf_morph:vampire_tag";
                const vanishActive = isVampire && isPlayerVanishActive(p);
                const eq = p.getComponent("minecraft:equippable");
                const invComp = p.getComponent("minecraft:inventory");
                const cont = invComp && invComp.container;
                if (!eq) return;
                const headItem = eq.getEquipment(q.Head);
                const headItemId = headItem && headItem.typeId;

                if (vanishActive) {
                    if (headItem) {
                        if (cont) {
                            const leftover = cont.addItem(headItem.clone());
                            if (leftover) {
                                p.dimension.spawnItem(leftover, p.location);
                            }
                        } else {
                            p.dimension.spawnItem(headItem.clone(), p.location);
                        }
                        try { eq.setEquipment(q.Head, undefined); } catch (_) { }
                    }
                } else {
                    if (headItemId !== activeMorph.itemId) {
                        p.runCommandAsync(
                            `replaceitem entity @s slot.armor.head 0 ${activeMorph.itemId} 1 0 {"item_lock":{"mode":"lock_in_inventory"},"item_lock":{"mode":"lock_in_slot"}}`
                        );
                    }
                }
            }


            let warnedThisTick = false;

            try {
                const invComp = p.getComponent("minecraft:inventory");
                const container = invComp?.container;
                if (container) {
                    for (let slot = 0; slot < container.size; slot++) {
                        const stack = container.getItem(slot);
                        if (!stack) continue;

                        const stackId = stack.typeId;
                        if (ALL_MORPH_HEADS.has(stackId)) {
                            container.setItem(slot, undefined);
                            if (!warnedThisTick) {
                                warnedThisTick = true;
                                p.sendMessage("§cYou can't hold this item in your inventory.");
                            }
                        }
                    }
                }
            } catch {
            }
        });
    }
    let r = new Map();
    let s = new Map();

    B.runInterval(() => {
        for (let a of x.getPlayers()) {
            if (
                a.hasTag("nc_werewolf_morph:werewolf_tag") ||
                a.hasTag("nc_werewolf_morph:vampire_tag")
            ) {
                const name = a.name;
                const lastPos = r.get(name);
                const loc = a.location;
                const cd = s.get(name) ?? 0;
                if (cd > 0) {
                    s.set(name, cd - 1);
                }

                if (lastPos) {
                    const dx = loc.x - lastPos.x;
                    const dz = loc.z - lastPos.z;
                    const pitch = (0.02 + Math.random() * 0.03).toFixed(2);
                    const vol = (0.8 + Math.random() * 0.4).toFixed(2);
                    if (loc.y >= -64 && loc.y <= 320) {
                        if (Math.hypot(dx, dz) > 0.3 && (s.get(name) ?? 0) <= 0) {
                            const under = a.dimension.getBlock({
                                x: Math.floor(loc.x),
                                y: Math.floor(loc.y) - 1,
                                z: Math.floor(loc.z),
                            });

                            if (under && !under.isAir) {
                                a.runCommandAsync(
                                    `playsound nc_werewolf_morph:morph_step @a[r=15] ~ ~ ~ ${pitch} ${vol}`
                                );
                                s.set(name, 10);
                            }
                        }
                    }
                }
                r.set(name, { x: loc.x, z: loc.z });
            } else {
                const loc = a.location;
                r.set(a.name, { x: loc.x, z: loc.z });
            }
        }
        t();
    }, 1);


})((We ||= {}));
We.init();
export { We as Main };
