Skip to content

BlockBreakEvent

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

public ref struct BlockBreakEvent : IEvent

A player is about to break a block. Cancel to keep the block (the client is resynced).

Id 20
Key mc:block_break
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Player player no (readonly) The player.
Pos BlockPos no (readonly) The block.
BlockState blockstate no (readonly) The block state about to be broken.
DropItems bool yes Whether the block drops its loot (the experience is controlled by experience).
Experience int yes The experience orbs dropped by the block, pre-filled with what vanilla would drop (ores, spawners, sculk; silk touch applied). Set 0 to drop none or any amount to drop that many; independent of drop_items.
Tool item no (readonly) The item in the main hand.

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 BlockBreakEvent(Player player, BlockPos pos, BlockState blockState, bool dropItems, int experience, ItemView tool)

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
blockState BlockState
dropItems bool
experience int
tool ItemView
Member Description
BlockState BlockState { get; } The block state about to be broken.
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
bool DropItems { get; set; } Whether the block drops its loot (the experience is controlled by experience).
int Experience { get; set; } The experience orbs dropped by the block, pre-filled with what vanilla would drop (ores, spawners, sculk; silk touch applied).
Player Player { get; } The player.
BlockPos Pos { get; } The block.
ItemView Tool { get; } The item in the main hand.
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 BlockState BlockState { get; }

The block state about to be broken.

public bool Cancelled { get; set; }

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

public bool DropItems { get; set; }

Whether the block drops its loot (the experience is controlled by experience).

public int Experience { get; set; }

The experience orbs dropped by the block, pre-filled with what vanilla would drop (ores, spawners, sculk; silk touch applied). Set 0 to drop none or any amount to drop that many; independent of drop_items.

public Player Player { get; }

The player.

public BlockPos Pos { get; }

The block.

public ItemView Tool { get; }

The item in the main hand.

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 · IEvent · ItemView · Player