Help with Recipes

Discussion in 'Plugin Development' started by Nikok34, Jul 28, 2013.

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

    Nikok34

    So I know there is a way to create custom crafting recipes, however I cannot find the way to do it. I've been searching it up for a while now and was wondering if anyone could just help me out with it? Thanks in advance.
     
  2. Offline

    MistPhizzle

    Code:java
    1.  
    2. // Create Recipe
    3. ShapedRecipe ironBarding = new ShapedRecipe(new ItemStack(Material.IRON_BARDING)).shape(" i", "iii", "i i").setIngredient('i', Material.IRON_INGOT);
    4. // Load Recipe
    5. getServer().addRecipe(ironBarding);
    6.  
    7.  


    That code was in my onEnable class for a private plugin on mine, used to Craft Iron Horse Armor.

    To explain it a little better, Shaped Recipes have 3 rows (Each row of the workbench). Each one is represented with a String (""). Each String is 3 characters long, can be 3 spaces if you want (for an empty row). So in my example above, an Iron Ingot (i), filled the last spot on the first row, all slots on the second row, and the first and last slots on the last row.

    Make sure you use the Strings properly to prevent errors, you can use more than one material (Just make sure you specify each with setIngredient.)
     
  3. Offline

    Nikok34

    Thank you! I'll try that out right now.

    Is there a crafting event in which you can get the item crafted and the recipe used by any chance? As in I want to have an event for someone crafting my item, and if the recipe is used, to rename it to something else.

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

    Compressions

    Nikok34 You can add ItemMeta when you recreate the recipe.
     
  5. Offline

    Nikok34

    Is there a crafting event in which you can get the item crafted and the recipe used by any chance? As in I want to have an event for someone crafting my item, and if the recipe is used, to rename it to something else.

    whoops dupe post sorry

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

    xTrollxDudex

    Nikok34
    CraftItemEvent. Look in the javadocs and find the methods, it should have a recipe and result method
     
Thread Status:
Not open for further replies.

Share This Page