Skip to content

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::PlayerEvent

Public Static Attributes

Type Name
const std::string NAME = = "PlayerInteractEvent"

Public Functions

Type Name
PlayerInteractEvent (Player & player, std::unique_ptr< ItemStack > item, std::unique_ptr< Block > block_clicked, BlockFace block_face, const Vector< float > & clicked_position)
Block * getBlock () const
Returns the clicked block.
BlockFace getBlockFace () const
Returns the face of the block that was clicked.
Vector< float > getClickedPosition () const
Gets the exact position on the block the player interacted with.
virtual std::string getEventName () override const
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.
virtual bool isCancellable () override const
~PlayerInteractEvent () override

Public Functions inherited from endstone::PlayerEvent

See endstone::PlayerEvent

Type Name
PlayerEvent (Player & player)
Player & getPlayer () const
~PlayerEvent () override

Public Functions inherited from endstone::Event

See endstone::Event

Type Name
Event (bool async=false)
Event (const Event &) = delete
virtual std::string getEventName () const = 0
bool isAsynchronous () const
virtual bool isCancellable () const = 0
bool isCancelled () const
Event & operator= (const Event &) = delete
void setCancelled (bool cancel)
virtual ~Event () = default

Public Static Attributes Documentation

variable NAME

const std::string endstone::PlayerInteractEvent::NAME;

Public Functions Documentation

function PlayerInteractEvent

inline endstone::PlayerInteractEvent::PlayerInteractEvent (
    Player & player,
    std::unique_ptr< ItemStack > item,
    std::unique_ptr< Block > block_clicked,
    BlockFace block_face,
    const Vector < float > & clicked_position
) 

function getBlock

Returns the clicked block.

inline Block * endstone::PlayerInteractEvent::getBlock () const

Returns:

Block returns the block clicked with this item.


function getBlockFace

Returns the face of the block that was clicked.

inline BlockFace endstone::PlayerInteractEvent::getBlockFace () const

Returns:

BlockFace returns the face of the block that was clicked


function getClickedPosition

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

inline Vector < float > endstone::PlayerInteractEvent::getClickedPosition () const

All vector components are between 0.0 and 1.0 inclusive.

Returns:

the clicked position.


function getEventName

inline virtual std::string endstone::PlayerInteractEvent::getEventName () override const

Gets a user-friendly identifier for this event.

Returns:

name of this event

Implements endstone::Event::getEventName


function getItem

Returns the item in hand represented by this event.

inline ItemStack * endstone::PlayerInteractEvent::getItem () const

Returns:

ItemStack the item used


function hasBlock

Check if this event involved a block.

inline bool endstone::PlayerInteractEvent::hasBlock () const

Returns:

boolean true if it did


function hasItem

Check if this event involved an item.

inline bool endstone::PlayerInteractEvent::hasItem () const

Returns:

boolean true if it did


function isCancellable

inline virtual bool endstone::PlayerInteractEvent::isCancellable () override const

Whether the event can be cancelled by a plugin or the server.

Returns:

true if this event can be cancelled

Implements endstone::Event::isCancellable


function ~PlayerInteractEvent

endstone::PlayerInteractEvent::~PlayerInteractEvent () override


The documentation for this class was generated from the following file include/endstone/event/player/player_interact_event.h