import { EquipmentSlot, MolangVariableMap } from '@minecraft/server';
import { applyKnockback } from 'utils/applyKnockback';
import { startCooldown } from 'utils/startCooldown';
export function shockwave(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:plutonium_special_2', head_location, molang);
    const entities = source.dimension.getEntities({
        location: source.location,
        maxDistance: 5
    });
    entities
        .filter((entity) => entity !== source)
        .forEach((entity) => {
        applyKnockback(source, entity, { x: 10, y: 1 });
    });
    source.playSound('endorah.mo.plutonite.sword_shockwave');
    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);
}
export function plutoniteParticleFunction(componentData) {
    try {
        const particles = [
            'endorah_mo:plutonium_1',
            'endorah_mo:plutonium_2',
            'endorah_mo:plutonium_3',
            'endorah_mo:plutonium_4'
        ];
        particles.forEach((particle) => {
            componentData.hitEntity.dimension.spawnParticle(particle, componentData.hitEntity.location);
        });
    }
    catch (error) { }
}
