BlockBreakEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct BlockBreakEvent : IEventA 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.
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
Constructor |
Creates the event (for firing it from a plugin; native code builds its own). |
Constructor
Section titled “Constructor”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 |
Properties
Section titled “Properties”| 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. |
BlockState
Section titled “BlockState”public BlockState BlockState { get; }The block state about to be broken.
Cancelled
Section titled “Cancelled”public bool Cancelled { get; set; }Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
DropItems
Section titled “DropItems”public bool DropItems { get; set; }Whether the block drops its loot (the experience is controlled by experience).
Experience
Section titled “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.
Player
Section titled “Player”public Player Player { get; }The player.
public BlockPos Pos { get; }The block.
public ItemView Tool { get; }The item in the main hand.
CatalogueId
Section titled “CatalogueId”public static ushort CatalogueId { get; }Catalogue id (stable ABI).
IsCancellable
Section titled “IsCancellable”public static bool IsCancellable { get; }Whether handlers can cancel the event.
public static string Key { get; }Registry key of the event.
See also
Section titled “See also”BlockPos · BlockState · IEvent · ItemView · Player