import { BlockVolumeUtils } from "@minecraft/server";

/**
 * 
 * @param { import("@minecraft/server").Block } block
 * @param { import("@minecraft/server").Dimension } dimension
 */
export const hoeGround = ( block, dimension ) => {
    const { x, y, z } = block.location;
    const blocks = BlockVolumeUtils.getBlockLocationIterator(
        {
            from: { x: x + 1, y, z: z + 1 },
            to: { x: x - 1, y, z: z - 1 }
        },
    );

    for (const b of blocks) {
        const block = dimension.getBlock(b);
        if(block.hasTag('minecraft:crop') || block.typeId == 'minecraft:tallgrass') {
        dimension.runCommandAsync( `setblock ${b.x} ${b.y} ${b.z} air [] destroy` );
    };}
};