import { EquipmentSlot } from '@minecraft/server';
import { getEntityEquippable } from './entity.js';

function getEntityHeldItem(entity, slot = EquipmentSlot.Mainhand) {
    const component = getEntityEquippable(entity);
    if (!component) {
        return;
    }
    return component.getEquipment(slot);
}
function setEntityHeldItem(entity, item, slot = EquipmentSlot.Mainhand) {
    const component = getEntityEquippable(entity);
    if (!component) {
        return;
    }
    return component.setEquipment(slot, item);
}

export { getEntityHeldItem, setEntityHeldItem };
