Solved Change name of craft result

Discussion in 'Plugin Development' started by idkG0D, Jan 31, 2019.

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

    idkG0D

    I want to change the name of the craft result. Like as...

    If the player was trying to make SOUP, i want to set the name of the crafted item(MUSHROOM_SOUP) to(SOPA)
    I need to use CraftItemEvent?

    My code:
    Code:
        @EventHandler
        public void craft(CraftItemEvent e){
    
            ItemStack sopa = new ItemStack(Material.MUSHROOM_SOUP);
            ItemMeta sopam = sopa.getItemMeta();
            sopam.setDisplayName("§a§lSOPA");
            sopa.setItemMeta(sopam);
    
            if(e.getRecipe().getResult().getType() == Material.MUSHROOM_SOUP){
                e.getRecipe().getResult().setItemMeta(sopam);
    
            }
        }
    }
    It's a simple code.
     
  2. Offline

    BlaSfaiMe

    Just add "sopam.setDisplayName("§a§lSOPA");" under "e.getRecipe().getResult().setItemMeta(sopam);" @idkG0D
     
  3. Offline

    timtower Administrator Administrator Moderator

    He already does that before hand though.

    @idkG0D Why not remove the recipe and add a new one?
     
  4. Offline

    idkG0D

    @timtower I'll try to do it, thanks ^^ but, how i do that?
     
  5. If you don't add a new recipe I suggest using the PrepareItemCraftEvent instead. But you could have similar problems with that one.

    Edit: and what about e.setResult(ItemStack)?
    You should also try this
     
    Last edited: Feb 2, 2019
Thread Status:
Not open for further replies.

Share This Page