import { EntityEquippableComponent } from "@minecraft/server";
/**
 * @param {import("@minecraft/server").Player} player
 * @param {string} typeId
 * @returns {boolean}
 */
export function isPlayerHoldingItem(player, typeId) {
    return getPlayerHoldingItem(player)?.typeId === typeId;
}

/**
 * @param {import("@minecraft/server").Player} player
 * @returns {import("@minecraft/server").ItemStack}
 */
export function getPlayerHoldingItem(player) {
    return player.getComponent("minecraft:equippable").getEquipment("Mainhand");
}

export function getPlayerEquipment(player) {
    return player.getComponent(EntityEquippableComponent.componentId);
}