import * as utils from "../../utils/index";
import { WornHat } from "../worn_hat";
class SherlockHat extends WornHat {
    constructor() {
        super(...arguments);
        this.hatTypeId = "ldz_crcomp:hat_sherlock";
    }
    async onEquip() {
        const wearer = this.hatWearer.Entity;
        utils.waitForLoopEvent(10, () => {
            if (wearer.isValid() && wearer.typeId === "minecraft:player") {
                utils.getEntitiesSafe(wearer.dimension, { type: "minecraft:item", location: wearer.location, maxDistance: 16 }).forEach(item => {
                    const direction = wearer.location.subtract(item.location).normalize();
                    item.applyImpulse(direction.multiply(Math.min(item.location.distance(wearer.location) * 0.2, 0.75)));
                });
            }
            return false;
        }, this.cancelCategory);
    }
    async onUnequip() {
        utils.abortEvents(this.cancelCategory);
    }
}
WornHat.HatTable["ldz_crcomp:hat_sherlock"] = SherlockHat;
