import * as mc from "@minecraft/server";
import * as utils from "../utils/index";
import { ignoreEntities } from "../shared/constants";
const guardianDamage = 9;
export function ocean_monumentAbility(player) {
    utils.mclog(`ocean_monument`);
    mc.world.playSound('ability.monument.start', player.location);
    for (let angle = 0; angle < 360; angle += 90) {
        const direction = new utils.Vector3({ x: 0, y: 0.5, z: 0.5 }).rotateYaw(angle);
        const guardian = player.dimension.spawnEntity('ldz:ocean_monument_ability', player.location);
        guardian.teleport(guardian.location, { rotation: { x: 0, y: angle } });
        guardian.applyImpulse(direction.multiply(2));
        utils.waitForEvent(60, () => {
            utils.waitForLoopEvent(5, () => {
                if (guardian.isValid() && guardian.hasTag('onGround')) {
                    guardian.dimension.getEntities({ location: guardian.location, maxDistance: 5, excludeTypes: ignoreEntities, excludeNames: [player.nameTag], excludeTags: ['friendlyFireOff'] }).forEach(victim => {
                        victim.applyDamage(guardianDamage, { damagingEntity: player.UnsafeEntity, cause: mc.EntityDamageCause.entityAttack });
                    });
                    return false;
                }
                return !guardian.isValid();
            });
        });
    }
}
