// replaces the current block with the most common nearby blocks
import { world } from "@minecraft/server";

world.beforeEvents.worldInitialize.subscribe((Initiate) => {
    Initiate.blockComponentRegistry.registerCustomComponent("ecbl_bc:remove", {
        onTick: (e) => {
            const blockBelow = e.block.below();
            const above = e.block.above();

            if (blockBelow.typeId === 'minecraft:dirt') {
                blockBelow.setType('minecraft:grass_block');
            }

            if (above.isValid() && above.typeId === 'minecraft:leaf_litter') above.setType('minecraft:air');

            e.block.setType('minecraft:air');
        }
    });
});