Block and Item Recipes/Smelting - 1.8
Adding recipes is very simple. To add a recipe, add this under your @init section. I tend to put my recipe directly under where I add the language registry for my object.
GameRegistry.addRecipe(new ItemStack(Tutorial.myFirstItem, 2), "XXX", "* *", "XXX", 'X', Items.iron_ingot, '*', new ItemStack(Blocks.dirt));
new ItemStack(this.myFirstItem, 2) gets what item is being crafted, in this case myFirstItem. It also says it will craft two of them. Change the number for a different amount of items recieved. If you only want one to be made you don't need to include the second parameter.
The code after ItemStack() defines the recipe. For this example, "XXX", "* *", "XXX" would look like this. Spaces represent blanks in the crafting table.
You'll notice that I put the Blocks.dirt inside a new ItemStack(). This is because ITEMS are used to craft in a crafting recipe and by converting a block to an ItemStack will allow it to work. Without this, blocks in a recipe will not function.
For a shapeless recipe, it's almost the same thing:
GameRegistry.addShapelessRecipe(new ItemStack(Tutorial.myFirstItem), new ItemStack(Block.cactus), Item.leather});
This says when you place cactus and leather together in any format it will create the myFirstItem item. If you want to add two of the same item in a shapeless recipe, list the item twice, or however many times you want it in the recipe.
To add a smelting recipe:
GameRegistry.addSmelting(Tutorial.myFirstBlock, new ItemStack(Tutorial.myFirstItem, 2), 1.5F);
This says when you place a myFirstBlock inside a furnace, you'll receive two of myFirstItem. The 1.5F determines how much experience you will get from smelting it.
Now on to mobs.
GameRegistry.addRecipe(new ItemStack(Tutorial.myFirstItem, 2), "XXX", "* *", "XXX", 'X', Items.iron_ingot, '*', new ItemStack(Blocks.dirt));
new ItemStack(this.myFirstItem, 2) gets what item is being crafted, in this case myFirstItem. It also says it will craft two of them. Change the number for a different amount of items recieved. If you only want one to be made you don't need to include the second parameter.
The code after ItemStack() defines the recipe. For this example, "XXX", "* *", "XXX" would look like this. Spaces represent blanks in the crafting table.
You'll notice that I put the Blocks.dirt inside a new ItemStack(). This is because ITEMS are used to craft in a crafting recipe and by converting a block to an ItemStack will allow it to work. Without this, blocks in a recipe will not function.
For a shapeless recipe, it's almost the same thing:
GameRegistry.addShapelessRecipe(new ItemStack(Tutorial.myFirstItem), new ItemStack(Block.cactus), Item.leather});
This says when you place cactus and leather together in any format it will create the myFirstItem item. If you want to add two of the same item in a shapeless recipe, list the item twice, or however many times you want it in the recipe.
To add a smelting recipe:
GameRegistry.addSmelting(Tutorial.myFirstBlock, new ItemStack(Tutorial.myFirstItem, 2), 1.5F);
This says when you place a myFirstBlock inside a furnace, you'll receive two of myFirstItem. The 1.5F determines how much experience you will get from smelting it.
Now on to mobs.