import { EquipmentSlot, MolangVariableMap } from '@minecraft/server';
import { applyDamageOverTime } from 'utils/random';
import { startCooldown } from 'utils/startCooldown';
export function sonic(componentData) {
    const source = componentData.source;
    const molang = new MolangVariableMap();
    molang.setFloat('endorah_x', source.getViewDirection().x);
    molang.setFloat('endorah_y', source.getViewDirection().y);
    molang.setFloat('endorah_z', source.getViewDirection().z);
    for (let index = 1; index < 9; index++) {
        source.runCommand(`particle endorah_mo:warden_special_1 ^^1^${index * 3}`);
        source.runCommand(`particle endorah_mo:warden_special_3 ^^1^${index * 3}`);
        source.dimension.spawnParticle('endorah_mo:warden_special_2', source.getHeadLocation(), molang);
    }
    source.playSound('mob.warden.sonic_boom');
    const durability_component = componentData.itemStack.getComponent('durability');
    if (durability_component)
        durability_component.damage += 1;
    const equippable_component = source.getComponent('equippable');
    if (equippable_component)
        equippable_component.setEquipment(EquipmentSlot.Mainhand, componentData.itemStack);
    startCooldown(componentData.itemStack, source);
    const entities = source.getEntitiesFromViewDirection({
        maxDistance: 24,
        excludeTypes: ['minecraft:item']
    });
    applyDamageOverTime(entities, 10, 10, 4);
}
export function echoParticleFunction(componentData) {
    try {
        const particles = [
            'endorah_mo:warden_1',
            'endorah_mo:warden_2',
            'endorah_mo:warden_3'
        ];
        particles.forEach((particle) => {
            componentData.hitEntity.dimension.spawnParticle(particle, componentData.hitEntity.location);
        });
    }
    catch (error) { }
}
