Get ingredient list for an existing crafting recipe.

Discussion in 'Plugin Development' started by asdeeeasd, Jul 25, 2012.

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

    asdeeeasd

    I am really new to all this plugin stuff. My question is as follows: is there any way to get the list of ingredients required to craft a certain item? When a bukkit server is loading, it says something like "x recipes and y achievements", so my guess is that recipes ARE stored somewhere. I have spent a long time tinkering around but haven't come any close to the solution, though. Blessings upon you for your responses and sincere apologies for broken language and general stupidness in advance.
     
  2. Offline

    Njol

    Use Bukkit.getRecipesFor(item) which returns a set of Recipes that can either be ShapelessRecipes, ShapedRecipes and/or FurnaceRecipes. Depending on what you want to do you might have to iterate over all recipes or only check whether there are any recipes for that item.

    edit: item is an itemStack, e.g. new ItemStack(Material.WHATEVER).
    I do not know how well this method works for items where multiple items are crafted at once, e.g. torches.
     
  3. Offline

    asdeeeasd

    My eternal gratitude, sir, everything works just fine
     
  4. Please could you write the code?
     
Thread Status:
Not open for further replies.

Share This Page