import { world, Vector } from '@minecraft/server';
world.afterEvents.playerBreakBlock.subscribe(e => {
const player = e.player;
const block = e.brokenBlockPermutation.type.id;
const entity = player.dimension.spawnEntity("mc:block", Vector.subtract(e.block.location, {
'x': -0.5,
'y': -0.66,
'z': -0.5
}));
const coord = -0.3;
const i = [{
'x': 0x0,
'y': 0x0 + coord,
'z': 0x0
}, {
'x': 0.33,
'y': 0x0 + coord,
'z': 0x0
}, {
'x': -0.33,
'y': 0x0 + coord,
'z': 0x0
}, {
'x': 0.33,
'y': 0x0 + coord,
'z': 0.33
}, {
'x': -0.33,
'y': 0x0 + coord,
'z': -0.33
},
}]
for (let a = 0x0; a < i.length; a++) {
const entity2 = entity.dimension.spawnEntity("mc:block", Vector.subtract(entity.location, i[a]));
entity2.runCommand("replaceitem entity @s slot.weapon.mainhand 0 " + block);
entity2.triggerEvent("mc:block_physics");
entity2.applyImpulse({
'x': Math.random() * 0.6 - 0.3,
'y': 0.2,
'z': Math.random() * 0.6 - 0.3
});
entity2.triggerEvent('mc:block_baby');
}
entity.teleport(new Vector( 999999, 999999, 999999), {keepVelocity: false, dimension: world.getDimension(entity.dimension.id)});
entity.kill();
});
updated here btw