Crafting recipes data structure available from plugin?

Discussion in 'Plugin Development' started by Fipil, Feb 16, 2012.

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

    Fipil

    Hi all, please I'm wondering if there is any crafting recipes database available and understandable by program. I'm thinking about a new plugin, let's call it crafting table.
    It'll be a 3x3 grid of small chests standing on some base, made from golden blocks for example.
    When the base receives a redstone signal - the plugin will examine the chests and if there are some items, plugin searches for proper crafting recipe in some database.
    If the recipe exists, the plugin create a new crafted item and put it to some output chest.
    The main purpose of the plugin is to allow creating of some automatic crafting factories.
    So my question is: is there available any database/data structure of all existing crafting recipes which I can use? Or should I create my own configuration file, fill it by recipes and maintain it up to date manually?
    Thanks.
     
  2. Offline

    Njol

    There isn't any getRecipes() method in Bukkit, but there exists a method in net.minecraft.server: net.minecraft.server.CraftingManager.getInstance().b().
    Now it's up to you to decide which one to use. But remember that b() also returns recipes added by other plugins, so that might be the better choice.
     
  3. Offline

    mushroomhostage

    I'd say net.minecraft.server.CraftingManager.getInstance().b() or its other methods is the way to go.

    There are some auto-crafting / crafting recipe info plugins out there that don't use the built-in CraftingManager, and they have to be updated whenever new recipes are added in updates, and also miss custom recipes added by other plugins. Using net.minecraft.server.CraftingManager avoids these problems, although it does mean you'll have to compile against CraftBukkit instead of Bukkit.

    Here is the source for CraftingManager: https://github.com/Bukkit/CraftBukk...ava/net/minecraft/server/CraftingManager.java - the
    Code:
    public ItemStack craft(InventoryCrafting inventorycrafting)
    method looks particularly useful.
     
Thread Status:
Not open for further replies.

Share This Page