import {
    world,
    system,
    ItemStack
} from "@minecraft/server";

world.beforeEvents.playerBreakBlock.subscribe((event) => {
    const block = event.block;
    if (block.type.id === "minecraft:jukebox") {
        system.run(() => {
            event.player.runCommand("/stopsound @a[r=64] sparkler.use")
        })
    }
});

world.afterEvents.playerBreakBlock.subscribe((event) => {
    const block = event.brokenBlockPermutation;
    if (block.type.id === "dragons:dragon_ruby_block") {

        if (world.getDifficulty() === "Peaceful") return;
        event.player.runCommand("/event entity @e[r=32,family=lethal,c=1] dragons:start_waking")
    }
});