Skip to Content
⚠ Under Construction
ReferenceC++ APIPlayerInteractEvent

endstone::PlayerInteractEvent

Represents an event that is called when a player right-clicks a block.

Bases: endstone::Cancellable< PlayerEvent >

Types:

NameDescription
Action

Functions:

NameDescription
PlayerInteractEvent
getActionReturns the action type.
getBlockReturns the clicked block.
getBlockFaceReturns the face of the block that was clicked.
getClickedPositionGets the exact position on the block the player interacted with.
getItemReturns the item in hand represented by this event.
hasBlockCheck if this event involved a block.
hasItemCheck if this event involved an item.

Action

enum Action { LeftClickBlock, RightClickBlock, LeftClickAir, RightClickAir };

PlayerInteractEvent

PlayerInteractEvent(Player &player, Action action, ItemStack *item, Block *block_clicked, BlockFace block_face, const std::optional<Vector<float>> &clicked_position)

getAction

Action getAction() const

Returns the action type.

Returns:

Action returns the type of interaction

getBlock

Block *getBlock() const

Returns the clicked block.

Returns:

Block returns the block clicked with this item.

getBlockFace

BlockFace getBlockFace() const

Returns the face of the block that was clicked.

Returns:

BlockFace returns the face of the block that was clicked

getClickedPosition

std::optional<Vector<float>> getClickedPosition() const

Gets the exact position on the block the player interacted with.

Note:

This will be std::nullopt outside of Action.RightClickBlock

Note:

All vector components are between 0.0 and 1.0 inclusive.

Returns:

the clicked position.

getItem

ItemStack *getItem() const

Returns the item in hand represented by this event.

Returns:

ItemStack the item used

hasBlock

bool hasBlock() const

Check if this event involved a block.

Returns:

boolean true if it did

hasItem

bool hasItem() const

Check if this event involved an item.

Returns:

boolean true if it did

Last updated on