This tutorial is made with the intention of guiding beginners!
Pictures are included!!
If you got the time or if you are having difficulty understanding parts of the tutorial, I strongly suggest reading all of it.
This tutorial is targeted at Windows PC users.
What is covered in this tutorial?
Tip: Use Ctr+F to skip to different sections.
A1) Required Programs - Things you will need. A2) Workspace Setup - How to install the things you will need.
B1) Your First Mod B2) Your First Item B3*) Crafting and Smelting Recipes B4*) Custom Textures and Icons
C*) Packaging and Publishing Your Mod
D1*) Your First Mob D2*) undecided (equipping mob with weapons?)
* In Progress * Planned, but not added... yet. * Comment with suggestions and opinions.
A1 - Required Programs
So here you are, starting off with a strong sense of self motivation and at the least a basic knowledge of how the Java programming language works. These programs aren't all required in the sense that you won't be able to mod without them, but they are strongly recommended, especially for self motivated entrepreneurs like yourself!
JDK 7 - Java Development Kit
Think of this as a box that contains many tools used by programs to help you write, compile, edit, and publish your Java code. These tools will be used by an IDE, or Integrated Development Environment, such as Eclipse. Tip: Install the 32-bit version of JDK as the 64-bit version may be somewhat problematic.
7-Zip[32-bit][64-bit]
This is pretty much the same thing as WinZip, only better! You don't really need this, but it helps alot, not just with Minecraft mods, but tons of other things too! It allows you to compress and decompress files quickly and efficiently by right clicking .zip or .7z files.
Minecraft Forge Source
This is a compressed file containing the backbone of your future Minecraft modding career. It includes MCP (Minecraft Coder's Pack), a powerful set of scripts that allow you to deobfuscate(clean up) and decompile Minecraft's core files into human readable Java code! Once the code has been edited, there are scripts included that will recompile and reobfuscate your code into .class files ready to be packaged into a mod. Download, but do not install this until you have set up your PATH variable. (PATH variable setup guide) Instructions on how to do this are provided in the next section. Tip: You can use 7-Zip to convert a compressed file into a folder, as seen in the picture below.
Eclipse IDE[32-bit][64-bit]
Eclipse is where you will be spending most of your time. Using an IDE makes working on projects dramatically easier, and with Minecraft Forge Source, you can even use Eclipse to test run your new mods before you publish them. Instructions on how to set up a workspace in Eclipse are included in the next section.
A2 - Workspace Setup
By now you should have everything you need to get started. You have installed Java SDK and downloaded Minecraft Forge Source. You have also aquired an IDE (Eclipse).
2. Installing Minecraft Forge Source
Now that you have set up your path variable, you can install Forge Src. Once you have unpackaged the .zip file, you will have a forge folder that contains a file named install.cmd. Run this file and it will automatically install Minecraft Coder's Pack scripts, download needed files, and decompile Minecraft.jar files, preparing them to be modified.
3. Setting up Eclipse
When Forge has finished installing and you have launched Eclipse, Eclipse will present you with a dialog named Workspace Launcher. Click the Browse... button and navigate to the \mcp\eclipse folder located in the forge folder and click Ok. Eclipse should now open and display a tab named Project Explorer on the left side. The Project Explorer should have a folder named Minecraft, wherein Minecraft's decompiled source code is displayed. Forge Mod Loader has been integrated into this source.
B1 - Your First Mod
By now you should have the required programs downloaded and installed. You should also have finished setting up your workspace. Looks like your ready to begin modding!
First off, you will want to familiarize yourself with Eclipse's project explorer on the left hand side. This panel can be used to navigate through Minecraft's source code packages as well as packages you have added or modified. It is a very good idea to view the Forge Mod Loader source as many useful methods and classes are provided to make modding Minecraft much easier.
Organization is very important when programming. It is much easier to find bugs when your code is clean and tidy. When you are naming variables, classes, etc. you should pick a name that respects the function of what you are naming. For example, if you were creating a class for a new type of weapon, a sword, it would be wiser to name it something like ItemWeaponSword.java instead of class1.java or MyWeapon.java.
Lets begin. In this section we create a package for our mod and create a basic skeleton.
Create a new package by pressing Ctr+N and selecting Package in the Java folder.
For the purpose of this tutorial, lets set the name of this package to mod.tutorial.
Your new package should now be visible in the Project Explorer on the left hand side.
Right click mod.tutorial and select New > Class.
This will open a window containing lots of options, many of which you don't need to worry about right now.
Make sure the package field is set to mod.tutorial.
We can set the name to TutorialMain.
By now you should have a new class named TutorialMaininside your mod.tutorial package. If you have followed the steps correctly, the TutorialMain class will have this piece of code already written for you:
package mod.tutorial;
public class TutorialMain {
}
Now you will want to add a line to your code that will allow Forge Mod Loader to identify your mod. Your code should now look like this:
package mod.tutorial;
@Mod(modid="TutorialMain", name="Tutorial Mod", version="1.0")
public class TutorialMain {
}
These parameters (modid, name and version) are quite self explanatory. Your mod's ID should be unique to your mod in order to avoid possible conflicts with other mods. It is generally a good idea to use the name of your main class as your mod's ID. The name is what will be shown to users when they see your mod in the mods list. The version will also be shown in this list and you may use any format you wish.
Eclipse will show you a few errors on this new line. These can easily be fixed by importing the correct class. In most cases, Eclipse will automatically detect which class you want to reference and will provide it in the quick fixes list. Hover your mouse over@Mod and click Import 'Mod' to fix the errors.
Now your code should look like this:
package mod.tutorial;
import cpw.mods.fml.common.Mod;
@Mod(modid="TutorialMain", name="Tutorial Mod", version="1.0")
public class TutorialMain {
}
Now we must add two lines that tell FML to instance your mod object in Minecraft. These lines must be added inside your TutorialMain class and you must import the referenced fml class.
@Instance("TutorialMain")
public static TutorialMain instance;
Now you have completed creating the basic skeleton of your mod. Your full code should now look like this:
package mod.tutorial;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Instance;
@Mod(modid="TutorialMain", name="Tutorial Mod", version="1.0")
public class TutorialMain {
@Instance("TutorialMain")
public static TutorialMain instance;
}
You can test your mod by clicking the Run Client button on the toolbar at the top.
Your new mod, that currently does absolutely nothing, will appear in the mods list.
In the next section, we will add a new item to our mod.
B2 - Your First Item
By now you have created a basic skeleton for your first mod, which still does not do anything more than look nice in the mods list.
Lets begin. In this section we create a new item and add it to the creative menu.
Create a new class by right clicking your mod.tutorial package and clicking New > Class.
This will open a window with a few options. The ones we are worried about are name and superclass. For our example, we will set the name to ItemSandwich. We can add net.minecraft.item.Item as our superclass. Make sure you also check the Constructors from superclass box.
If you have filled the options correctly, you should end up with this code in your new ItemSandwich class:
package mod.tutorial;
import net.minecraft.item.Item;
public class ItemSandwich extends Item {
public ItemSandwich(int par1) {
super(par1);
// TODO Auto-generated constructor stub
}
}
This will serve as a skeleton for our new item. Now lets go back to our TutorialMain class. FML has a convenient method which allows you to register your new item into Minecraft. Tasks such as registering items and blocks may be done when your mod is loading. Luckily, FML also has built in event 'hooks' that are called when a particular event occurs in Minecraft, such as your mod being loaded.
Add these lines to your TutorialMain class and import the required classes:
@Init
public void load(FMLInitializationEvent event) {
}
Any code inside the load method will be executed when your mod is being loaded.
Your full TutorialMain code should now look like this:
package mod.tutorial;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
@Mod(modid="TutorialMain", name="Tutorial Mod", version="1.0")
public class TutorialMain {
@Instance("TutorialMain")
public static TutorialMain instance;
@Init
public void load(FMLInitializationEvent event) {
}
}
Now that we have a place to register our item, we can write the code to do it. Add this line inside your load method:
Item itemSandwich = new ItemSandwich(500).setItemName("itemSandwich");
When you right clickItem to import the required class, make sure you select net.minecraft.item.Item.
The above line of code simply creates a new Item named itemSandwich, which uses the ItemSandwich() class (the one we just made) and gives it the unique ID of 500.
Note: Capitalization is very important when programming. As seen above, itemSandwich is not the same as ItemSandwich().
We still need to give our item a name to show when you hover your mouse over it in Minecraft! This must be done through the Language Registry and can be accomplished by adding this line to your load method:
This simply adds the name "Sandwich" to the object itemSandwich.
Your full TutorialMain code should now look like this:
package mod.tutorial;
import net.minecraft.item.Item;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid="TutorialMain", name="Tutorial Mod", version="1.0")
public class TutorialMain {
@Instance("TutorialMain")
public static TutorialMain instance;
@Init
public void load(FMLInitializationEvent event) {
Item itemSandwich = new ItemSandwich(500).setItemName("itemSandwich");
LanguageRegistry.addName(itemSandwich, "Sandwich");
}
}
It looks like we're done!
Oops! Hold on a minute! We don't have a way to actually get this item yet. Lets add it to the creative menu for now. Crafting and smelting recipes are covered in the next section!
Go back to your ItemSandwich class.
Replace the // TODO comment with this line of code:
this.setCreativeTab(CreativeTabs.tabFood);
Obviously, this will add your new Sandwich item to the Food tab in the creative menu. There are many tabs to choose from, and it is really up to you which tab you want to put your new items in. Just because we named it Sandwich doesn't mean it must be put into the Food tab.
Eclipse will often show you a list of possibilities that you can choose from when they are available, as seen in the picture below, given that you have imported the correct classes (in our case: net.minecraft.creativetab.CreativeTabs)
Now that we have created our item, named our item, and added a way for us to get our item, we can test it out by clicking the Run Client button in the toolbar at the top.
In the next section, we will add new crafting and smelting recipes to our mod. Custom textures and icons are covered later in the tutorial.
B3 - Crafting and Smelting Recipes
By now you have created an item for your mod, but currently the only way to get your item is through the creative menu.
There are three main types of 'recipes' that we will discuss; smelting, shaped crafting, and shapeless crafting. The first is the simplest; 'smelting' recipes or furnace recipes. Implementing these allows you to put your item into a furnace to create another itemOR to use another item in a furnace to create your item. Another type of recipe is shaped crafting, or crafting on a table using a pattern. Shapeless crafting is like shaped crafting, but it does not require items to be in a pattern.
Lets begin. In this section we add a shapeless crafting recipe and smelting (furnace) recipe to our new item.
Navigate to your TutorialMain.java class.
New recipes must be registered using the GameRegistry, similar to how an item's visible name is registered using the LanguageRegistry. We can register a shapeless recipe by adding the following line in our load method:
GameRegistry.addShapelessRecipe(new ItemStack(itemSandwich,1), new ItemStack(Item.bread));
This line registers a recipe that will let you craft 1 Sandwich out of 1 Bread.
Any item that is in a container (such as your inventory or a furnace) is referred to as a stack. Note that even if you only have one of that item in your inventory, it will still be called a stack.
You can add more ingredients to the recipe as well. The first ItemStack you refer to in addShapelessRecipe() is the output and the ItemStacks after the output are the inputs.
Lets add a cooked steak to this recipe. Change the line of code to look like this:
GameRegistry.addShapelessRecipe(new ItemStack(itemSandwich,1), new ItemStack(Item.bread), new ItemStack(Item.beefCooked));
Furnace recipes work in the same way, except that you may only have one input. Note that in furnace recipes, the input comes first and the output comes second. There is also afloating point number at the end that defines how much experience the player will get for each item smelted.
Add this line to add a smelting recipe:
GameRegistry.addSmelting(itemSandwich.itemID, new ItemStack(Block.dirt), 0.0F);
This will allow you to put your Sandwich into a furnace and get 1 Dirt in return, and will not give you any experience. Note how the input is not an ItemStack in a furnace recipe, but instead an item's ID. If you wanted, you could put an integer instead of itemSandwich.itemID to achieve the same thing. The following line of code is the same as the above code:
GameRegistry.addSmelting(726, new ItemStack(Block.dirt), 0.0F);
Note: Registering item and block ID's using Forge will shift the defined ID by 256. Our Sandwich item's effective ID thus becomes 726 instead of what we defined; 500.
Getting dirt after burning a sandwich hardly seems realistic, but it is done here to show how blocks are referred to as ItemStacks in a container as well.
Your complete TutorialMain.java script should now look like this:
package mod.tutorial;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid="TutorialMain", name="Tutorial Mod", version="1.0")
public class TutorialMain {
@Instance("TutorialMain")
public static TutorialMain instance;
@Init
public void load(FMLInitializationEvent event) {
Item itemSandwich = new ItemSandwich(500).setItemName("itemSandwich");
LanguageRegistry.addName(itemSandwich, "Sandwich");
GameRegistry.addShapelessRecipe(new ItemStack(itemSandwich,1), new ItemStack(Item.bread), new ItemStack(Item.beefCooked));
GameRegistry.addSmelting(itemSandwich.itemID, new ItemStack(Block.dirt), 0.0F);
}
}
Shaped crafting can be a bit confusing.
You can use shaped crafting recipes in a 1 by 1 format, 2 by 2, or 3 by 3 format. Consider the following examples:
GameRegistry.addRecipe(new ItemStack(itemSandwich,1), "BBB","MMM","BBB", 'B' new ItemStack(Item.bread), 'M', new ItemStack(Item.beefCooked));
This line will add a 3x3 recipe, allowing you to get a Sandwich by placing 3 Bread at the top, 3 Steak in the middle, and 3 Bread at the bottom.
GameRegistry.addRecipe(new ItemStack(itemSandwich,3), "BMB","BMB","BMB", 'B', new ItemStack(Item.bread), 'M', new ItemStack(Item.beefCooked));
This is an example of another 3x3recipe that gives you 3 Sandwiches instead of 1.
Our final example uses spaces to show empty crafting table slots, and also adds a 3rd ItemStack to be used.
GameRegistry.addRecipe(new ItemStack(itemSandwich,1), " b ","mpm"," b ", 'b', new ItemStack(Item.bread), 'm', new ItemStack(Item.beefCooked), 'p', new ItemStack(Item.potato));
This line of code adds a recipe where you must put bread in the middle on the top row. In the middle row, you put meat, potato, meat. In the bottom row, you put bread in the middle. This will give you one Sandwich.
Shaped crafting recipes are added using GameRegistry.addRecipe() and can be broken down into 3 main sections. The first sectionis the output. The second sectionare letters that represent ItemStacks arranged into rows. The third section are pairings that show which Items the letters in the second section represent.
I will not be adding a shaped crafting recipe to this tutorial for now.
In the next section, we will create and add a custom texture/icon for our new item.
B4 - Custom Textures and Icons
...
Trouble understanding parts of the tutorial? Post your concerns and help make this tutorial more user-friendly!
Still working on this tutorial. Constructive feedback and comments are appreciated.
If this tutorial helped you, be sure to +1 this post.
Rollback Post to RevisionRollBack
"Never under-estimate the power that words can impart. Sticks and stones may break your bones but words can break hearts." - Tim Minchin
Time to learn some Java.
I'll be checking back here for more! This looks like it's going to be very, very helpfull.
Thank you
I haven't been prioritizing this too much, but I will be adding more to it periodically.
Edit: Just finished the Your First Item section. Sorry for the spacing problems with the code, it all seems to reset whenever I go to edit the OP. Time for some sleep.
Rollback Post to RevisionRollBack
"Never under-estimate the power that words can impart. Sticks and stones may break your bones but words can break hearts." - Tim Minchin
Thank you. Thank you! Thank you, for this awesome tutorial. I have been perusing videos and forums for quite some time looking for a thorough tutorial to begin modding with forge, and all of them seemed to lead me to dead ends. After reading and completing your tutorial however, I finally got it to work. I am really looking forward to the next section.
Thank you. Thank you! Thank you, for this awesome tutorial. I have been perusing videos and forums for quite some time looking for a thorough tutorial to begin modding with forge, and all of them seemed to lead me to dead ends. After reading and completing your tutorial however, I finally got it to work. I am really looking forward to the next section.
^ ^ Glad it helped. I didn't think many people were reading it, but I will try to update it more often from now on.
You can set the PATH variable by going to My Computer > System Properties > Advanced System Properties > Advanced > Environment Variables... Make sure you edit the User variables (top list) and not the System variables (bottom list).
If you do not have a PATH variable in User variables, create a new one by clicking the New... button under the User variables list.
If this is not clear enough, I can add a picture tutorial like the ones in the OP.
Good luck
- Ky
Rollback Post to RevisionRollBack
"Never under-estimate the power that words can impart. Sticks and stones may break your bones but words can break hearts." - Tim Minchin
Really useful tutorials thanks. Wating for the next one now though...
^ ^ Glad they help. I am working on the Crafting tutorial right now and it will be posted within 30 minutes or so.
I will begin work on the texturing and icons tutorial immediately after and hope to have it done today as well.
You can follow this topic to easily catch changes and additions I make onto the tutorials.
Rollback Post to RevisionRollBack
"Never under-estimate the power that words can impart. Sticks and stones may break your bones but words can break hearts." - Tim Minchin
Please make more forge mod making tutorials u are pretty good at making simple, easy to understand tutorials. I wanted to learn how to code but couldnt find bupkiss that would work for me. plus make can you make these tutorials here : Your First Mob, Your First Block, Make A 3D Model For Your Mob/Entity, Your First Tile-Entity, Meta-Data, and everything in that sense. heres a notch head
Ok sorry about this post but i must left all this relife (spelled it wrong?) out. But i finally managed to get it to decompile minecraft!!!! ive been sitting here searching google to decompile it cause the forge thing doesnt do anything for me it just sits there doing nothing and sometimes it says the client and server jar arent there plus KyWest be a little more specific as to where the "Path" variable ends i searched it up and it needs to be where a java bin folder is (google it) (maybe im the dumb dumb here cause my pc that im going to use for modding while at school then passing it over is very slow 1 GB RAM)
Please make more forge mod making tutorials u are pretty good at making simple, easy to understand tutorials. I wanted to learn how to code but couldnt find bupkiss that would work for me. plus make can you make these tutorials here : Your First Mob, Your First Block, Make A 3D Model For Your Mob/Entity, Your First Tile-Entity, Meta-Data, and everything in that sense. heres a notch head
I will add First Mob + Mob Entity, First Block + Tile Entity and Meta-Data to the list. I can't make a coding tutorial for models because I know very little about that myself. I use Techne by ZeuX to make models.
Ok sorry about this post but i must left all this relife (spelled it wrong?) out. But i finally managed to get it to decompile minecraft!!!! ive been sitting here searching google to decompile it cause the forge thing doesnt do anything for me it just sits there doing nothing and sometimes it says the client and server jar arent there plus KyWest be a little more specific as to where the "Path" variable ends i searched it up and it needs to be where a java bin folder is (google it) (maybe im the dumb dumb here cause my pc that im going to use for modding while at school then passing it over is very slow 1 GB RAM)
When you run the install.cmd file, it will decompile Minecraft for you. If after opening the file, it does not start installing, then the most likely problem is that you don't have the most recent version of Java installed. Go to the Java website and use the tool that they have to check if you have Java installed. This tool will also tell you if your version of Java is outdated.
I would imagine simply playing Minecraft would be hard enough for you with only 1gb of ram, thats half of the minimum system requirements for Minecraft. If your going to be modding, I would strongly suggest using a system with ATLEAST 4gb of ram, and very preferrably one that is owned by you.
PS: Spelling your looking for is relief.
Rollback Post to RevisionRollBack
"Never under-estimate the power that words can impart. Sticks and stones may break your bones but words can break hearts." - Tim Minchin
I just said this is only for making mods i did not say this is for playing it cause i have a biggger better pc that has 4 GB RAM that i would pass my stuff to and i did have the most recent java its on auto update i checked also the JDK its the same u used but when i manualy decompiled it with MCP on this small pc it took me like 1100 secs so i imagine it would take longer on the forge thing and i would get to impatient to wait for a word to appear on the log. and ty for the word correction now im off to school to sleep and code this game :POh and i also use techne to make models and i already finished 1 model just dont know what to do with them after that so i need to code
(death has fallen upon me) remember what i said that instead of decompiling mc with forge i did it manually with mcp well let me summarize it: 1.I copy pasted both the resource folder and the bins folder which is what another website said for mcp.
2.I decompiled it all but heres the thing at 1 point it said that i decompiled the Client.jar but not the server jar im guessing i need
to download it right now (the thing for starting a server (never really used it so...))
3.when i opened eclipse and used the folder forge/fml/mcp726/eclipse it opens up with the project explorer like this:
>Client
>src
>JRE System Library[Java SE1-6]
>jinput.jar
>lwjgl_util.jar
>lwjgl.jar
>minecraft.jar
>jars
>Server
>src
>JRE System Library[Java SE1-6]
>jars
its doesnt show what u have plus i cant find ANY of those net.-----.----- things and in :
>Client
>src
>net.minecraft.src
is where i find the things like blocks,achievments,callables.biomegens,etc.
(i also still havent forge into the actual game while i did all this i was leaving that for last)
(and so u can see if im being dumb here heres what i did for a Path variable:
(death has fallen upon me) remember what i said that instead of decompiling mc with forge i did it manually with mcp well let me summarize it: 1.I copy pasted both the resource folder and the bins folder which is what another website said for mcp.
2.I decompiled it all but heres the thing at 1 point it said that i decompiled the Client.jar but not the server jar im guessing i need
to download it right now (the thing for starting a server (never really used it so...))
3.when i opened eclipse and used the folder forge/fml/mcp726/eclipse it opens up with the project explorer like this:
>Client
>src
>JRE System Library[Java SE1-6]
>jinput.jar
>lwjgl_util.jar
>lwjgl.jar
>minecraft.jar
>jars
>Server
>src
>JRE System Library[Java SE1-6]
>jars
its doesnt show what u have plus i cant find ANY of those net.-----.----- things and in :
>Client
>src
>net.minecraft.src
is where i find the things like blocks,achievments,callables.biomegens,etc.
(i also still havent forge into the actual game while i did all this i was leaving that for last)
Part 2)
(and so u can see if im being dumb here heres what i did for a Path variable:
sorry for the massive text bomb (dont know how to work with spoilers yet)
(early edit with no internet XD: im stupid cause i did what forge said that i should place the mcp7.26 in fml and now it does something)
In response to part 1 of your post, I would strongly recommend trashing stand-alone mcp all together and allowing the Forge install.cmd to set everything up for you. If you are manually installing mcp, you will have to know where to put what files, and tutorials can be confusing if you haven't done anything like that before. With a manual install, you will also have to manually integrate Forge's source into your Minecraft source, which can be another headache.
In response to part 2, change your PATH variable so it looks like this:
I just said this is only for making mods i did not say this is for playing it cause i have a biggger better pc that has 4 GB RAM that i would pass my stuff to and i did have the most recent java its on auto update i checked also the JDK its the same u used but when i manualy decompiled it with MCP on this small pc it took me like 1100 secs so i imagine it would take longer on the forge thing and i would get to impatient to wait for a word to appear on the log. and ty for the word correction now im off to school to sleep and code this game Oh and i also use techne to make models and i already finished 1 model just dont know what to do with them after that so i need to code
Ah. There are many tutorials out there for models in Java, but that tends to be a bit more on the advanced side. This being targeted on beginners, I would not realistically be able to include that.If there is anything else you need help with, let me know.
This is how to create a spoiler in a Minecraft forum post:
[spoiler]
Stuff you want hidden
[/spoiler]
Rollback Post to RevisionRollBack
"Never under-estimate the power that words can impart. Sticks and stones may break your bones but words can break hearts." - Tim Minchin
What is covered in this tutorial?
A1) Required Programs - Things you will need.
A2) Workspace Setup - How to install the things you will need.
B1) Your First Mod
B2) Your First Item
B3*) Crafting and Smelting Recipes
B4*) Custom Textures and Icons
C*) Packaging and Publishing Your Mod
D1*) Your First Mob
D2*) undecided (equipping mob with weapons?)
* In Progress
* Planned, but not added... yet.
* Comment with suggestions and opinions.
A1 - Required Programs
So here you are, starting off with a strong sense of self motivation and at the least a basic knowledge of how the Java programming language works. These programs aren't all required in the sense that you won't be able to mod without them, but they are strongly recommended, especially for self motivated entrepreneurs like yourself!
JDK 7 - Java Development Kit
Think of this as a box that contains many tools used by programs to help you write, compile, edit, and publish your Java code. These tools will be used by an IDE, or Integrated Development Environment, such as Eclipse.
Tip: Install the 32-bit version of JDK as the 64-bit version may be somewhat problematic.
7-Zip [32-bit] [64-bit]
This is pretty much the same thing as WinZip, only better! You don't really need this, but it helps alot, not just with Minecraft mods, but tons of other things too! It allows you to compress and decompress files quickly and efficiently by right clicking .zip or .7z files.
Minecraft Forge Source
This is a compressed file containing the backbone of your future Minecraft modding career. It includes MCP (Minecraft Coder's Pack), a powerful set of scripts that allow you to deobfuscate(clean up) and decompile Minecraft's core files into human readable Java code! Once the code has been edited, there are scripts included that will recompile and reobfuscate your code into .class files ready to be packaged into a mod. Download, but do not install this until you have set up your PATH variable. (PATH variable setup guide) Instructions on how to do this are provided in the next section.
Tip: You can use 7-Zip to convert a compressed file into a folder, as seen in the picture below.
Eclipse IDE [32-bit] [64-bit]
Eclipse is where you will be spending most of your time. Using an IDE makes working on projects dramatically easier, and with Minecraft Forge Source, you can even use Eclipse to test run your new mods before you publish them. Instructions on how to set up a workspace in Eclipse are included in the next section.
A2 - Workspace Setup
By now you should have everything you need to get started. You have installed Java SDK and downloaded Minecraft Forge Source. You have also aquired an IDE (Eclipse).
1. Setting the PATH variable.
http://www.java.com/...d/help/path.xml
2. Installing Minecraft Forge Source
Now that you have set up your path variable, you can install Forge Src. Once you have unpackaged the .zip file, you will have a forge folder that contains a file named install.cmd. Run this file and it will automatically install Minecraft Coder's Pack scripts, download needed files, and decompile Minecraft.jar files, preparing them to be modified.
3. Setting up Eclipse
When Forge has finished installing and you have launched Eclipse, Eclipse will present you with a dialog named Workspace Launcher. Click the Browse... button and navigate to the \mcp\eclipse folder located in the forge folder and click Ok. Eclipse should now open and display a tab named Project Explorer on the left side. The Project Explorer should have a folder named Minecraft, wherein Minecraft's decompiled source code is displayed. Forge Mod Loader has been integrated into this source.
B1 - Your First Mod
By now you should have the required programs downloaded and installed. You should also have finished setting up your workspace. Looks like your ready to begin modding!
First off, you will want to familiarize yourself with Eclipse's project explorer on the left hand side. This panel can be used to navigate through Minecraft's source code packages as well as packages you have added or modified. It is a very good idea to view the Forge Mod Loader source as many useful methods and classes are provided to make modding Minecraft much easier.
Organization is very important when programming. It is much easier to find bugs when your code is clean and tidy. When you are naming variables, classes, etc. you should pick a name that respects the function of what you are naming. For example, if you were creating a class for a new type of weapon, a sword, it would be wiser to name it something like ItemWeaponSword.java instead of class1.java or MyWeapon.java.
Lets begin.
In this section we create a package for our mod and create a basic skeleton.
Create a new package by pressing Ctr+N and selecting Package in the Java folder.
For the purpose of this tutorial, lets set the name of this package to mod.tutorial.
Your new package should now be visible in the Project Explorer on the left hand side.
Right click mod.tutorial and select New > Class.
This will open a window containing lots of options, many of which you don't need to worry about right now.
Make sure the package field is set to mod.tutorial.
We can set the name to TutorialMain.
By now you should have a new class named TutorialMain inside your mod.tutorial package. If you have followed the steps correctly, the TutorialMain class will have this piece of code already written for you:
Now you will want to add a line to your code that will allow Forge Mod Loader to identify your mod. Your code should now look like this:
These parameters (modid, name and version) are quite self explanatory. Your mod's ID should be unique to your mod in order to avoid possible conflicts with other mods. It is generally a good idea to use the name of your main class as your mod's ID. The name is what will be shown to users when they see your mod in the mods list. The version will also be shown in this list and you may use any format you wish.
Eclipse will show you a few errors on this new line. These can easily be fixed by importing the correct class. In most cases, Eclipse will automatically detect which class you want to reference and will provide it in the quick fixes list. Hover your mouse over @Mod and click Import 'Mod' to fix the errors.
Now your code should look like this:
Now we must add two lines that tell FML to instance your mod object in Minecraft. These lines must be added inside your TutorialMain class and you must import the referenced fml class.
Now you have completed creating the basic skeleton of your mod. Your full code should now look like this:
You can test your mod by clicking the Run Client button on the toolbar at the top.
Your new mod, that currently does absolutely nothing, will appear in the mods list.
In the next section, we will add a new item to our mod.
B2 - Your First Item
By now you have created a basic skeleton for your first mod, which still does not do anything more than look nice in the mods list.
New items are one of the most basic types of content you can add, although they have the potential to be quite complex as well. All items and blocks have a unique ID. Trying to give a new item an ID that is already taken will cause errors when trying to run your mod. Here is a reference list of all blocks and items in Minecraft, along with their respective IDs.
Lets begin.
In this section we create a new item and add it to the creative menu.
Create a new class by right clicking your mod.tutorial package and clicking New > Class.
This will open a window with a few options. The ones we are worried about are name and superclass. For our example, we will set the name to ItemSandwich. We can add net.minecraft.item.Item as our superclass. Make sure you also check the Constructors from superclass box.
If you have filled the options correctly, you should end up with this code in your new ItemSandwich class:
This will serve as a skeleton for our new item. Now lets go back to our TutorialMain class. FML has a convenient method which allows you to register your new item into Minecraft. Tasks such as registering items and blocks may be done when your mod is loading. Luckily, FML also has built in event 'hooks' that are called when a particular event occurs in Minecraft, such as your mod being loaded.
Add these lines to your TutorialMain class and import the required classes:
Any code inside the load method will be executed when your mod is being loaded.
Your full TutorialMain code should now look like this:
Now that we have a place to register our item, we can write the code to do it. Add this line inside your load method:
When you right click Item to import the required class, make sure you select net.minecraft.item.Item.
The above line of code simply creates a new Item named itemSandwich, which uses the ItemSandwich() class (the one we just made) and gives it the unique ID of 500.
Note: Capitalization is very important when programming. As seen above, itemSandwich is not the same as ItemSandwich().
We still need to give our item a name to show when you hover your mouse over it in Minecraft! This must be done through the Language Registry and can be accomplished by adding this line to your load method:
This simply adds the name "Sandwich" to the object itemSandwich.
Your full TutorialMain code should now look like this:
It looks like we're done!
Oops! Hold on a minute! We don't have a way to actually get this item yet. Lets add it to the creative menu for now. Crafting and smelting recipes are covered in the next section!
Go back to your ItemSandwich class.
Replace the // TODO comment with this line of code:
Obviously, this will add your new Sandwich item to the Food tab in the creative menu. There are many tabs to choose from, and it is really up to you which tab you want to put your new items in. Just because we named it Sandwich doesn't mean it must be put into the Food tab.
Eclipse will often show you a list of possibilities that you can choose from when they are available, as seen in the picture below, given that you have imported the correct classes (in our case: net.minecraft.creativetab.CreativeTabs)
Now that we have created our item, named our item, and added a way for us to get our item, we can test it out by clicking the Run Client button in the toolbar at the top.
In the next section, we will add new crafting and smelting recipes to our mod.
Custom textures and icons are covered later in the tutorial.
B3 - Crafting and Smelting Recipes
By now you have created an item for your mod, but currently the only way to get your item is through the creative menu.
There are three main types of 'recipes' that we will discuss; smelting, shaped crafting, and shapeless crafting.
The first is the simplest; 'smelting' recipes or furnace recipes. Implementing these allows you to put your item into a furnace to create another item OR to use another item in a furnace to create your item.
Another type of recipe is shaped crafting, or crafting on a table using a pattern.
Shapeless crafting is like shaped crafting, but it does not require items to be in a pattern.
Lets begin.
In this section we add a shapeless crafting recipe and smelting (furnace) recipe to our new item.
Navigate to your TutorialMain.java class.
New recipes must be registered using the GameRegistry, similar to how an item's visible name is registered using the LanguageRegistry. We can register a shapeless recipe by adding the following line in our load method:
This line registers a recipe that will let you craft 1 Sandwich out of 1 Bread.
Any item that is in a container (such as your inventory or a furnace) is referred to as a stack. Note that even if you only have one of that item in your inventory, it will still be called a stack.
You can add more ingredients to the recipe as well. The first ItemStack you refer to in addShapelessRecipe() is the output and the ItemStacks after the output are the inputs.
Lets add a cooked steak to this recipe. Change the line of code to look like this:
Furnace recipes work in the same way, except that you may only have one input. Note that in furnace recipes, the input comes first and the output comes second. There is also a floating point number at the end that defines how much experience the player will get for each item smelted.
Add this line to add a smelting recipe:
This will allow you to put your Sandwich into a furnace and get 1 Dirt in return, and will not give you any experience. Note how the input is not an ItemStack in a furnace recipe, but instead an item's ID. If you wanted, you could put an integer instead of itemSandwich.itemID to achieve the same thing. The following line of code is the same as the above code:
Note: Registering item and block ID's using Forge will shift the defined ID by 256. Our Sandwich item's effective ID thus becomes 726 instead of what we defined; 500.
Getting dirt after burning a sandwich hardly seems realistic, but it is done here to show how blocks are referred to as ItemStacks in a container as well.
Your complete TutorialMain.java script should now look like this:
Shaped crafting can be a bit confusing.
You can use shaped crafting recipes in a 1 by 1 format, 2 by 2, or 3 by 3 format. Consider the following examples:
This line will add a 3x3 recipe, allowing you to get a Sandwich by placing 3 Bread at the top, 3 Steak in the middle, and 3 Bread at the bottom.
This is an example of another 3x3 recipe that gives you 3 Sandwiches instead of 1.
Our final example uses spaces to show empty crafting table slots, and also adds a 3rd ItemStack to be used.
This line of code adds a recipe where you must put bread in the middle on the top row. In the middle row, you put meat, potato, meat. In the bottom row, you put bread in the middle. This will give you one Sandwich.
Shaped crafting recipes are added using GameRegistry.addRecipe() and can be broken down into 3 main sections. The first section is the output. The second section are letters that represent ItemStacks arranged into rows. The third section are pairings that show which Items the letters in the second section represent.
I will not be adding a shaped crafting recipe to this tutorial for now.
In the next section, we will create and add a custom texture/icon for our new item.
B4 - Custom Textures and Icons
...
Trouble understanding parts of the tutorial? Post your concerns and help make this tutorial more user-friendly!
Still working on this tutorial. Constructive feedback and comments are appreciated.
If this tutorial helped you, be sure to +1 this post.
Technically, it is finished.. There is simply potential for more..
Very constructive feedback by the way, thank you..
What are you referring to? Manual install version for what?
I'll be checking back here for more! This looks like it's going to be very, very helpfull.
Thank you
I haven't been prioritizing this too much, but I will be adding more to it periodically.
Edit: Just finished the Your First Item section. Sorry for the spacing problems with the code, it all seems to reset whenever I go to edit the OP. Time for some sleep.
^ ^ Glad it helped. I didn't think many people were reading it, but I will try to update it more often from now on.
You can set the PATH variable by going to My Computer > System Properties > Advanced System Properties > Advanced > Environment Variables... Make sure you edit the User variables (top list) and not the System variables (bottom list).
If you do not have a PATH variable in User variables, create a new one by clicking the New... button under the User variables list.
If this is not clear enough, I can add a picture tutorial like the ones in the OP.
Good luck
- Ky
^ ^ Glad they help. I am working on the Crafting tutorial right now and it will be posted within 30 minutes or so.
I will begin work on the texturing and icons tutorial immediately after and hope to have it done today as well.
You can follow this topic to easily catch changes and additions I make onto the tutorials.
I'm going to need a bit more information than that to help you > __ <
Copy paste the line of code that your having trouble with.
I will add First Mob + Mob Entity, First Block + Tile Entity and Meta-Data to the list. I can't make a coding tutorial for models because I know very little about that myself. I use Techne by ZeuX to make models.
When you run the install.cmd file, it will decompile Minecraft for you. If after opening the file, it does not start installing, then the most likely problem is that you don't have the most recent version of Java installed. Go to the Java website and use the tool that they have to check if you have Java installed. This tool will also tell you if your version of Java is outdated.
I would imagine simply playing Minecraft would be hard enough for you with only 1gb of ram, thats half of the minimum system requirements for Minecraft. If your going to be modding, I would strongly suggest using a system with ATLEAST 4gb of ram, and very preferrably one that is owned by you.
PS: Spelling your looking for is relief.
2.I decompiled it all but heres the thing at 1 point it said that i decompiled the Client.jar but not the server jar im guessing i need
to download it right now (the thing for starting a server (never really used it so...))
3.when i opened eclipse and used the folder forge/fml/mcp726/eclipse it opens up with the project explorer like this:
>Client
>src
>JRE System Library[Java SE1-6]
>jinput.jar
>lwjgl_util.jar
>lwjgl.jar
>minecraft.jar
>jars
>Server
>src
>JRE System Library[Java SE1-6]
>jars
its doesnt show what u have plus i cant find ANY of those net.-----.----- things and in :
>Client
>src
>net.minecraft.src
is where i find the things like blocks,achievments,callables.biomegens,etc.
(i also still havent forge into the actual game while i did all this i was leaving that for last)
(and so u can see if im being dumb here heres what i did for a Path variable:
Users:
Variable Name:Path
Variable Value:C:\Program Files\Java\jdk1.7.0_13\bin;C:\Program Files\Java\jre6\bin;C:\Program Files\Java\jre7\bin
i added all of my java things just to be safe)
any help here?
sorry for the massive text bomb (dont know how to work with spoilers yet)
(early edit with no internet XD: im stupid cause i did what forge said that i should place the mcp7.26 in fml and now it does something)
In response to part 1 of your post, I would strongly recommend trashing stand-alone mcp all together and allowing the Forge install.cmd to set everything up for you. If you are manually installing mcp, you will have to know where to put what files, and tutorials can be confusing if you haven't done anything like that before. With a manual install, you will also have to manually integrate Forge's source into your Minecraft source, which can be another headache.
In response to part 2, change your PATH variable so it looks like this:
Ah. There are many tutorials out there for models in Java, but that tends to be a bit more on the advanced side. This being targeted on beginners, I would not realistically be able to include that.If there is anything else you need help with, let me know.
This is how to create a spoiler in a Minecraft forum post:
testing
ty