Get recipes that can be made from itemstacks

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

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

    thechrisanator

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

    CraftCreeper6

    @thechrisanator
    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

    KarimAKL

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

    Your first suggestion still seems like the best solution.

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

    thechrisanator

    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

    CraftCreeper6

    @thechrisanator
    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.
     
Thread Status:
Not open for further replies.

Share This Page