ItemMeta in ShapelessRecipe

Discussion in 'Plugin Development' started by Maximvdw, Jun 17, 2014.

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

    Maximvdw

    Dear,
    Is there a way to add ItemMeta to the recipe in a shapelessRecipe, or will I have to do the listening to items
    manually?
    - Maxim
     
  2. Offline

    fireblast709

    Maximvdw
    1. Create ItemStack
    2. add ItemMeta
    3. register ShapelessRecipe with 1.
     
  3. Offline

    Maximvdw

  4. Offline

    cs475x

    Maximvdw I think this is what he meant, tested and working.
    Code:java
    1. ItemStack item = new ItemStack(Material.NAME_TAG);
    2. ItemMeta meta = item.getItemMeta();
    3.  
    4. meta.setDisplayName("Custom name");
    5. item.setItemMeta(meta);
    6.  
    7. ShapelessRecipe nametag = new ShapelessRecipe(item);
    8. // Add ingredients
     
  5. Offline

    Maximvdw

    That will return the itemstack, but I want to craft 'with' a custom itemstack.

    Like two "Blablabla Sword" with some custom lores will get you a specfic item. But you can only define the material of those swords.
     
  6. Offline

    Relicum


    You have been given the correct answer already. The answer given allows you to do exactly what your looking for. Or your not explaining yourself very well.

    I get you now, you would need to use different materials for a start

    One thing I will say is make sure you have this in the onDisable

    Code:java
    1. Bukkit.clearRecipes();


    As recipes do persist and you end up with multiple recipes for the same item.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  7. Offline

    Maximvdw

    bump* ^- The above method is not required if using listeners instead of adding the item in bukkit. Should I use the PrepareCraftItemEvent to manually create an advanced recipe?
     
Thread Status:
Not open for further replies.

Share This Page