Skip to content

Class endstone::PlayerBucketEvent

ClassList > endstone > PlayerBucketEvent

Provides common data for events involving a player's bucket interaction.

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

Inherits the following classes: endstone::Cancellable

Inherited by the following classes: endstone::PlayerBucketEmptyEvent, endstone::PlayerBucketFillEvent

Public Functions

Type Name
PlayerBucketEvent (const NotNull< Player > & player, const Nullable< Block > & block, const NotNull< Block > & block_clicked, BlockFace block_face, const ItemType & bucket, std::optional< ItemStack > item_stack, EquipmentSlot hand)
const Nullable< Block > & getBlock () const
Gets the block involved in this event.
const NotNull< Block > & getBlockClicked () const
Gets the block clicked by the player.
BlockFace getBlockFace () const
Gets the face on the clicked block.
const ItemType & getBucket () const
Gets the bucket used in this event.
EquipmentSlot getHand () const
Gets the hand used in this event.
const std::optional< ItemStack > & getItemStack () const
Gets the resulting item in the player's hand.
void setItemStack (std::optional< ItemStack > item_stack)
Sets the resulting item in the player's hand.
~PlayerBucketEvent () override

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

Public Functions Documentation

function PlayerBucketEvent

inline endstone::PlayerBucketEvent::PlayerBucketEvent (
    const  NotNull < Player > & player,
    const  Nullable < Block > & block,
    const  NotNull < Block > & block_clicked,
    BlockFace block_face,
    const  ItemType & bucket,
    std::optional< ItemStack > item_stack,
    EquipmentSlot hand
) 

function getBlock

Gets the block involved in this event.

inline const  Nullable < Block > & endstone::PlayerBucketEvent::getBlock () const

Returns:

the block involved in this event, or a null handle if unavailable


function getBlockClicked

Gets the block clicked by the player.

inline const  NotNull < Block > & endstone::PlayerBucketEvent::getBlockClicked () const

Returns:

the clicked block


function getBlockFace

Gets the face on the clicked block.

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

Returns:

the clicked block face


function getBucket

Gets the bucket used in this event.

inline const  ItemType & endstone::PlayerBucketEvent::getBucket () const

Returns:

the bucket item type


function getHand

Gets the hand used in this event.

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

Note:

This is always EquipmentSlot::Hand, because Bedrock does not report which hand was used for this interaction.

Returns:

the hand


function getItemStack

Gets the resulting item in the player's hand.

inline const std::optional< ItemStack > & endstone::PlayerBucketEvent::getItemStack () const

Returns:

the resulting item stack, or std::nullopt if unavailable


function setItemStack

Sets the resulting item in the player's hand.

inline void endstone::PlayerBucketEvent::setItemStack (
    std::optional< ItemStack > item_stack
) 

Parameters:

  • item_stack the item stack to write back after the event, or std::nullopt

function ~PlayerBucketEvent

endstone::PlayerBucketEvent::~PlayerBucketEvent () override


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