import { ItemComponentUseEvent, ItemCooldownComponent } from '@minecraft/server'
import { Server } from '../../../libs/Core/index.js';
import { onUseWrapper } from './wrapper.js';

export class VoidStaff extends onUseWrapper {
    constructor() {
        super();
    }


    /**
     * @param {ItemComponentUseEvent} e 
     */
    onUse(e) {
        const player = e.source

        /** @type {ItemCooldownComponent} */
        const cooldownComponent = e.itemStack.getComponent('minecraft:cooldown');
        cooldownComponent.startCooldown(player);

        this.decrementDurability(player, e.itemStack, 1);
        Server.entityShootProjectile('plank_waao:void_staff_projectile', player, 0.8, { facingOffset: { x: 1.5, y: 0, z: 0 }, gravity: 0 });
    }

}

