Class endstone::PlayerCraftItemEvent¶
ClassList > endstone > PlayerCraftItemEvent
Called when a player crafts an item, either inside a crafting grid or straight from the recipe book. More...
#include <endstone/event/player/player_craft_item_event.h>
Inherits the following classes: endstone::Cancellable
Public Functions¶
| Type | Name |
|---|---|
| ENDSTONE_EVENT (PlayerCraftItemEvent) |
|
| PlayerCraftItemEvent (const NotNull< Player > & player, NotNull< Recipe > recipe, std::vector< ItemStack > ingredients, std::vector< ItemStack > results, int repetitions) |
|
| const std::vector< ItemStack > & | getIngredients () const Gets the ingredients a single craft consumes. |
| NotNull< Recipe > | getRecipe () const |
| int | getRepetitions () const Gets the number of times the recipe is being crafted. |
| const std::vector< ItemStack > & | getResults () const Gets the items a single craft produces. |
| void | setRepetitions (int repetitions) Sets the number of times the recipe is being crafted. |
| void | setResults (std::vector< ItemStack > results) Sets the items a single craft produces. |
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:
If the event is cancelled the item will not be crafted and the ingredients will not be consumed.
Public Functions Documentation¶
function ENDSTONE_EVENT¶
function PlayerCraftItemEvent¶
inline endstone::PlayerCraftItemEvent::PlayerCraftItemEvent (
const NotNull < Player > & player,
NotNull < Recipe > recipe,
std::vector< ItemStack > ingredients,
std::vector< ItemStack > results,
int repetitions
)
function getIngredients¶
Gets the ingredients a single craft consumes.
Note:
These are the items in the crafting grid where the player used one. Crafting from the recipe book never fills the grid, so the ingredients then come from the recipe instead, and an ingredient that accepts several items reports the one the recipe names rather than the one the player supplied.
Returns:
the ingredients the craft consumes
function getRecipe¶
Returns:
A copy of the current recipe on the crafting matrix.
function getRepetitions¶
Gets the number of times the recipe is being crafted.
This is usually 1, but is higher when a batch is crafted at once, such as a shift click in the recipe book.
Returns:
the number of times the recipe is being crafted
function getResults¶
Gets the items a single craft produces.
A recipe usually produces one item, but may produce several, and an ingredient that leaves a remainder behind contributes one too.
Returns:
the items the craft produces
function setRepetitions¶
Sets the number of times the recipe is being crafted.
Note:
Values are clamped to the 0-255 range the server accepts.
Parameters:
repetitionsthe number of times the recipe is being crafted
function setResults¶
Sets the items a single craft produces.
Note:
Results are replaced one for one, so any beyond the number the recipe produces are ignored. Cancel the event to stop the craft instead.
Parameters:
resultsthe items the craft should produce
The documentation for this class was generated from the following file include/endstone/event/player/player_craft_item_event.h