
export function Saw(player, block, itemStackAfterBreak, itemStackBeforeBreak, dimension, brokenBlockPermutation) {
    // Check if the broken block is a log
    if (block.type.id.endsWith(`_log`)) {
        const sawItem = itemStackBeforeBreak;

        
        // Calculate new durability
        const durabilityLoss = Math.floor(sawItem.maxDurability / 5);
        const newDurability = sawItem.durability - durabilityLoss;

        if (newDurability > 0) {
            // Update the saw's durability
            sawItem.setDurability(newDurability);
        } else {
            // Break the saw if durability reaches zero or below
            player.getComponent("inventory").container.setItem(player.selectedSlot, null);
        }

        // Update the item stack in the player's hand
        player.getComponent("inventory").container.setItem(player.selectedSlot, sawItem);
    }
}