Minecraft 1.12 modding with forge – 6 – custom recipes

Hello everyone, in this part we will be adding some custom recipes, I will show how to add a smelting recipe, a shapeless recipe and a shaped recipe.

For the people who haven’t followed this tutorial, I have 2 custom items and 2 custom blocks. If you don’t know how to add blocks click here, for items click here. For the people who followed the tutorial, I renamed the tutorialItem to tutorialIngot to be more consistent with the texture. Well lets get started!

In the init package create a new class and call it ModRecipes. Add a public static method, this method will register all of your recipes. I called it init to be consistent with the other classes.

I am going to add a smelting recipe to smelt the tutorialDust into the tutorialIngot. In this method call the method addSmelting on the GameRegistry object. This method needs an input, an output, and an amount of xp it will give. The input can be a Block, an Item or an ItemStack. The output has to be an ItemStack and the amount of xp has to be an float.

As input I will pass it ModItems.tutorialDust. The output has to be an ItemStack, an ItemStack is like an stack of items in game. You have to instantiate it with the item you want the stack to be and the amount of items in the stack. I will make it an ItemStack of 1 ModItems.tutorialIngot item.  Diamond has 1.0 for the xp amount, I will use 1.5. I will make another smelting recipe, this one takes the ModBlocks.oreBlock and turns into 2 ModItems.tutorialIngots, it wil only give 0.2 xp.

If you want to know all of the xp values for vanilla, you can see the vanilla smelting recipes in net.minecraft.item.crafting.FurnaceRecipes.

Now in the main class’ init method call the ModRecipes.init();

For crafting recipes you don’t have to add any code. In your assets package create a new package called recipes in this folder you can put .json files which will be loaded by the game. Here is a shaped recipe example:

This recipe needs 9 tutorialIngots in a 3×3 grid, this recipe is just like the iron block recipe.

And here a shapeless one:

This recipe needs a vanilla stone block and the custom tutorialIngot (My modid is “stm”). Putting this in a crafting table, or your 2×2 crafting grid will result in 2 purpur block.

A shaped recipe has a pattern, to fill the 3×3 of the crafting table you can do:

"AAA"
"AAA"
"AAA"

You can enter any symbol you want instead of “A” but you have to define the key and the value. That is done in the json under keys. You can also have different keys:

"AAA"
" B "
" B "

This would be a pickaxe shaped recipe. If you have a place where you don’t have a recipe you should put space (” “) there. For recipes that don’t fill the 3×3 you should leave out the spaces at the end, for example:

"AA"
"B "
"B "

This would be a hoe shaped recipe, this recipe is only 2 wide so we can remove the space at the end (Make sure every line is the same length, as you can see they are all 2 long).
If your recipe is your recipe is only 2 high you can remove the bottom line.

"AB"
"BA"

This recipe would also be possible in your 2×2 crafting grid.

For shapeless recipes you don’t need a pattern, but you need ingredients. To complete the recipe you need all of the ingredients to be in the crafting grid, but the order doesn’t matter., like dyeing wool.
There is a recipe generator, it only works with vanilla blocks but you can renamen the items in the json file you get so it can be useful.
For more information about the format you can check this post.

That was all for this part! I hope you learned something, as always if you have any question don’t hesitate to ask in the comments. Saw any errors? Please tell me!
Till next time!

~suppergerrie2

Posted in Forge tutorial, Forge Tutorial 1.12.

16 Comments

  1. I want to overwrite the existing crafting recipes for smooth sandstone. Is there a tutorial on doing that?

    I did find how I can overwrite the stone variants, just not the sandstone variants

  2. Thank you for the tutorial! I do have one question for you though. How can I specify what the damage value is for the items in the smelting recipes? For example, how could I smelt red dye into yellow dye? Thanks!

        • I just realized how unclear that reply was. I meant that I didn’t see the first comment I made. I thought that it didn’t post. Sorry for the accidental spam. 🙂

  3. The code works for me and everything, thank you btw. However I am unsure on how and where to specify the damage values. How could I smelt a red dye into a yellow dye for example? What would I add to my code? Thanks!

    • Hello,

      Instead of using an item you need to instantiate an ItemStack for the input and output. To instantiate an ItemStack you pass in the item it will be, the amount of items and the metadata.

       GameRegistry.addSmelting(new ItemStack(Items.DYE, 1, 1), new ItemStack(Items.DYE, 1, 11), 0.2f); 
  4. Is there any way to specify that a certain ingredient should not be consumed in a certain recipe ?

    • What do you mean by “not be consumed”? If you mean like a milk bucket turning in a empty bucket, that will happen automatically. Other items will have to be more complex I think. I am planning to do a tutorial on the more complex recipe structure but I first have to finish the large tutorial I am working on now.

      ~suppergerrie2

  5. after doing what you stated here for a smelting recipe i was unable to smelt my ore into an ingot please help

    • Hello!

      Please post your code whenever you have a problem. We can’t guess what you did 😛

      Did you make sure to call the modrecipe init function?

      ~suppergerrie2

      • I had this problem too.

        GameRegistry.addSmelting(ModItems.tutorialDust, new ItemStack(ModItems.tutorialItem, 1), 1.5f);
        GameRegistry.addSmelting(ModBlocks.tutorialOre, new ItemStack(ModItems.tutorialItem, 1), 1.5f);

        Smelting the tutorialDust into the tutorialItem works just fine, but not the tutorialOre. I haven’t been able to get any block to smelt.
        I’ve tried this aswell:

        GameRegistry.addSmelting(Item.getItemFromBlock(ModBlocks.tutorialOre), new ItemStack(ModItems.tutorialItem, 1), 1.5f);

        thinking that it only worked with items, but as expected, no change. I’ve also tried it with tutorialBlock in case it was some interaction with BlockOre, but that also doesn’t work.

        The only thing I can think of is that I’m using Forge 1.12.2-14.23.4.2705, not 1.12-14.21.1.2387. Everything else in the tutorial has worked fine so far, though. And mousing over the method addSmelting shows that it accepts blocks, not just items…

        • Figured it out, might be good to leave this here for other people.

          Skipping along like a dingus, I didn’t notice you stating to put ModRecipes.init() in [init] specifically, NOT [preInit] with modItems.init() and modBlocks.init()

          @EventHandler
          public void preInit(FMLPreInitializationEvent event)
          {
          ModItems.init();
          ModBlocks.init();
          }
          @EventHandler
          public void init(FMLInitializationEvent event)
          {
          ModRecipes.init();
          }

          This way everything works.

          • Apparently I have a problem somewhere and I don’t get notifications about comments sorry!

            I can understand that can be confusing, the reason for the method names is that the ModItems.init initializes the items, and ModRecipes.init initializes the recipes. I am planning on updating every part when 1.13 forge releases and I am gonna change some things so ModItems.init and ModBlocks.init won’t exist.

            ~suppergerrie2

Comments are closed.