Change name of a custom crafting recipe

Discussion in 'Plugin Development' started by Iegendary, Jun 27, 2015.

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

    Iegendary

    Hello I was wondering how do you change the name of the item you craft in a custom crafting recipe, I'm using JTGaming2012's code for making the recipe right now

    Code:
    package me.jack.exprecipe;
    import org.bukkit.Material;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapedRecipe;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Recipe extends JavaPlugin {
    
    public void onEnable() {
    
    ItemStack bottle = new ItemStack(Material.EXP_BOTTLE, 1);
    
    ShapedRecipe expBottle = new ShapedRecipe(bottle);
    
    expBottle.shape("*%*","%B%","*%*");
    
    expBottle.setIngredient('*', Material.INK_SACK, 2);
    expBottle.setIngredient('%', Material.SUGAR);
    expBottle.setIngredient('B', Material.GLASS_BOTTLE);
    
    getServer().addRecipe(expBottle);
    
    }
    
    public void onDisable() {
    
     
  2. Offline

    mrCookieSlime

    Moved to Plugin Development.
     
  3. Offline

    timtower Administrator Administrator Moderator

    @Iegendary Get the meta of bottle, set the display name, set the meta on the stack.
     
  4. Offline

    Iegendary

    I'm sorry about the noob question but how would i do this kind of thing? I just started trying to make plugins a few days ago.
     
  5. Offline

    timtower Administrator Administrator Moderator

  6. Some explanation:
    ItemStack#getItemMeta() returns the item's meta data.
    In there you can set the item's display name, lore etc.
    Once you have that done you need to call ItemStack#setItemMeta(ItemMeta) or the item doesn't have the display name
     
  7. Offline

    Iegendary

    @timtower Okay I got it working thank you very much timtower!
     
Thread Status:
Not open for further replies.

Share This Page