I got this script where after a players breaks a block it will get all entities in radius of 2 and kill them
world.afterEvents.playerBreakBlock.subscribe((e) =>{
const block = e.block;
const { dimension } = block;
const location = block.center();
if (block.typeId == "si:corpse") {
const entities = dimension.getEntities({location:location, maxDistance: 2});
entities.forEach(entity =>{
if (entities.typeId == "si:corpse") {
entity.remove();
}
})
}
})