import { BlockPermutation } from '@minecraft/server';
import { decreaseItemDurabilityInHand, getItemInSlot } from '../../util/utils';
export default class WitheredLogComponent {
    onPlayerInteract(e) {
        if (!e.player)
            return;
        const heldItem = getItemInSlot(e.player);
        if (heldItem?.hasTag('minecraft:is_axe')) {
            let permutation = BlockPermutation.resolve(e.block.typeId.replace('twb_wisu:', 'twb_wisu:stripped_'));
            try {
                permutation = permutation.withState('minecraft:block_face', e.block.permutation.getState('minecraft:block_face'));
            }
            catch (err) {
                // Ignore
            }
            e.block.setPermutation(permutation);
            e.block.dimension.playSound('use.wood', e.block);
            decreaseItemDurabilityInHand(e.player);
        }
    }
}
