import { world } from "@minecraft/server"
import { CUSTOM_HEADS } from "../blocks/common/customHeads"
import { EntityComponents as EComponents } from "../entities/utils/entityComponents"

world.afterEvents.itemUse.subscribe(ev => {
    const {itemStack, source} = ev

    const equippable = EComponents.getEquippable(source)
    const itemStackId = itemStack.typeId

    if (CUSTOM_HEADS.isUsing(itemStackId)) CUSTOM_HEADS.wearAsHead(itemStack, source, equippable)
})