ModderDojo Java Modding 6: Creating Our First Mod – Adding A Crafting Recipe

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.

craftdiamonds

The code for this goes into the init function:

recipecode

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.

 

3 thoughts on “ModderDojo Java Modding 6: Creating Our First Mod – Adding A Crafting Recipe

  1. Pingback: ModderDojo Java Modding 1: Beginning Java Mods with Forge | CoderDojo Athenry

  2. Pingback: ModderDojo Java Modding 5: Creating Our First Mod – The Basic Code | CoderDojo Athenry

  3. Pingback: ModderDojo 2016: Adding a Crafting Recipe in Scriptcraft | CoderDojo Athenry

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s