The PlayerPlaceBlockBeforeEvent interface in @minecraft/server.
Interface in @minecraft/server
Extends CancellableEvent
import type { PlayerPlaceBlockBeforeEvent } from '@minecraft/server';Subscribe to it with world.beforeEvents.playerPlaceBlock.
Example
Section titled “Example”import { world, type PlayerPlaceBlockBeforeEvent } from '@minecraft/server';
world.beforeEvents.playerPlaceBlock.subscribe((event: PlayerPlaceBlockBeforeEvent) => { console.log('playerPlaceBlock', event.player.name, event.block.typeId);
// Uncomment to stop it from happening. // event.cancel = true;});import { world } from '@minecraft/server';
world.beforeEvents.playerPlaceBlock.subscribe((event) => { console.log('playerPlaceBlock', 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;The block being placed, at its place.
Types
permutationBeingPlaced
Section titled “permutationBeingPlaced”read-only
readonly permutationBeingPlaced: { readonly typeId: string };Used by
Section titled “Used by”WorldBeforeEvents.playerPlaceBlock
Inherited
Section titled “Inherited”From CancellableEvent: cancel