Class endstone::EnchantItemEvent¶
ClassList > endstone > EnchantItemEvent
Called when a player enchants an item at an enchanting table. More...
#include <endstone/event/enchantment/enchant_item_event.h>
Inherits the following classes: endstone::Cancellable
Public Types¶
| Type | Name |
|---|---|
| typedef std::unordered_map< const Enchantment *, int > | Enchantments |
Public Functions¶
| Type | Name |
|---|---|
| ENDSTONE_EVENT (EnchantItemEvent) |
|
| EnchantItemEvent (Inventory & inventory, const NotNull< Player > & enchanter, const NotNull< Block > & enchant_block, ItemStack item, int exp_level_cost, Enchantments enchants_to_add, int which_button) |
|
| const NotNull< Block > & | getEnchantBlock () const Gets the enchanting table involved in this event. |
| const NotNull< Player > & | getEnchanter () const Gets the player enchanting the item. |
| const Enchantments & | getEnchantsToAdd () const Gets the enchantments that will be applied to the item. |
| Enchantments & | getEnchantsToAdd () Gets the enchantments that will be applied to the item. |
| int | getExpLevelCost () const Gets the minimum player level required by the selected option. |
| const ItemStack & | getItem () const Gets the item being enchanted. |
| void | setExpLevelCost (int exp_level_cost) Sets the minimum player level required by the selected option. |
| void | setItem (ItemStack item) Sets the item to enchant. |
| int | whichButton () const Gets the selected enchanting button. |
Public Functions inherited from 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¶
| 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:
Cancelling the event leaves the item, the player's experience levels and the lapis lazuli untouched.
Note:
Bedrock does not reveal a single hinted enchantment for an offer, so every enchantment the offer applies is listed in getEnchantsToAdd().
Public Types Documentation¶
typedef Enchantments¶
Public Functions Documentation¶
function ENDSTONE_EVENT¶
function EnchantItemEvent¶
inline endstone::EnchantItemEvent::EnchantItemEvent (
Inventory & inventory,
const NotNull < Player > & enchanter,
const NotNull < Block > & enchant_block,
ItemStack item,
int exp_level_cost,
Enchantments enchants_to_add,
int which_button
)
function getEnchantBlock¶
Gets the enchanting table involved in this event.
Returns:
the enchanting table
function getEnchanter¶
Gets the player enchanting the item.
Returns:
the player enchanting the item
function getEnchantsToAdd [½]¶
Gets the enchantments that will be applied to the item.
Returns:
the enchantments and their levels
function getEnchantsToAdd [2/2]¶
Gets the enchantments that will be applied to the item.
Returns:
the enchantments and their levels
function getExpLevelCost¶
Gets the minimum player level required by the selected option.
The number of levels consumed remains determined by the selected button.
Returns:
the minimum required player level
function getItem¶
Gets the item being enchanted.
Returns:
the item being enchanted
function setExpLevelCost¶
Sets the minimum player level required by the selected option.
Parameters:
exp_level_costthe minimum required player level
function setItem¶
Sets the item to enchant.
Parameters:
itemthe item to enchant
function whichButton¶
Gets the selected enchanting button.
Returns:
the selected button, from 0 to 2
The documentation for this class was generated from the following file include/endstone/event/enchantment/enchant_item_event.h