Hi, I am trying to detect when a block is broken by explosion, as far as I can see, ExplosionAfterEvent is in stable, but I can't work out how I should be using it, here is what I have so far:
import { world } from "@minecraft/server";
const blockTypes = [
"minecraft:dirt"
];
world.afterEvents.Explosion.subscribe((event) => {
const { brokenBlockPermutation } = event;
blockTypes.forEach((id) => {
if (brokenBlockPermutation.matches(id)) {
event.source.dimension.runCommand(
`summon minecraft:pig ${event.block.x} ${event.block.y} ${event.block.z}`
);
return;
}
});
});
any help will be greatly appreciated ๐