Let’s add a way to obtain our red diamonds! In this tutorial I will make a recipe to get red diamonds by smelting normal diamonds.
First, you need to have a ModRecipes class ready. If you don’t, or you don’t know what it is, check out my shaped crafting tutorial.
Adding a smelting recipe is really straightforward.
GameRegistry.addSmelting(Items.diamond, new ItemStack(ModItems.red_diamond), 0.0F);
The first parameter is your input. The second parameter is the output, and the last float parameter is how much experience will the player get upon smelting. I set mine to 0.0F, but you can set yours to any number you like.
After adding said piece of code, your ModRecipes class should look like so:
package com.emx.tutorial.init; public class ModRecipes { public static void init() { GameRegistry.addRecipe(new ItemStack(ModBlocks.red_diamond_block), "XXX", "XXX", "XXX", 'X', ModItems.red_diamond); GameRegistry.addShapelessRecipe(new ItemStack(ModItems.red_diamond, 9), ModBlocks.red_diamond_block); GameRegistry.addSmelting(Items.diamond, new ItemStack(ModItems.red_diamond), 0.0F); } }
That’s it, very easy.