Originally posted by lallyman
Hey all you Minecraft fans
Well, today as you may have noticed, Merkii posted a tutorial on how to make your own items(obesidian tools). I want to show you how to make your own blocks and how to use them with Merkii's tutorial. So check out his You must login or register to view this content. and download the pre-requirements.
ALSO! It's not letting me add a new page to this so this tut looks like crap for while. 
How to decompile!
NOTE: I am using Windows 7. I don't know how to do this for Mac/Linux users. So first, press the little start icon on your keyboard and 'R' on your keyboard at the same time. This will bring up a window called 'RUN'. If you don't have a start icon on your keyboard, just go to the start icon and type in '%appdata%'. If you have played Minecraft before, look for a file called .minecraft. If you don't see one, open Minecraft and load a singleplayer level then save and quit. Open .minecraft and locate the folder called 'BIN'. COPY the 'BIN' folder. Now open up your folder with MCP and look for a folder called 'JARS'. Open 'JARS' and PASTE your 'BIN' folder in there. Then exit and go to the main directory of MCP(where you see all the folders 'JARS' 'CONF'
and double-click '
ECOMPILE.BAT'. Let that load and do its stuff. Once done (when it says "Press any key on the keyboard to continue") you should have a folder called 'SRC'. Now your ready to make your actual codes! 
Making your codes!
In your SRC, click 'MINECRAFT', 'NET', 'MINECRAFT', 'SRC' and that's where all your coding will be put. Copy ANY of the .java files and rename it to 'mod_LALLY' <---- it's case sensitive. Open 'mod_LALLY' and delete ANYTHING IN IT. I recomend opening it with EditRocket (or RocketEdit I don't remember) or Notepad ++ <----- I use that.
Now in the beginning, copy and paste this in 'mod_LALLY':
package net.minecraft.src;
import java.util.Random;
public class mod_Base extends BaseMod
{
public mod_Base()
{
}
public String Version()
{
return "3.14159265";
}
}
We're almost close to actually making our block
Ok. Paste this inbetween 'public class mod_Block extends BaseMod' and 'public mod_Lally()'
public static final Block keeghanBlock = new BlockKeeghan(150,0).setHardness(1.0F).setResistance(500.0F).setBlockName("asdf").setLightValue(1.3F);
Where it says 'public static final Block keeghanBlock' 'keeghanBlock' is what we are going to name our block. My first name is Keeghan, so I called it that. 'new BlockKeeghan(150,0)' is your data value. If you use single-player commands, you would type '/give 150 1' to give you your block. IT MUST BE UNIQUE. 'setHardness(1.0F)' is how hard your block is. Stone/Cobblestone is 1.5, and 1.0 is about a little stronger than dirt. 'setResistance(500.0F)' is how resistance it is to Creepers exploding/TNT exploding. 500 SHOULD be enough
'setBlockName("asdf")' is the name Minecraft recognizes it. I think. I just put 'asdf'. 'setLightValue(1.3F)' is how much light it will produce in dark places like GlowStone.
All together, your code should look like this:
package net.minecraft.src;
import java.util.Random;
public class mod_Block extends BaseMod
{
public static final Block keeghanBlock = new BlockKeeghan(150,0).setHardness(1.0F).setResistance(500.0F).setBlockName("asdf").setLightValue(1.3F);
public mod_Block()
{
}
}
Your actual codes for mod_LALLY()
Alright, now in the '{' and '}' in 'public mod_LALLY()' add this code:
ModLoader.RegisterBlock(keeghanBlock);
This is basically registering your block (keeghanBlock) with Minecraft.
Paste this right below that:
keeghanBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/NGU.png");
This is the texture of your block! I named mine 'NGU.png'. I will show you how to make your texture later, or you can just follow Merkii's tutorial.
Paste this below that:
ModLoader.AddName(keeghanBlock, "NGU_LALLY");
This is the INGAME name for your game! I will name it 'NGU_LALLY' and that's what it will appear as ingame.
Paste this below that:
ModLoader.AddRecipe(new ItemStack(keeghanBlock, 10), new Object[]
{
"**","**", Character.valueOf('*'
, Block.dirt
});
' ModLoader.AddRecipe(new ItemStack(keeghanBlock, 10) ' is saying it will give you 10 of your block when you make it in the crafting table.
This is the crafting recipe for your item. I will make mine a 2x2 so it can be made in the 2x2 crafting table. If you have ' "***","***","***", ' it will be a 3x3. ' Character.valueOf('*'
, Block.dirt ' is declaring that '*' is dirt. All together, your code should look like this:
package net.minecraft.src;
import java.util.Random;
public class mod_LALLY extends BaseMod
{
public static final Block nguBlock = new BlockNGU(150,0).setHardness(1.0F).setResistance(500.0F).setBlockName("NGUF").setLightValue(1.3F);
public mod_LALLY()
{
ModLoader.RegisterBlock(nguBlock);
nguBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/NGU.png");
ModLoader.AddName(nguBlock, "NGU");
ModLoader.AddRecipe(new ItemStack(nguBlock, 10), new Object[]
{
"* *","***","* *", Character.valueOf('*'
, Block.dirt
});
}
public String Version()
{
return "3.14159265";
}
}
On to making your Block!
Bringing your Block to the game!
You must login or register to view this content. to create a 16x16 image. Here is mine: [ATTACH=CONFIG]12486[/ATTACH]
Just convert the .ico to .png You must login or register to view this content.
Once you have your .png, save it in a folder where you can find it. COPY it and PASTE it in 'Minecraft Coder Pack\bin\minecraft'.
Now we just need one more file and then we can test our code!!!!
Your block codes
Make a new .java file in the SRC folder where our mod_LALLY.java is. Call it 'BlockNGU.java'. Paste this code into it:
package net.minecraft.src;
import java.util.Random;
public class BlockNGU extends Block
{
protected BlockNGU(int i, int j)
{
super (i,j,Material.wood);
}
public int idDropped(int i, Random random)
{
return Block.oreGold.blockID;
}
public int quantityDropped(Random random)
{
return 15;
}
}
' super (i,j,Material.wood); ' is saying that it will be treated as wood. Like when you use a axe etc etc.
' return Block.oreGold.blockID; ' is saying when you break your block, it will break into Gold ore blocks.
' return 15; ' under the 'quantityDropped' is saying it will give you 15 of the return block. In our case, it is Gold ore!
Almost finished!
Now that you are done with all the coding, go to your main directory in MCP. Double-click 'recompile.bat' and let it load. If you have no errors, run 'startclient.bat' then test your mod! Just get 7 blocks of dirt and make a 'N' in a 3x3 crafting table. Viola! Your block is made!
Final code for mod_LALLY:
package net.minecraft.src;
import java.util.Random;
public class mod_LALLY extends BaseMod
{
public static final Block nguBlock = new BlockNGU(151,0).setHardness(1.0F).setResistance(500.0F).setBlockName("NGUF").setLightValue(1.3F);
public mod_LALLY()
{
ModLoader.RegisterBlock(nguBlock);
nguBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/NGU.png");
ModLoader.AddName(nguBlock, "NGU");
ModLoader.AddRecipe(new ItemStack(nguBlock, 10), new Object[]
{
"* *","***","* *", Character.valueOf('*'
, Block.dirt
});
}
public String Version()
{
return "3.14159265";
}
}
Final code for BlockNGU:
package net.minecraft.src;
import java.util.Random;
public class BlockNGU extends Block
{
protected BlockNGU(int i, int j)
{
super (i,j,Material.wood);
}
public int idDropped(int i, Random random)
{
return Block.oreGold.blockID;
}
public int quantityDropped(Random random)
{
return 15;
}
}
when I started "startclient.bat" it crashes

it says failed to load mod from "NAME.class"