The PlayerBreakBlockBeforeEvent interface in @minecraft/server.
Interface in @minecraft/server
Extends CancellableEvent
import type { PlayerBreakBlockBeforeEvent } from '@minecraft/server';Subscribe to it with world.beforeEvents.playerBreakBlock.
Example
Section titled “Example”import { world, type PlayerBreakBlockBeforeEvent } from '@minecraft/server';
world.beforeEvents.playerBreakBlock.subscribe((event: PlayerBreakBlockBeforeEvent) => { console.log('playerBreakBlock', event.player.name, event.block.typeId);
// Uncomment to stop it from happening. // event.cancel = true;});import { world } from '@minecraft/server';
world.beforeEvents.playerBreakBlock.subscribe((event) => { console.log('playerBreakBlock', event.player.name, event.block.typeId);
// Uncomment to stop it from happening. // event.cancel = true;});Properties
Section titled “Properties”player
Section titled “player”read-only
readonly player: Player;Types
read-only
readonly block: Block;Types
Used by
Section titled “Used by”WorldBeforeEvents.playerBreakBlock, PlayerBreakBlockBeforeEventSignal.subscribe, PlayerBreakBlockBeforeEventSignal.unsubscribe
Inherited
Section titled “Inherited”From CancellableEvent: cancel