import { world } from "@minecraft/server";
world.afterEvents.playerBreakBlock.subscribe(event => {
// Verifica que el jugador esté usando el martillo específico
if (event.itemStackAfterBreak.typeId == "minecraft:iron_pickaxe") {
world.sendMessage("hola")
const p = event.player;
const locationToBreak = [
{ x: event.block.location.x, y: event.block.location.y + 1, z: event.block.location.z - 1 }, // Arriba Izquierda
{ x: event.block.location.x, y: event.block.location.y + 1, z: event.block.location.z }, // Arriba
{ x: event.block.location.x, y: event.block.location.y + 1, z: event.block.location.z + 1 }, // Arriba Derecha
{ x: event.block.location.x, y: event.block.location.y, z: event.block.location.z - 1 }, // Izquierda
{ x: event.block.location.x, y: event.block.location.y, z: event.block.location.z }, //Centro
{ x: event.block.location.x, y: event.block.location.y, z: event.block.location.z + 1 }, // Derecha
{ x: event.block.location.x, y: event.block.location.y - 1, z: event.block.location.z - 1 }, // Abajo izquierda
{ x: event.block.location.x, y: event.block.location.y - 1, z: event.block.location.z }, // Abajo
{ x: event.block.location.x, y: event.block.location.y - 1, z: event.block.location.z + 1 } // Abajo derecha
]
if (event.brokenBlockPermutation.type.id === 'minecraft:stone') {
world.sendMessage("hola2")
for (const offset of locationToBreak) {
const targetLocation = {
x: offset.x,
y: offset.y,
z: offset.z
};
p.runCommandAsync(`say ${targetLocation.x} ${targetLocation.y} ${targetLocation.z}`);
p.runCommandAsync(`setblock ${targetLocation.x} ${targetLocation.y} ${targetLocation.z} air destroy`);
}
}
}
});
#How to adapt the break event to the player's direction?
1 messages · Page 1 of 1 (latest)
I gotta go do something.. but I think if you use the player's getRotation, the y of the vector2 has the rotation and maybe some vector math... and maybe put in the before events while the block is still there.
If it was an interact, you can get the face of the block...
**This also looks promising... **take a look at the getBlockFromViewDirection.. and the code example.. has FACE and if the block is the same block, then you got the face https://jaylydev.github.io/scriptapi-docs/latest/classes/_minecraft_server_1_13_0.Player.html#getBlockFromViewDirection