Class PlayerChangeCraftingAmountEvent
java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.player.PlayerEvent
net.risingworld.api.events.player.ui.PlayerChangeCraftingAmountEvent
Called when a player changes the amount of items to craft in the crafting menu (e.g. via
the plus/minus buttons or the input field). This event is not called if the amount changes
because the player selects another recipe, use
While the player holds a plus/minus button (or changes the amount with a gamepad), the amount is only sent to the server every 250 ms, so not every single intermediate value triggers this event. The final amount is always sent once the player releases the button. The amount is set 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
Clients only send amount changes to the server if any plugin listens for this event, so it does not cause network traffic otherwise.
PlayerSelectCraftingRecipeEvent.getAmount() instead.While the player holds a plus/minus button (or changes the amount with a gamepad), the amount is only sent to the server every 250 ms, so not every single intermediate value triggers this event. The final amount is always sent once the player releases the button. The amount is set 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.Clients only send amount changes to the server if any plugin listens for this event, so it does not cause network traffic otherwise.
- See Also:
- Example: Show the amount the player wants to craft
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionintGets the new amount of items the player wants to craft.Gets the recipe which is currently selected in the crafting menu.intGets the currently selected variant of the recipe, or -1 if no variant is selected.Methods inherited from class PlayerEvent
getPlayer
-
Method Details
-
getRecipe
Gets the recipe which is currently selected in the crafting menu.- Returns:
- the selected crafting recipe.
-
getVariant
public int getVariant()Gets the currently selected variant of the recipe, or -1 if no variant is selected. SeePlayerSelectCraftingRecipeEvent.getVariant()for more information.- Returns:
- the selected variant, or -1 if no variant is selected.
-
getAmount
public int getAmount()Gets the new amount of items the player wants to craft.- Returns:
- the amount of items to craft.
-