Skip to content

Class endstone::PlayerItemConsumeEvent

ClassList > endstone > PlayerItemConsumeEvent

Called when a player is finishing consuming an item (food, potion, milk bucket). More...

  • #include <endstone/event/player/player_item_consume_event.h>

Inherits the following classes: endstone::Cancellable

Public Functions

Type Name
PlayerItemConsumeEvent (Player & player, ItemStack item, EquipmentSlot hand)
EquipmentSlot getHand () const
Get the hand used to consume the item.
const ItemStack & getItem () const
Gets the item that is being consumed.

Public Functions inherited from endstone::Cancellable

See endstone::Cancellable

Type Name
virtual void cancel ()
Cancel this event.
virtual bool isCancelled () override const
Gets the cancellation state of this event.
virtual void setCancelled (bool cancel) override
Sets the cancellation state of this event.

Public Functions inherited from endstone::ICancellable

See endstone::ICancellable

Type Name
virtual void cancel () = 0
Cancels this event.
virtual bool isCancelled () const = 0
Gets the cancellation state of this event.
virtual void setCancelled (bool cancel) = 0
Sets the cancellation state of this event.
virtual ~ICancellable () = default

Detailed Description

Note:

If the ItemStack is modified the server will use the effects of the new item and not remove the original one from the player's inventory.

Note:

If the event is cancelled the effect will not be applied and the item will not be removed from the player's inventory.

Public Functions Documentation

function PlayerItemConsumeEvent

inline explicit endstone::PlayerItemConsumeEvent::PlayerItemConsumeEvent (
    Player & player,
    ItemStack item,
    EquipmentSlot hand
) 

function getHand

Get the hand used to consume the item.

inline EquipmentSlot endstone::PlayerItemConsumeEvent::getHand () const

Returns:

the hand


function getItem

Gets the item that is being consumed.

inline const  ItemStack & endstone::PlayerItemConsumeEvent::getItem () const

Returns:

an ItemStack for the item being consumed



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