endstone::PlayerInteractEvent
Represents an event that is called when a player right-clicks a block.
Bases: endstone::Cancellable< PlayerEvent >
Types:
| Name | Description |
|---|---|
Action |
Functions:
| Name | Description |
|---|---|
PlayerInteractEvent | |
getAction | Returns the action type. |
getBlock | Returns the clicked block. |
getBlockFace | Returns the face of the block that was clicked. |
getClickedPosition | Gets the exact position on the block the player interacted with. |
getItem | Returns the item in hand represented by this event. |
hasBlock | Check if this event involved a block. |
hasItem | Check 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() constReturns the action type.
Returns:
Action returns the type of interaction
getBlock
Block *getBlock() constReturns the clicked block.
Returns:
Block returns the block clicked with this item.
getBlockFace
BlockFace getBlockFace() constReturns 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() constGets 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() constReturns the item in hand represented by this event.
Returns:
ItemStack the item used
hasBlock
bool hasBlock() constCheck if this event involved a block.
Returns:
boolean true if it did
hasItem
bool hasItem() constCheck if this event involved an item.
Returns:
boolean true if it did