Solved Custom Recipes

Discussion in 'Plugin Help/Development/Requests' started by 2008Choco, May 12, 2015.

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


    I'm attempting to add a custom recipe into the game to make a bandage for a plugin I'm planning on making. I have the recipe in the onEnable method, but for whatever reason, when I attempt to create the recipe in a crafting table, it's sayin, "NOPE!" and just doesn't give me any result in the crafting table. Here's the code I have. Note, this is in the onEnable method, and loading just fine.

            ItemStack bandage = new ItemStack(Material.PAPER);
            ItemMeta bandageMeta = bandage.getItemMeta();
            bandageMeta.setLore(new ArrayList<String>(Arrays.asList(
                    "Right click with this to",
                    "stop yourself from bleeding")));
            ShapedRecipe bandageRecipe = new ShapedRecipe(bandage);
            bandageRecipe.setIngredient('O', Material.AIR);
            bandageRecipe.setIngredient('W', Material.WOOL);
            bandageRecipe.setIngredient('R', Material.INK_SACK, 1);
  2. Offline


    @2008Choco First of all, recipes can be chained. Most methods return the object.
    getServer().addRecipe(new ShapedRecipe(bandage).shape("wrw").setIngredient('w',Material.WOOL).setIngredient('r',Material.INK_SACK, 1));
    Second, notice the change I have made to the recipe. Never, never, never try to create, accept, or assume the existence of an ItemStack with type Material.AIR. AIR is a block type. A nonexistent item is just a null, literally. Just leave out the parts of the recipe you don't use, and if you need to leave a bit blank then just use a space.
  3. Offline


    @pie_flavor Thank you. 1st thanks for telling me about chaining the recipe. Simplifies my code a lot. 2nd I added air only because I saw another post with air :p it was worth a shot

    Thanks again
Thread Status:
Not open for further replies.

Share This Page