BlockPlaceEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct BlockPlaceEvent : IEventA 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.
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 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 |
Properties
Section titled “Properties”| 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. |
Against
Section titled “Against”public BlockPos Against { get; }The clicked block.
BlockState
Section titled “BlockState”public BlockState BlockState { get; set; }The state that will be placed.
Cancelled
Section titled “Cancelled”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.
Player
Section titled “Player”public Player Player { get; }The player.
public BlockPos Pos { get; }Where the block goes.
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.