Skip to content

BlockPlaceEvent

Namespace Mc.Scripting.Events · Kind struct (ref)

public ref struct BlockPlaceEvent : IEvent

A player is about to place a block. Cancel to refuse; ‘block_state’ may be rewritten.

Id 21
Key mc:block_place
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Player player no (readonly) The player.
Pos BlockPos no (readonly) Where the block goes.
Against BlockPos no (readonly) The clicked block.
BlockState blockstate yes The state that will be placed.
Hand byte no (readonly) The hand (Hand).
Item item no (readonly) The block item used.

Set e.Cancelled = true in a handler to cancel it; lower-priority handlers are skipped unless they subscribed with receiveCancelled: true.

Member Description
Constructor Creates the event (for firing it from a plugin; native code builds its own).
public BlockPlaceEvent(Player player, BlockPos pos, BlockPos against, BlockState blockState, byte hand, ItemView item)

Creates the event (for firing it from a plugin; native code builds its own). Signature of API 1.0.

Parameters

Name Type Description
player Player
pos BlockPos
against BlockPos
blockState BlockState
hand byte
item ItemView
Member Description
BlockPos Against { get; } The clicked block.
BlockState BlockState { get; set; } The state that will be placed.
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
byte Hand { get; } The hand (Hand).
ItemView Item { get; } The block item used.
Player Player { get; } The player.
BlockPos Pos { get; } Where the block goes.
static ushort CatalogueId { get; } Catalogue id (stable ABI).
static bool IsCancellable { get; } Whether handlers can cancel the event.
static string Key { get; } Registry key of the event.
public BlockPos Against { get; }

The clicked block.

public BlockState BlockState { get; set; }

The state that will be placed.

public bool Cancelled { get; set; }

Cancelling stops lower-priority handlers (unless they opt in) and the action itself.

public byte Hand { get; }

The hand (Hand).

public ItemView Item { get; }

The block item used.

public Player Player { get; }

The player.

public BlockPos Pos { get; }

Where the block goes.

public static ushort CatalogueId { get; }

Catalogue id (stable ABI).

public static bool IsCancellable { get; }

Whether handlers can cancel the event.

public static string Key { get; }

Registry key of the event.

BlockPos · BlockState · Hand · IEvent · ItemView · Player