1.8 KiB
metadata.title = "Smelting Recipes"
metadata.date = "2016-06-30 10:49:42 -0400"
metadata.series = "forge-modding-112"
metadata.seriesName = "Forge Mods for 1.12"
Setup
Before we implement any smelting recipes, we'll create a little class in which we'll use to register them. We'll call this class ModRecipes
, following the same convention as our ModItems
and ModBlocks
classes. We'll put this into the recipe
package inside our main package so if we have to implement more complex custom recipes, we'll have a place to group them together.
You'll want an empty init
static method in ModRecipes
which is where we'll register our recipes in just a moment.
package net.shadowfacts.tutorial.recipe;
public class ModRecipes {
public static void init() {
}
}
The ModRecipes.init
method should be called from TutorialMod#init
. The init method is called during the initialization phase which occurs after the pre-initialization phase. We want to register our recipes here instead of in the pre-init or post-init phases because all mod items/blocks (including those from other mods) should be registered at this point.
// ...
public class TutorialMod {
// ...
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
ModRecipes.init();
}
// ...
}
Smelting Recipe
The furnace recipe we'll add is going to be a simple 1 Copper Ore to 1 Copper Ingot recipe. All this requires is 1 call to GameRegistry.addSmelting
in our ModRecipes.init
method:
public static void init() {
GameRegistry.addSmelting(ModBlocks.oreCopper, new ItemStack(ModItems.ingotCopper), 0.7f);
}
GameRegistry.addSmelting
takes 3 parameters, the item/block/stack input, the ItemStack
output, and the amount of experience to be given to the player (per smelt).