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() 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