import { ItemDurabilityComponent } from "@minecraft/server";
export class ItemManager {
    static reduceDurability(item, player) {
        const durComp = item.getComponent(ItemDurabilityComponent.componentId);
        if (!durComp)
            return item;
        if (!this.canReduceDurability(item))
            return item;
        if (durComp.damage + 1 > durComp.maxDurability) {
            player?.dimension?.playSound("random.break", player.location);
            return undefined;
        }
        durComp.damage += 1;
        return item;
    }
    static canReduceDurability(item) {
        return true;
    }
    static reduceAmount(item) {
        if (item.amount - 1 <= 0)
            return undefined;
        item.amount -= 1;
        return item;
    }
}
