import { Entity, GameMode, Player, world } from "@minecraft/server";

world.afterEvents.playerPlaceBlock.subscribe((eventData) => {
    const block = eventData.block
    const player = eventData.player
    if (block.typeId == 'minecraft:carved_pumpkin') {
        if (block.below(1).typeId == 'minecraft:hay_block' && block.below(2).typeId.match('_fence')) {
            block.setType("minecraft:air")
            block.below(1).setType("minecraft:air")
            block.below(2).setType("minecraft:air")
            player.runCommandAsync('summon bumble:maze_golem ' + JSON.stringify(block.location.x) + ' ' + JSON.stringify(block.location.y - 2) + ' ' + JSON.stringify(block.location.z))

        }
    }
})