import * as utils from "../../utils/index";
import { WornHat } from "../worn_hat";
class NasteeHat extends WornHat {
    constructor() {
        super(...arguments);
        this.hatTypeId = "ldz_crcomp:hat_nastee";
    }
    async onEquip() {
        const wearer = this.hatWearer.Entity.getPlayer();
        utils.waitForLoopEvent(5, () => {
            if (wearer === null || wearer === void 0 ? void 0 : wearer.isValid()) {
                if (wearer.isJumping) {
                    wearer.addEffect("levitation", 120, { showParticles: false, amplifier: 2 });
                }
                else {
                    wearer.removeEffect("levitation");
                }
            }
            return false;
        }, this.cancelCategory);
    }
    async onUnequip() {
        utils.abortEvents(this.cancelCategory);
        if (this.hatWearer.Entity.isValid()) {
            this.hatWearer.Entity.removeEffect("levitation");
        }
    }
}
WornHat.HatTable["ldz_crcomp:hat_nastee"] = NasteeHat;
