Class PlayerSelectCraftingRecipeEvent

java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.player.PlayerEvent
net.risingworld.api.events.player.ui.PlayerSelectCraftingRecipeEvent

public final class PlayerSelectCraftingRecipeEvent extends PlayerEvent
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 PlayerCraftItemEvent instead.
See Also:

Example: Show the name of the selected recipe
1@EventMethod
2public void onPlayerSelectCraftingRecipe(PlayerSelectCraftingRecipeEvent event) {
3 Crafting.Recipe recipe = event.getRecipe();
4 if (recipe == null) return;
5 event.getPlayer().showStatusMessage("Selected " + recipe.name + " (variant: " + event.getVariant() + ")", 3);
6}
  • Method Details

    • getRecipe

      public Crafting.Recipe 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 the PlayerCraftItemEvent (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 the PlayerChangeCraftingAmountEvent.
      Returns:
      the amount of items to craft.