import * as mc from "@minecraft/server";
import * as utils from "../utils/index";
import { ignoreEntities } from "../shared/constants";
const tickDuration = 60;
export function dolphinAbility(player) {
    utils.mclog(`Dolphin`);
    utils.runCommand(`particle ldz:ability_dolphin_effector ~ ~ ~`, player);
    mc.world.playSound('ability.dolphin', player.location);
    const victims = player.dimension.getEntities({ location: player.location, maxDistance: 10, excludeTypes: ignoreEntities, excludeNames: [player.nameTag], excludeTags: ['friendlyFireOff'] });
    if (victims.length) {
        const endTime = mc.system.currentTick + tickDuration;
        utils.waitForLoopEvent(5, () => {
            for (const victim of victims) {
                if (victim.isValid()) {
                    utils.runCommand(`particle ldz:ability_dolphin ~ ~ ~`, victim);
                    mc.world.playSound(`bubble.up`, victim.location);
                    victim.addEffect('levitation', 10, { amplifier: 1, showParticles: false });
                }
            }
            return mc.system.currentTick >= endTime;
        });
    }
}
