import { ItemStack, Player } from "@minecraft/server";
import { decrementItemStack, shootProjectileWithPower } from "../../../library/itemManager";

/**
 * Evento onUse del componente digitalSpawnComponent
 * Addon: Electrical Creativity BP
 * @param {{itemStack: ItemStack, source: Player}} event 
 */
export const digitalSpawnOnUseEvent = ({ itemStack, source }) => {
    const summon = itemStack.typeId.replace("spawn", "summon")

    shootProjectileWithPower(source, summon, 1.0)
    itemStack = decrementItemStack(itemStack, source);
}