CraftItemEvent with custom items

Discussion in 'Plugin Development' started by U2F, Jun 2, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    U2F

    I have created a custom item recipe and now I want to detect for crafting it using "CraftItemEvent", here is my code:
    Code:
        @EventHandler
        public void craftingRewards(CraftItemEvent event)
        {
            Player player = (Player) event.getWhoClicked();
            ItemStack craftedItem = event.getCurrentItem();
          
            if(craftedItem.getType().equals())
            {
              
            }
        }
    Inside the parenthesis at the 7th line, I need to write what item I want to detect for, but I don't know how to call it...
    Can someone help me?
     
  2. Online

    timtower Administrator Administrator Moderator

    @U2F Well, what item do you want to check for?
     
  3. Offline

    U2F

    it's called thoraxeRecipe
     
  4. Online

    timtower Administrator Administrator Moderator

    @U2F Then you check if craftedItem is similar to that.
     
  5. Offline

    U2F

    It's called thoraxeRecipe

    but how to do that?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  6. Online

    timtower Administrator Administrator Moderator

  7. Offline

    MightyOne

    Your recipe has an result and your event has this current item. Look if they are similar
     
  8. Try using getResult() from the recipe and it will get you the exact item. You can then check data for the item manually (check the type, the damage, then the item meta’s display name). Otherwise, you can save the Thor axe and check isSimilar from that.
     
Thread Status:
Not open for further replies.

Share This Page