import { EquipmentSlot, system } from '@minecraft/server';
import { startCooldown } from 'utils/startCooldown';
export function blackhole(componentData) {
    const source = componentData.source;
    const entity = source.dimension.spawnEntity('endorah_mo:blackhole', source.location);
    const multiplied_vector = {
        x: source.getViewDirection().x * 7,
        y: source.getViewDirection().y * 2.5,
        z: source.getViewDirection().z * 7
    };
    entity.applyImpulse(multiplied_vector);
    source.addTag(entity.id);
    system.runTimeout(() => {
        source.removeTag(entity.id);
    }, 20 * 15);
    source.playSound('endorah.mo.shadowite.sword_black_hole_sound');
    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 shadowiteParticleFunction(componentData) {
    try {
        const particles = [
            'endorah_mo:shadowite_1',
            'endorah_mo:shadowite_2',
            'endorah_mo:shadowite_3',
            'endorah_mo:shadowite_4'
        ];
        particles.forEach((particle) => {
            componentData.hitEntity.dimension.spawnParticle(particle, componentData.hitEntity.location);
        });
    }
    catch (error) { }
}
