Previous post: ModderDojo Java Modding 5: Creating Our First Mod – The Basic Code
Note: the instructions at this link are good but things have changed a bit for Forge 1.7: http://www.minecraftforge.net/wiki/Crafting_and_Smelting
Different types of mods require different types of code. One of the easiest type of mod to add is a crafting recipe. We will write one to turn some dirt into diamonds.
The code for this goes into the init function:
What this does:
- Create a new ItemStack called dirtStack with a single dirt block
- Create a new ItemStack called diamonds10 with 10 diamond blocks
- Add a new recipe to the game that will produce this stack of 10 diamonds, when you lay out the dirt in the shape specified: x in the shape is where the dirt blocks have to go.
We can also have shapeless recipes (where it doesn’t matter where you put blocks), which are even simpler to write:
GameRegistry.addShapelessRecipe(
new ItemStack(Items.diamond, 6), new ItemStack(Blocks.dirt));
This second one creates a stack of 6 diamonds from a single block of dirt.
Previous post: ModderDojo Java Modding 5: Creating Our First Mod – The Basic Code
This concludes this series of posts on getting started with Java Modding, from ModderDojo Athenry.
Pingback: ModderDojo Java Modding 1: Beginning Java Mods with Forge | CoderDojo Athenry
Pingback: ModderDojo Java Modding 5: Creating Our First Mod – The Basic Code | CoderDojo Athenry
Pingback: ModderDojo 2016: Adding a Crafting Recipe in Scriptcraft | CoderDojo Athenry