Waffle - feel free to skip:
This tutorial will not cover any actual code, but it will help you get set up so you can start modding, and hopefully give you a good understanding of mods and how they work.
Please don't be put off by the length! Everything here is actually very simple, I've just tried to include as much detail as possible.
What is a mod?
A mod, or modification, is something that expands or edits the code of the game in some way, to provide new or modified functionality. Since mods work with the actual code of the game, there is really no restriction on what you can make, short of the limitations of the Java language itself, which is not something that can be said for many games!
Mods are different to texture packs, which only provide replacement graphics for the game (although mods can include their own graphics as well as code edits).
What is ModLoader?
Throughout this tutorial I will reference something called ModLoader; it's up to you whether or not you want to use it, but more people will download your mod if it uses ModLoader. It's very straightforward to use, and also very useful.
ModLoader is actually just another mod, but it doesn't add any new content; instead, it just provides modders with added functionality and allows for multiple mods to be installed with fewer compatibility issues.
Normally, to add a new block to the game, you'd need to edit "Block.java". The problem with this is, there can only ever be one "Block.java" file, so if 2 mods both add a block, only one of them can be used! This is obviously very limiting, which is what makes ModLoader so desirable.
Again, it's entirely up to you whether or not you want to use ModLoader. You will find tutorials out there to help you mod with or without it, but personally I would recommend you learn to use it from the start, and it will save you a lot of trouble later.
1) Let's Get Downloading!
Before you can start modding you will need several files.
1. Minecraft Coder Pack
Obviously if we want to edit the game's code, we will need to have the code in the first place! The Minecraft Coder Pack (MCP) allows us to decompile the game's files to get it in its code form, as well as enabling us to recompile our modified code afterwards so that it's ready for use.
The latest release can be found here.
Note that every time a new version of Minecraft is released, the MCP must also be updated! So if you ever find that the latest version of MCP is actually outdated, just be patient; a new version is usually released within a few days of a Minecraft update.
Mods, too, will often need to be updated when a new version of Minecraft is released. It is for this reason that many players and modders always keep an old version of their Minecraft files (specifically "minecraft.jar", but we'll learn about this later), so that they can still make or play with mods while waiting for MCP or various mods to update.
2. (Optional) ModLoader
If you want to use ModLoader to make your mod (recommended), you will need to download the necessary files, which can be found here.
Once again, these files need to be updated each time Minecraft is updated, so just be patient when this happens.
3. A Text Editor / IDE
Finally, you will need a program with which you can actually edit the files. IDE stands for Interactive Development Environment, which just means a program built to help programmers with coding. These are preferable to just any text editor, as they are able to correct your Java and point out mistakes as you type.
It doesn't matter what you use, but here are some options:
Notepad++: I've never used this myself, but a lot of tutorials recommend it and, being based on Notepad, I imagine it's quite straightforward.
NetBeans: This is actually what I use, but it's a bit of a pain to set up a project to use the decompiled Minecraft files.
Eclipse: This is very similar to NetBeans but a bit less "heavy".
4. WinRAR (or something similar)
WinRAR is a great (and free!) program that lets you view, modify and extract the contents of compressed archives (.zip, .rar, .ace, etc.). More specifically, it lets us edit the contents of "minecraft.jar", a compressed archive that contains all the game's code.
This is necessary for installing any mods, including your own!
You can download it here.
5. Minecraft Server Software
I'm not even sure if this step is necessary, but I believe MCP will complain if it can't find this file. No problem, you can download it at the official Minecraft website.
The file you need is called "minecraft_server.jar" and it is located at the bottom of the page.
2) Locate "minecraft.jar"
I have already mentioned "minecraft.jar" several times - this is a single file containing all the game's code, which we are obviously going to need!
This is located in your Minecraft's "AppData" folder. Here's how to find it:
Then just open the ".minecraft" folder.
Mac: ~/Library/Application Support/minecraft
Linux: Home (Ctrl + H to see hidden files) -> .minecraft
Here you should see a number of folders, such as the following (don't worry if you don't have all of these): bin, config, mods, resources, saves, screenshots, stats, texturepacks.
Now is probably a good time to mention that it's always a good idea to make a back-up of your "saves" folder before messing around with any mods, in case something goes wrong!
You should find your "minecraft.jar" in the "bin" folder.
Now, you should also have downloaded MCP by now; you can extract the files anywhere, for instance, in a subdirectory of your "Minecraft" folder (if you don't know how to extract the files, it should be an option when you right-click on the archive you downloaded; if your operating system can't do it, then WinRAR can!). Once you have extracted them, you should find a "jars" folder in your MCP directory.
Copy "minecraft.jar" and place it in the "jars" folder of MCP. Then do the same for "minecraft_server.jar".
3) (Optional) Install ModLoader
If you want to use ModLoader, now is the time to install it! All of these instructions can also be found on the page where you downloaded ModLoader.
You'll need to open up the copy of "minecraft.jar" that you just placed in the "jars" folder of MCP. This can be done using WinRAR; right-click on the file, select "Open With" and then find WinRAR in the list of programs. This should open the file in a new window, a bit like a normal folder, enabling you to see what's inside.
To install ModLoader, you just need to drag the included files (after extracting them from the archive you downloaded) into your WinRAR window (the window that just opened listing the files contained within "minecraft.jar", that is).
Finally, you need to delete the "META-INF" folder located in your "minecraft.jar". Forgetting this step is a common problem when people install mods, and it will result in a black screen when Minecraft loads!
You should now have a copy of "minecraft.jar" and "minecraft_server.jar" in the "jars" folder of MCP, ready to be decompiled. MCP comes with a file "decompile.bat", and this is file you need to run now; this should decompile your "minecraft.jar", thus giving you the source code for the game in the editable ".java" format.
(If you installed ModLoader, you might get a couple of error messages about "hunks", but these can be ignored.)
The decompiled files, ready for editing, are located at:
4) Get Modding!
That's it! You're all set! Congratulations, you've completed one of the hardest parts of modding Minecraft.
There are many tutorials out there to help with the actual coding side of things, so the next step is probably to look at some of them to figure out what you're doing.
The best advice I can give at this point is just to take things slow; start with something very simple, like adding a new block. If you get really stuck, then ask on the forum, but if you follow a tutorial carefully enough then that shouldn't happen!
Good luck, and I hope this helped.