Green: Working in current version*. Yellow: Untested in current version*. Red: Not working in current version*. *Minecraft Major version (e.g. 1.6), not including bugfix updates (e.g. 1.6.2).
Difficulty Key (Please Read):
: Easy.
: Moderate.
: Hard.
**Note**
These tutorials assume that you have a basic understanding of the Java programming language. If you are unfamiliar with Java, many elements of this tutorial will not make sense. If you need to learn Java, then watch the first 50 or so of TheNewBoston's java tutorials. It is alot, but it will make everything easier for you.
Getting Ready
1. Setting up Forge:
Requirements: None
Instructions:
First download the recommended/latest version of the scr download of Minecraft Forge from the forge website:http://files.minecraftforge.net.
**Note**: The "latest" version can be unstable, so download the "recommended" version for the latest Minecraft Version if possible.
Shown above is the Forge download screen as of 6 July 2013
After you download the file, extract it using 7-Zip or another program (will be done automatically if you are on a Mac).
Next, create a folder on your desktop called "development". Create a subfolder named mcp and copy the contents of the "forge" folder into it.
Now we are ready to start forge! Operating System specific instructions below:
Mac OSX
Open terminal (You can find terminal at /Applications/Utilities/Terminal.app, or you can use spotlight to find it. and type: cd ~/Desktop/development/mcp
now type python install.py.
Forge will now start to download and install the necessary files. It will then automatically decompile the Minecraft source code. This process can take between 15-20 minutes, and sometimes even longer, so be patient.
Linux/Unix
All you need to do to install forge on Linux systems is locate the "install.sh" file in the /Desktop/development/mcp. After you double click it, it will begin to execute a script which will download and install the necessary files. It will then automatically decompile the Minecraft source code. This process can take between 15-20 minutes, and sometimes even longer, so be patient.
Windows
All you need to do to install forge on Windows is locate the "install.bat" file in the /Desktop/development/mcp. After you double click it, it will begin to execute a script which will download and install the necessary files. It will then automatically decompile the Minecraft source code. This process can take between 15-20 minutes, and sometimes even longer, so be patient.
2. Setting up Eclipse (Your IDE):
Requirements: Setup Forge Installation
Instructions:
First, download the latest version of Eclipse from the website, being sure to select the correct Operating System. Scroll down to the download"Eclipse IDE for Java Developers". The downloads are located at:
Now, open Eclipse. You will be prompted to select the workspace location. Select your "Desktop" directory and then type in "/development/mcp/mcp/eclipse".
Overview: The @Mod class is the main class for each and every mod. This class is used to tell Forge there is a mod, to initialize your mod, and add all of the blocks and items you mod makes to the game.
Instructions:
First you need to create a new package in Eclipse by right-clicking on the "Minecraft" project and selecting "New Package". Name it <Your Name>.<YourMod>.
Now to create a new class. Find your package in the box on the right, right click it and select "New Class". You will be presented with a window that looks like this.
Where it says "Name:" put in the name of your mod, and press Finish. Eclipse will now create a class with some default code which should look like this:
package sprite99.TutorialMod;
public class TutorialMod {
}
This is a basic class file. The first line tells Java what package it is in for internal reference, and the second line simply defines the beginning of a class. Next, you need to add the following two lines of code.
The first line tells Minecraft Forge that this class is the main class for the Mod, and it gives it some basic information about the Mod. The second line lets Forge know that the mod is a Singleplayer Mod and that it doesn't eed to be installed on the server. Be sure to import all of the neccesary items with CMD-Shift-O or CTRL-Shift-O. Now we need to add a few methods to our class file. This is the new code:
@EventHandler
public void preInit(FMLPreInitializationEvent e) {
}
@EventHandler
public void load(FMLInitializationEvent e) {
}
@EventHandler
public void postInit(FMLPostInitializationEvent e) {
}
Each method handles a slightly different task. The "preInit" method handles things like Translation files and Config files, and is called before everything is Initialized and Loaded. The "load" method handles Item and Block initialization as well as handling names, recipes, and tooltips. The "postInit" method handles interaction with other mods, and is called after everything is Initialized and Loaded. Now use the above mentioned shortcut to import everything.
Now that our main class is complete we need to move on to our reference class. This is where we will store the information about the mod so that we only need to change it once, rather than anywhere where there is referenced. We first need to create a new package called <Your Name>.<YourMod>.lib. Now create a new class in that package called Reference. This is the code that needs to be placed inside of that class:
package sprite99.TutorialMod.lib;
public class Reference {
public static final String NAME = "Tutorial Mod";
public static final String MOD_ID = "TMod";
public static final String VERSION = "0.0.1";
}
This code is just 3 Variables that have been defined as Constants. By Java convention, all constants have names that are all capitals. The "Name" variable is the name of your mod. The "Mod_ID" is a unique abbreviation of the name of your mod, and "Version" simply defines the version of your mod. There are many ways to version your mods, but I reccomend the good old <0-9>.<0-9>.<0-9>. This is the same method used by the folks at Mojang. For every minor change you raise the third number by one, and for every major change, you change the second number by one.
All that is left to do now is to change our main class to accomodate these new Variables. Only one line actually needs to be changed, the @Mod line. This is what the code needs to be changed to:
@Mod(name = Reference.NAME, modid = Reference.MOD_ID, version = Reference.VERSION)
Don't forget to import everything with the shortcut I taught you earlier! Now if you run the project by pressing the small play button in the top bar of the window. You should see your mod added to the in-game list of mods!
1. Making an mcmod.info file INCOMPLETE
Requirements: Completed @Mod file
Overview: An mcmod.info file is a file written in the JSON format which gives information to forge which is not located in the @Mod file. This information includes a description, dependencies on other mods, and the logo file location for your mod.
Instructions:
First, create a new file in the src directory of the Minecraft project by right clicking and selecting new file. There is no point actually explaining what each tag means as it is fairly straightforward so...here is the template:
*All of the code is located in the tutorialMod_Common, and the texture files will be located in resources, both of which represent the src directory in your forge setup.
I love the references file idea - central location for management of mod data, very cool. Mind if I use it, and credit you, in my next Mod video? Just mention that I modified my Mod file, and your tut is what showed me how to do it?
This was really helpful, Thanks. Will you be doing more of these tutorials? Could you please do a lot of them, including the creation and design of new mobs? Thanks, mikeline100
For those of you who are using these tutorials to learn how to create mods: I am recoding the tutorials FULLY. This will allow me to reformat the tutorial itsself as well as giving me a chance to post the code on GitHub. The code will be much the same, but there will be subtle changes both to the code and the package structure. The code can be found at: https://github.com/Sprite99/TutorialMod
I love the references file idea - central location for management of mod data, very cool. Mind if I use it, and credit you, in my next Mod video? Just mention that I modified my Mod file, and your tut is what showed me how to do it?
As for this, I owe the idea to Pahimar, one of the Forge developers, and the developer of Equivalent Exchange 3. This code is based off of the code of Equivalent Exchange 3 to a certain degree.
**NOTE** The recode should begin tomorrow, and will probably be completed by this Friday.
Green: Working in current version*.
Yellow: Untested in current version*.
Red: Not working in current version*.
*Minecraft Major version (e.g. 1.6), not including bugfix updates (e.g. 1.6.2).
: Easy.
Now to create a new class. Find your package in the box on the right, right click it and select "New Class". You will be presented with a window that looks like this.
This is a basic class file. The first line tells Java what package it is in for internal reference, and the second line simply defines the beginning of a class. Next, you need to add the following two lines of code.
The first line tells Minecraft Forge that this class is the main class for the Mod, and it gives it some basic information about the Mod. The second line lets Forge know that the mod is a Singleplayer Mod and that it doesn't eed to be installed on the server. Be sure to import all of the neccesary items with CMD-Shift-O or CTRL-Shift-O. Now we need to add a few methods to our class file. This is the new code:
Each method handles a slightly different task. The "preInit" method handles things like Translation files and Config files, and is called before everything is Initialized and Loaded. The "load" method handles Item and Block initialization as well as handling names, recipes, and tooltips. The "postInit" method handles interaction with other mods, and is called after everything is Initialized and Loaded. Now use the above mentioned shortcut to import everything.
Now that our main class is complete we need to move on to our reference class. This is where we will store the information about the mod so that we only need to change it once, rather than anywhere where there is referenced. We first need to create a new package called <Your Name>.<YourMod>.lib. Now create a new class in that package called Reference.
This is the code that needs to be placed inside of that class:
This code is just 3 Variables that have been defined as Constants. By Java convention, all constants have names that are all capitals. The "Name" variable is the name of your mod. The "Mod_ID" is a unique abbreviation of the name of your mod, and "Version" simply defines the version of your mod. There are many ways to version your mods, but I reccomend the good old <0-9>.<0-9>.<0-9>. This is the same method used by the folks at Mojang. For every minor change you raise the third number by one, and for every major change, you change the second number by one.
All that is left to do now is to change our main class to accomodate these new Variables. Only one line actually needs to be changed, the @Mod line. This is what the code needs to be changed to:
Don't forget to import everything with the shortcut I taught you earlier! Now if you run the project by pressing the small play button in the top bar of the window. You should see your mod added to the in-game list of mods!
As for this, I owe the idea to Pahimar, one of the Forge developers, and the developer of Equivalent Exchange 3. This code is based off of the code of Equivalent Exchange 3 to a certain degree.
**NOTE** The recode should begin tomorrow, and will probably be completed by this Friday.
You haven't tried hard enough.