Class PlayerSelectCraftingRecipeEvent
java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.player.PlayerEvent
net.risingworld.api.events.player.ui.PlayerSelectCraftingRecipeEvent
Called when a player selects a recipe in the crafting menu, or a variant (e.g. a texture
or shape) of the currently selected recipe. Selecting the same recipe and variant again
does not trigger this event again until the player closes the crafting menu. Deselecting a recipe
does not trigger this event.
The selection happens on the client, so this event arrives with a small delay (network latency) and cannot be cancelled. If you want to prevent the player from crafting something, use the
The selection happens on the client, so this event arrives with a small delay (network latency) and cannot be cancelled. If you want to prevent the player from crafting something, use the
PlayerCraftItemEvent instead.- See Also:
- Example: Show the name of the selected recipe
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionintGets the amount of items the player currently wants to craft.Gets the recipe the player has selected.intGets the selected variant of the recipe, or -1 if no variant is selected (i.e. if the player only selected the recipe itself).Methods inherited from class PlayerEvent
getPlayer
-
Method Details
-
getRecipe
Gets the recipe the player has selected.- Returns:
- the selected crafting recipe.
-
getVariant
public int getVariant()Gets the selected variant of the recipe, or -1 if no variant is selected (i.e. if the player only selected the recipe itself). For construction elements this is the selected texture (block id), for block materials this is the selected shape (construction id). This value matches the variant of thePlayerCraftItemEvent(if the player crafts the selected recipe).- Returns:
- the selected variant, or -1 if no variant is selected.
-
getAmount
public int getAmount()Gets the amount of items the player currently wants to craft. This is the amount shown in the crafting menu at the time the recipe was selected (it may differ from 1 if the player selected this recipe before). If you want to get informed about later changes, use thePlayerChangeCraftingAmountEvent.- Returns:
- the amount of items to craft.
-