Class endstone::PlayerInteractEvent¶
ClassList > endstone > PlayerInteractEvent
Represents an event that is called when a player right-clicks a block.
#include <endstone/event/player/player_interact_event.h>
Inherits the following classes: endstone::Cancellable
Public Types¶
Type | Name |
---|---|
enum | Action |
Public Functions¶
Type | Name |
---|---|
ENDSTONE_EVENT (PlayerInteractEvent) |
|
PlayerInteractEvent (Player & player, Action action, ItemStack * item, Block * block_clicked, BlockFace block_face, const std::optional< Vector< float > > & clicked_position) |
|
Action | getAction () const Returns the action type. |
Block * | getBlock () const Returns the clicked block. |
BlockFace | getBlockFace () const Returns the face of the block that was clicked. |
std::optional< Vector< float > > | getClickedPosition () const Gets the exact position on the block the player interacted with. |
ItemStack * | getItem () const Returns the item in hand represented by this event. |
bool | hasBlock () const Check if this event involved a block. |
bool | hasItem () const Check if this event involved an item. |
Public Functions inherited from endstone::Cancellable¶
Type | Name |
---|---|
virtual void | cancel () Cancel this event. A cancelled event will not be executed in the server, but will still pass to other plugins. |
virtual bool | isCancelled () override const Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins. |
virtual void | setCancelled (bool cancel) override Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins. |
Public Functions inherited from endstone::ICancellable¶
Type | Name |
---|---|
virtual void | cancel () = 0 |
virtual bool | isCancelled () const = 0 |
virtual void | setCancelled (bool cancel) = 0 |
virtual | ~ICancellable () = default |
Public Types Documentation¶
enum Action¶
enum endstone::PlayerInteractEvent::Action {
LeftClickBlock,
RightClickBlock,
LeftClickAir,
RightClickAir
};
Public Functions Documentation¶
function ENDSTONE_EVENT¶
function PlayerInteractEvent¶
inline endstone::PlayerInteractEvent::PlayerInteractEvent (
Player & player,
Action action,
ItemStack * item,
Block * block_clicked,
BlockFace block_face,
const std::optional< Vector < float > > & clicked_position
)
function getAction¶
Returns the action type.
Returns:
Action returns the type of interaction
function getBlock¶
Returns the clicked block.
Returns:
Block returns the block clicked with this item.
function getBlockFace¶
Returns the face of the block that was clicked.
Returns:
BlockFace returns the face of the block that was clicked
function getClickedPosition¶
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.
function getItem¶
Returns the item in hand represented by this event.
Returns:
ItemStack the item used
function hasBlock¶
Check if this event involved a block.
Returns:
boolean true if it did
function hasItem¶
Check if this event involved an item.
Returns:
boolean true if it did
The documentation for this class was generated from the following file include/endstone/event/player/player_interact_event.h