Modding TuT - Creating a new block

Thanks to this forums post for the TuT

In this tutorial I will explain how to create a new block in Minecraft and how to make it craftable. This tutorial makes a standard block like stone.

Creating a new block

1. You need to make a new file called BlockExample.java in the src directory. 2. The basic structure of this file is this: package net.minecraft.src; import java.util.Random; public class BlockExample extends Block {    public BlockExample(int i, int j)     { super(i, j, Material.rock); }    public int idDropped(int i, Random random) {        return 0; } } 3. You now need to add this block to minecraft so that it knows about it. To do this open up Block.java 4. You should see a whole bunch of variable declarations towards the bottom of the file, add a new one: public static final Block example; 5. Below the declarations you should see initialisation of these instance variables, initialise your block. example = (new BlockExample(92, 1)).setHardness(1.5F).setResistance(10F).setStepSound(soundStoneFootstep); Like mentioned before this example block is creating a new 'stone' block. new BlockExample(92, 1) creates the new block, the first number is the block id - THIS HAS TO BE UNIQUE, the second number is the graphic of the block, in this case the same as stone. setHardness(1.5F) is the same as stone, this is how long it takes to destroy a block. setResistance(10F) is the same as stone, this is how strong the block is against explosions. setStepSound(soundStoneFootstep) is the same as stone, this is the sound it makes when you walk on it.

You have now successfully created a new block class. To use this block you need to generate it, this can be done using the Single Player Commands mod using this command: "/give 92".

Continue on reading if you want to add a recipe to the crafting table to make this block.