Solved Custom Recipe not working

Discussion in 'Spigot Plugin Development' started by GnRDevelopment, Jul 22, 2018.

  1. Hi, I am coding a plugin that involves a custom recipe and it doesn't seem to work. I've tried numerous threads and forum posts and none help.


    Code (Java):
    public class Main extends JavaPlugin {

        @Override
        public void onEnable() {
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(new Events(), this);
           
            ItemStack result = new ItemStack(Material.MUSHROOM_SOUP);
            ItemMeta cocoa = result.getItemMeta();
            cocoa.setDisplayName("§f Chocolate Milk <o/");
            result.setItemMeta(cocoa);
            ShapedRecipe cocoamilk = new ShapedRecipe(result);
            cocoamilk.shape("C", "B");
            cocoamilk.setIngredient('C', Material.COCOA);
            cocoamilk.setIngredient('B', Material.BOWL);
           
            Bukkit.addRecipe(cocoamilk);
        }
       
        @Override
        public void onDisable() {
           
        }
    }
     
    Thanks for the help.

    PS. I originally had it as a Shapeless Recipe but that didn't work so I moved to a Shaped Recipe.
     
  2. Have you tried setting the shape to something like
    CCC
    BBB
    CCC
    so that it's obvious where the ingredients go? Just in case Bukkit makes 1 letter rows on the right side or something silly.
     
  3. Just tried that and no it doesn't work.
     
  4. Why didn't it work as a shapeless recipe?
     
  5. How would I know? It didn't craft it when I did the recipe.
     
  6. Instead of
    Code (Java):
    ItemStack result = new ItemStack(Material.MUSHROOM_SOUP);
    try
    Code (Java):
    ItemStack result = new ItemStack(Material.MUSHROOM_SOUP, 1);
    Just occurred to me that you might be trying to craft 0 mushroom soups.
     
  7. No result.
     
  8. The problem is that minecraft:cocoa is the cocoa pod that grows on trees, not the dye stuff dye:3 (1.12) or cocoa_beans (1.13)
    Using the same code with different materials works fine in my dev server.
     
    • Like Like x 1
  9. I'll change and see if it works. If it does, I'll update this post. I'll turn it back into a shapeless recipe as well. Thanks!

    EDIT: It works. Here's the code I changed that made it work


    Code (Java):
    ItemStack result = new ItemStack(Material.MUSHROOM_SOUP, 1);
            ItemMeta cocoa = result.getItemMeta();
            cocoa.setDisplayName("§bChocolate Milk <o/");
            result.setItemMeta(cocoa);
            ShapelessRecipe cocoamilk = new ShapelessRecipe(result);
            cocoamilk.addIngredient(Material.INK_SACK, (byte) 3);
            cocoamilk.addIngredient(Material.BOWL);
           
            getServer().addRecipe(cocoamilk);
     
    #10 GnRDevelopment, Jul 23, 2018
    Last edited: Jul 23, 2018