import * as mc from "@minecraft/server";
import { WornHat } from "../worn_hat";
class SakuraHat extends WornHat {
    constructor() {
        super(...arguments);
        this.hatTypeId = "ldz_crcomp:hat_sakura_parkette";
        this.onEffectEvent = this.onEffect.bind(this);
    }
    async onEquip() {
        mc.world.afterEvents.effectAdd.subscribe(this.onEffectEvent, { entities: [this.hatWearer.Entity.UnsafeEntity] });
    }
    async onUnequip() {
        mc.world.afterEvents.effectAdd.unsubscribe(this.onEffectEvent);
    }
    onEffect(event) {
        if (event.effect.typeId === "wither" || event.effect.typeId.includes("poison")) {
            this.hatWearer.Entity.removeEffect("wither");
            this.hatWearer.Entity.removeEffect("poison");
            this.hatWearer.Entity.removeEffect("fatal_poison");
        }
    }
}
WornHat.HatTable["ldz_crcomp:hat_sakura_parkette"] = SakuraHat;
