Get recipes that can be made from itemstacks

Discussion in 'Plugin Development' started by thechrisanator, Feb 25, 2020.

  1. Offline


    Is there a good way to get every item that can be created from a list of Materials / ItemStacks?
    getRecipesFromMats(Material.OAK_WOOD, Material.STONE);
    would return: stone button, wood button, stone bricks, door, chest, stone slab, etc etc
  2. Offline


    Bukkit#recipeIterator() would be a good place to start.

    Loop over each recipe, and use Recipe#getInput() to check the inputs. (It might not be getInput() anymore)

    EDIT: More googling led me to a potentially better solution. Try this out.
    Last edited: Feb 25, 2020
  3. Offline


    That gets the recipe for the item, he wanted the items from the recipe contents.

    Your first suggestion still seems like the best solution.

    Look at the classes implementing Recipe, then check for them and use their methods for getting the item inputs.
  4. Offline


    I just feel like iterating through *every* single recipe is quite resource intensive.
    But It's looking like it's going to be the only way
  5. Offline


    I think it's the only way.

    Plus, I don't see it being massively intensive, and if it does turn out to be I see no issue in creating a BukkitRunnable to compute ten recipes every tick or so. That's 200 recipes a second. But of course that's your choice.

Share This Page