import { EquipmentSlot, MolangVariableMap } from '@minecraft/server';
import { applyDamageOverTime } from 'utils/random';
import { startCooldown } from 'utils/startCooldown';
export function breath(componentData) {
    const source = componentData.source;
    const head_location = source.getHeadLocation();
    const view_direction = source.getViewDirection();
    const molang = new MolangVariableMap();
    molang.setFloat('endorah_x', view_direction.x);
    molang.setFloat('endorah_y', view_direction.y);
    molang.setFloat('endorah_z', view_direction.z);
    source.dimension.spawnParticle('endorah_mo:dragon_special_1', head_location, molang);
    source.playSound('endorah.mo.dragonite.sword_special_attack');
    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: 10,
        excludeTypes: ['minecraft:item']
    });
    applyDamageOverTime(entities, 10, 10, 4);
}
export function dragoniteParticleFunction(componentData) {
    try {
        const particles = [
            'endorah_mo:dragon_1',
            'endorah_mo:dragon_2',
            'endorah_mo:dragon_3',
            'endorah_mo:dragon_4'
        ];
        particles.forEach((particle) => {
            componentData.hitEntity.dimension.spawnParticle(particle, componentData.hitEntity.location);
        });
    }
    catch (error) { }
}
