top of page

Crafting, Smelting and Ore Dictionary

We've just finished our Lead Ore and our Lead Ingot, if we try to smelt our lead we cant. Why? We haven't added a smelting recipe! Lets quickly add one now. Just like with the InitItems and InitBlocks classes, we are going to make a smelting, crafting and ore Dictionary Handler. Im going to call it crafting handler. Made a new package called "handler" and added it. Simply add 3 new methods called "smelting", "crafting" and "oreDict". Now we have to add a method in GameRegistry for smelting called addSmelting(Block input, Itemstack output, float xp)

This method we just used has 3 parameters: Block input, ItemStack output and float xp. First one, is the block to be smelted. You can also use an Item or an ItemStack. Second parameter is an ItemStack of the item or block to be produced by smelting the first parameter. The last parameter is a float of xp given when the player takes out the finished smelting product. We use 0.7f as that is the same as iron. Now just add CraftingHandler.smelting(); in the init method of our Mod File and boom! Our Lead is smeltable. Now lets get onto crafting. Quickly, lets make a quick block called lead_block. After quickly creating our lead block, we find that it is only avaliable in creative. We want to be able to create this block. Okay, lets do it! 

As you can see here, I've called each method inside another method called init() just to make things more tidy in the main file. In the "crafting" method, you can see a GameRegistry method being called named "addShapedRecipe(itemstack output, object[]). First parameter is the itemstack that will be created, which is the lead block. Next we make a new object array. As you can see, the first 3 parameters are strings made up of 3 'l's. Those are the layout of the crafting table. It goes like this in the slots "123" "456" "789". We just fill the whole of it with "l"s to make the lead block. Tip: To make a empty slot just put a space like this "i i". The last bit just says that 'l' is the lead ingot item. Awesome! Now if we go into Minecraft and fill the crafting with lead ingots, it should make our lead block! Last but not least, we have the ore dictionary. If you dont know what it is, I'll explain. The ore dict is a unique thing to forge which allows mod authors to add their blocks and items, etc. to a string or ID. So if we add our lead to the ore dict, we can use our lead ingots in recipes that use the ore dict with lead! Pretty cool huh. The term we used then is the common string used by many mod authors including famous authors like Azanor and the Slime Knights. We also had our lead block. Awesome! Now if we were to run a mod that used lead ingots ore dict, we see we can use our ingot (if they use the same string of course). Just remember to add CraftingHandler.init() in the init() method of our main class!

bottom of page