These tutorials are for people that have some experience coding in Java. Of course you can learn Java by modding, like i did, but I personally don't suggest it!
I'm still working on them and i hope to get the basic tutorials done by this week.
The tutorials will not be posted on the forums, because there a annoying backspace bug that is getting on my nerves ! It will be posted on my[font=arial, helvetica, sans-serif] blog. Hope you guys can learn something from it ^.^![/font]
Sorry for my bad English, hope you guys wont mind.
I suggest you to my page but if you really really want to use the forums, just head to the bottom.
Click here to go to my homepage.
[font=Times New Roman][font=arial, helvetica, sans-serif]Setting up[/font][/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]FAQ[/font][/font]
You wouldn't believe how much I would [font=arial, helvetica, sans-serif]prefer you use [/font]my page. Not just i can keep count on page view, but for other personal reasons as well. my page
[font=arial, helvetica, sans-serif]Here are the tutorials on the forum [/font][font=arial, helvetica, sans-serif]
[/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]Setting up [/font][font=arial, helvetica, sans-serif][/font][/font]
[font=Times New Roman][font=arial,helvetica,sans-serif]Setting up[/font] [font=arial, helvetica, sans-serif]
[/font]
[font=arial, helvetica, sans-serif]You will need to set-up a few things before you can start Modding Minecraft.[/font]
[font=arial, helvetica, sans-serif]Here are a few things you will need to download.[/font][/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]Download and install the latest Java JDK here.[/font]
[/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]Download Minecraft Forge. Get the recommended source version here. [/font]
[/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]Download Eclipse IDE here. This is NOT compulsory but highly recommended. The tutorials will be done in this IDE.[/font][/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]YOU MUST BE CONNECTED TO THE INTERNET WHEN YOU PERFORM THE STEPS BELLOW![/font]
[font=arial, helvetica, sans-serif]Extract Minecraft Forge using any archiver onto your desktop. You should have a folder called "forge". Open the folder and you will see a few files named "install". If you're running windows, double click on "install.cmd". If you're using a mac, try using "install.py".[/font]
[font=arial, helvetica, sans-serif]This should now download all the required files for forge to run. It should also decompile Minecraft for you.[/font]
[font=arial, helvetica, sans-serif]That's it! You're done setting up! Head back to the list of tutorials here. [/font]
[font=arial, helvetica, sans-serif]If you want to know how to set-up Eclipse IDE, click here.[/font] [font=arial, helvetica, sans-serif]Check out the FAQif you have something to ask, you might just find your answer there! [/font] Eclipse IDE
[font=arial, helvetica, sans-serif]The awesome people that maintains MCP are so awesome to bundle their awesome work with the build path for Eclipse IDE! Awesome right? Actually, it is.[/font]
[font=arial, helvetica, sans-serif]Minecraft Modders are provided with the build paths for Eclipse IDE when they download MCP. If you're wondering : "I have to download this MCP?", well no. Forge should have already done that for you! Thank the forge team for that. This means you guys can also enjoy this awesomeness with little extra work![/font][/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]Move the Eclipse folder to your desktop. [/font]
[/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]Open the folder and you should see Eclipse.exe. Start Eclipse[/font]
[/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]If this is your 1st time starting up Eclipse (most of you should be), Eclipse will ask you for a default BuildPath. Click on browse and set it to \Destop\forge\mcp\eclipse and hit ok. [/font][/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]Eclipse should do the rest, and BAM! Done! It's that simple. You're now ready to head into the world of Modding, but let me warn you in advance, at times, it will get really tough. You will feel like quitting, you will want to give up, you WILL. But if you want to take something from this paragraph, take this : Just follow along with the tutorials, you might not have to understand how it all works, but mainly, you must know how to do it![/font]
[font=arial, helvetica, sans-serif]Found a better tutorial? Good for you! different tutorials work for different people. They don't work for everyone. But once you really understand the code, you'll soon realize that all the tutorials are the same. The difference is whether you understand, or not.[/font]
[font=arial, helvetica, sans-serif]Head back here, after you're done setting up![/font] [font=arial, helvetica, sans-serif][/font]
[font=arial, helvetica, sans-serif][/font]
[font=arial, helvetica, sans-serif]Before you can start changing the game, there are a few things you will need to know. This will always be the same for every Mod you make.[/font]
[font=arial, helvetica, sans-serif]You will need to Open up Eclipse. If you have set-up Eclipse properly, you should see a small folder on the left called Minecraft. Expend it and you will see another folder called src. Expend it as well. See all those squares with a "+" sign on it? That is the source code of Minecraft. [/font]
[font=arial, helvetica, sans-serif]Right click on the src folder. Then go to New > Package. It will ask you for a Package name. Name it anything you want. Lets name it : tutorial. Once you're done hit finish.[/font]
[font=arial, helvetica, sans-serif]Scroll down till you find the Package you just created, it should be in white. Right click it and go to New > Class. Lets name this class : Tutorial. [/font]
[font=arial, helvetica, sans-serif]Now that you created your class, time to write something in that class.[/font]
[font=arial, helvetica, sans-serif]You should have something like this:[/font]
[font=arial, helvetica, sans-serif]The keyword package is used by Java to declare the package the class is in. You should go learn some Java first if you don't understand. I'm not to sure how to explain it in text.[/font]
[font=arial, helvetica, sans-serif]Next, we have publicclass Tutorial. Public is an excess modifier that tell Java, anyone can use it. The keyword class declares the class name, in this case, Tutorial.[/font]
[font=arial, helvetica, sans-serif]@Mod(modid = "Tutorial Mod", name = "Tutorial Mod", version = "1.0.0")[/font]
[font=arial, helvetica, sans-serif]You will need to type this above the class declaration.[/font] [font=arial, helvetica, sans-serif]@Mod tells Forge that this is a Mod, and Forge will help you register it.[/font] [font=arial, helvetica, sans-serif]The first parameter is modid. This must be unique to your mod. If another mod shares the same modid with yours, the mods will not work together. Lets call it "Tutorial Mod" for this tutorial.[/font] [font=arial, helvetica, sans-serif]The second parameter is name. This is the name of your mod. This will be displayed in the Mods screen on the Title Page. Lets call it "Tutorial Mod" for this tutorial.[/font] [font=arial, helvetica, sans-serif]The last parameter is version. Any string will do, and I think I don't have to explain this parameter.[/font]
[font=arial, helvetica, sans-serif]There should be an error on @Mod. This is because you have to import it from another class. You can just hit Shift + Ctrl + O to solve this.[/font]
[font=arial, helvetica, sans-serif]Here is another annotation you need to have in your mod to let it work in SMP.[/font] [font=arial, helvetica, sans-serif]@NetworkMod Takes 2 parameters, clientSideRequired and severSideRequired. clientSideRequired should always be set to true while severSideRequired should always be false. If clientSideRequired is true that means you need to have this Mod on your client to work. severSideRequired should be false, or else you cannot join severs that don't have this Mod.[/font]
[font=arial, helvetica, sans-serif]All you need to know for now is that you will need this to let your mod work in SMP.[/font]
[font=arial, helvetica, sans-serif]Again, you should have an error on @NetworkMod, you'll need to import the classes again. You can just hit Shift + Ctrl + O to solve this.[/font]
[font=arial, helvetica, sans-serif][font=Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif]@Init is [/font]where most of your code should go. publicvoid load(FMLInitializationEvent event){} tells forge to initialize all the code found between the curly brackets.[/font]
[font=arial, helvetica, sans-serif]Once again, import the required classes and you are good to go. [/font]
[font=arial, helvetica, sans-serif]Your final Basic Mod file should look like this[/font]
[font=arial, helvetica, sans-serif]You're good to go! You are officially ready to start modding! Have fun![/font]
[font=arial, helvetica, sans-serif]When you're done you should go back to the list of tutorials here.[/font] [font=arial, helvetica, sans-serif][/font]
[font=arial, helvetica, sans-serif][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]public class Tutorial[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]{ [/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] @Init[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] public void load(FMLInitializationEvent event)[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] {[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] }[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
I suggest trying out Minecraft 1st before we start this tutorial. To do this, just hit the GREEN PLAY ARROW ">" on the Menu bar. This should start up forge, and it should help you download some stuff. A few moments latter Minecraft should start. If it crashes, you might have misspelled something. Look the the bottom left corner of Minecraft. Look at the number of mods installed. Does it say 4? If it does, that mean you have set up everything correctly.
Now, check out the list of mods from your Title Screen. You will notice that there is a Mod called Tutorial Mod.
Time to add your very first block to Minecraft!!!
public static Block UglyStoneBlock;
This should go above @Init. This creates a new Block variable called UglyStoneBlock. You will have more errors, just import the classes using Ctrl + Shift + O. Import the net.minecraft.src.Block class. It should solve all the error for now.
Now that you created a Block variable, you need it to have some properties (eg. Hardness, Resistance, LightValue, bla bla). To do this, you will need to add this bit of code. This goes inside public void load(FMLInitilizationEvent event){}
UglyStoneBlock = new UglyStoneBlock(501, Material.wood).setUnlocalizedName("UglyStone").setHardness(0.1F).setResistance(0.1F).setLightValue(1F);
Don't fall off your chairs! This is amazingly simple! UglyStoneBlock = new UglyStoneBlock(501) Creates a new UglyStoneBlock object. If you have played Minecraft for a while, you will know that every block has his own block ID. The number between the brackets UglyStoneBlock(501) is the block ID for this block. Easy. The ID for every block must be unique, or else Minecraft will crash.
The next part, .setUnlocalizedName("UglyStone").setHardness(0.1F).setResistance(0.1F).setLightValue(1F);
is also extremely simple. Lets break this into individual sections so we can understand this easier.
.setUnlocalizedName("UglyStone")
.setHardness(0.1F)
.setResistance(0.1F)
.setLightValue(1F)
The first one, .setUnlocalizedName("UglyStone") gives the block a name. This is used latter to register the Block. The second one is .setHardness(0.1F). This is how long you will need to hit the block before it breaks. It takes 1 parameter, a float. (0.1F) is extremely small. The block is very very very easy to break. Try bigger numbers if you want, but for this tutorial, lets set it to 0.1F. If you want to change the number, remember to a F behind it because it is a float. .setResistance(0.1F) Gives the block a resistance value to TNT. The bigger the number, the harder it is for TNT to blow it up. And finally, and most probably the funnest, .setLightValue(1F). This lets the block emit light, like glowstone. If you do not want your block to glow, then just remove this.
You should get errors on new UglyStoneBlock(501). Don't worry about it, it will be cleared in part 2.
Now lets register this Block with forge
GameRegistry.registerBlock(UglyStoneBlock, "UglyStone");
This registers the block with forge. The first parameter is the Block variable you declared. The second parameter should be the same is .setUnlocalizedName("UglyStone").
Next, lets give it a in-game name.
LanguageRegistry.addName(UglyStoneBlock, "UglyStone");
The first parameter is the Block variable you declared. The second parameter is the in-game name.
This is how your file should look like
package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.Mod;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.Mod.Init;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.event.FMLInitializationEvent;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.network.NetworkMod;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]@Mod(modid = "Tutorial Mod", name = "Tutorial Mod", version = "1.0.0")[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] {[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]UglyStoneBlock = new UglyStoneBlock(501, Material.wood).setUnlocalizedName("UglyStone").setHardness(0.1F).setResistance(0.1F).setLightValue(1F);
GameRegistry.registerBlock(UglyStoneBlock, "UglyStone");
LanguageRegistry.addName(UglyStoneBlock, "Ugly Stone");[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] }[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
First, import the classes needed if haven't already done that. (Ctrl+Shift+O). Move your cursor over new UglyStoneBlock(501) and you a small box should appear asking to create a class. Create the class. package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]publicclass UglyStoneBlock{[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
The class should look like this. We need to extend the Block class, to do that, we have to type in package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import net.minecraft.block.Block;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]{[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
Note that i imported the Block class. Next, you will have to add this bit of code in the class.
public UglyStoneBlock(int id, Material par2Material)
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]{[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]super(id, par2Material);[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] this.setCreativeTab(CreativeTabs.tabBlock);[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
Remember the UglyStoneBlock(501, Material.wood)? super(id, par2Material); takes the 2 parameters the block ID, and the Material. this.setCreativeTab(CreativeTabs.tabBlock); Lets your block appear in the creative inventory menu. You can change which tab it appears on by changing CreativeTabs.tabBlock. There is .tabDecorations, .tabCombat, and a few more.
Your file should look like this
package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]publicclass UglyStoneBlock{[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] public UglyStoneBlock(int id, Material par2Material)
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] {[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]super(id, par2Material);[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] this.setCreativeTab(CreativeTabs.tabBlock);[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] }[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
Import the classes needed if there are any, and you are done! Hit run and create a new world
You should find your block under the creative menu in the Blocks tab.!
Feel free to post questions in this topic. I will try my best to answer all of them. Check out the FAQ(It is still empty, because I'm not sure what questions will you guys frequently ask >.<").[/font]
Nice, good for starting out, but needs a little more, most people ask or want these codes:
Biomes
Dimensions
Surface generation
Nether generation
End generation
Blocks
Items
Achievements
Custom sounds
Custom music
Custom block step sounds
Colorful item names
Enchantment effects
Shapeless recipes
Recipes
Furnace smelting recipes
Advanced blocks
Advances items
Brewing recipes
And even more
Just some tips to help you become famous in the feature!
Thanks.
Haha, thanks! I plan to slowly add more and more tutorials. But I've experienced a problem before and that is that Minecraft updates too fast. I might NOT be able to cover all the tutorials before Minecraft goes to a newer version. If forge updates, sometimes it also breaks my tutorials. =O
Haha, thanks! I plan to slowly add more and more tutorials. But I've experienced a problem before and that is that Minecraft updates too fast. I might NOT be able to cover all the tutorials before Minecraft goes to a newer version. If forge updates, sometimes it also breaks my tutorials. =O
Yes I under stand, like when ModLoader updated to 1.5 I had many issues with like .setItemName and forge had changed from multiple pictures using .setItemCoord to a single picture.
If you need some help with development for forge I could help you with some codes.
These tutorials are for people that have some experience coding in Java. Of course you can learn Java by modding, like i did, but I personally don't suggest it!
I'm still working on them and i hope to get the basic tutorials done by this week.
The tutorials will not be posted on the forums, because there a annoying backspace bug that is getting on my nerves ! It will be posted on my[font=arial, helvetica, sans-serif] blog. Hope you guys can learn something from it ^.^![/font]
Sorry for my bad English, hope you guys wont mind.
I suggest you to my page but if you really really want to use the forums, just head to the bottom.
Click here to go to my homepage.
[font=Times New Roman][font=arial, helvetica, sans-serif]Setting up[/font][/font]
[font=Times New Roman][font=arial, helvetica, sans-serif]- Setting up[/font]
[font=arial, helvetica, sans-serif]- Eclipse IDE[/font]
[font=arial, helvetica, sans-serif]Basics[/font]
[font=arial, helvetica, sans-serif]- Basic Mod file[/font]
[font=arial, helvetica, sans-serif]Blocks[/font][/font]
-Basic Block part 1
-Basic Block part 2
-Custom Textures for Blocks
[font=Times New Roman][font=arial, helvetica, sans-serif]FAQ[/font][/font]
You wouldn't believe how much I would [font=arial, helvetica, sans-serif]prefer you use [/font]my page. Not just i can keep count on page view, but for other personal reasons as well. my page
[font=arial, helvetica, sans-serif]Here are the tutorials on the forum [/font][font=arial, helvetica, sans-serif]
[font=Times New Roman][font=arial, helvetica, sans-serif]Setting up [/font][font=arial, helvetica, sans-serif][/font][/font]
[font=Times New Roman][font=arial,helvetica,sans-serif]Setting up[/font] [font=arial, helvetica, sans-serif]
[font=arial, helvetica, sans-serif]You will need to set-up a few things before you can start Modding Minecraft.[/font]
[font=arial, helvetica, sans-serif]Here are a few things you will need to download.[/font][/font]
[font=arial, helvetica, sans-serif]Extract Minecraft Forge using any archiver onto your desktop. You should have a folder called "forge". Open the folder and you will see a few files named "install". If you're running windows, double click on "install.cmd". If you're using a mac, try using "install.py".[/font]
[font=arial, helvetica, sans-serif]This should now download all the required files for forge to run. It should also decompile Minecraft for you.[/font]
[font=arial, helvetica, sans-serif]That's it! You're done setting up! Head back to the list of tutorials here. [/font]
[font=arial, helvetica, sans-serif]If you want to know how to set-up Eclipse IDE, click here.[/font]
[font=arial, helvetica, sans-serif]Check out the FAQif you have something to ask, you might just find your answer there! [/font]
Eclipse IDE
[font=arial, helvetica, sans-serif]The awesome people that maintains MCP are so awesome to bundle their awesome work with the build path for Eclipse IDE! Awesome right? Actually, it is.[/font]
[font=arial, helvetica, sans-serif]Minecraft Modders are provided with the build paths for Eclipse IDE when they download MCP. If you're wondering : "I have to download this MCP?", well no. Forge should have already done that for you! Thank the forge team for that. This means you guys can also enjoy this awesomeness with little extra work![/font][/font]
[font=arial, helvetica, sans-serif]Found a better tutorial? Good for you! different tutorials work for different people. They don't work for everyone. But once you really understand the code, you'll soon realize that all the tutorials are the same. The difference is whether you understand, or not.[/font]
[font=arial, helvetica, sans-serif]Head back here, after you're done setting up![/font]
[font=arial, helvetica, sans-serif][/font]
[font=arial, helvetica, sans-serif][/font]
Basics [font=arial, helvetica, sans-serif]
Basic Mod file [font=arial, helvetica, sans-serif]
[font=arial, helvetica, sans-serif]Before you can start changing the game, there are a few things you will need to know. This will always be the same for every Mod you make.[/font]
[font=arial, helvetica, sans-serif]You will need to Open up Eclipse. If you have set-up Eclipse properly, you should see a small folder on the left called Minecraft. Expend it and you will see another folder called src. Expend it as well. See all those squares with a "+" sign on it? That is the source code of Minecraft. [/font]
[font=arial, helvetica, sans-serif]Right click on the src folder. Then go to New > Package. It will ask you for a Package name. Name it anything you want. Lets name it : tutorial. Once you're done hit finish.[/font]
[font=arial, helvetica, sans-serif]Scroll down till you find the Package you just created, it should be in white. Right click it and go to New > Class. Lets name this class : Tutorial. [/font]
[font=arial, helvetica, sans-serif]Now that you created your class, time to write something in that class.[/font]
[font=arial, helvetica, sans-serif]You should have something like this:[/font]
[font=arial, helvetica, sans-serif]package tutorial;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]public class Tutorial {[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]}[/font][/font]
[font=arial, helvetica, sans-serif]The keyword package is used by Java to declare the package the class is in. You should go learn some Java first if you don't understand. I'm not to sure how to explain it in text.[/font]
[font=arial, helvetica, sans-serif]Next, we have public class Tutorial. Public is an excess modifier that tell Java, anyone can use it. The keyword class declares the class name, in this case, Tutorial.[/font]
[font=arial, helvetica, sans-serif]@Mod(modid = "Tutorial Mod", name = "Tutorial Mod", version = "1.0.0")[/font]
[font=arial, helvetica, sans-serif]You will need to type this above the class declaration.[/font]
[font=arial, helvetica, sans-serif]@Mod tells Forge that this is a Mod, and Forge will help you register it.[/font]
[font=arial, helvetica, sans-serif]The first parameter is modid. This must be unique to your mod. If another mod shares the same modid with yours, the mods will not work together. Lets call it "Tutorial Mod" for this tutorial.[/font]
[font=arial, helvetica, sans-serif]The second parameter is name. This is the name of your mod. This will be displayed in the Mods screen on the Title Page. Lets call it "Tutorial Mod" for this tutorial.[/font]
[font=arial, helvetica, sans-serif]The last parameter is version. Any string will do, and I think I don't have to explain this parameter.[/font]
[font=arial, helvetica, sans-serif]There should be an error on @Mod. This is because you have to import it from another class. You can just hit Shift + Ctrl + O to solve this.[/font]
[font=arial, helvetica, sans-serif]@NetworkMod(clientSideRequired = true, severSideRequired = false)[/font]
[font=arial, helvetica, sans-serif]Here is another annotation you need to have in your mod to let it work in SMP.[/font]
[font=arial, helvetica, sans-serif]@NetworkMod Takes 2 parameters, clientSideRequired and severSideRequired. clientSideRequired should always be set to true while severSideRequired should always be false. If clientSideRequired is true that means you need to have this Mod on your client to work. severSideRequired should be false, or else you cannot join severs that don't have this Mod.[/font]
[font=arial, helvetica, sans-serif]All you need to know for now is that you will need this to let your mod work in SMP.[/font]
[font=arial, helvetica, sans-serif]Again, you should have an error on @NetworkMod, you'll need to import the classes again. You can just hit Shift + Ctrl + O to solve this.[/font]
[font=arial, helvetica, sans-serif][font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]@Init[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]public void load(FMLInitializationEvent event)[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]{[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif] [/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]}[/font][/font]
[font=arial, helvetica, sans-serif][font=Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif]@Init is [/font]where most of your code should go. public void load(FMLInitializationEvent event){} tells forge to initialize all the code found between the curly brackets.[/font]
[font=arial, helvetica, sans-serif]Once again, import the required classes and you are good to go. [/font]
[font=arial, helvetica, sans-serif]Your final Basic Mod file should look like this[/font]
[font=arial, helvetica, sans-serif]package tutorial;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]import cpw.mods.fml.common.Mod;[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]import cpw.mods.fml.common.Mod.Init;[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]import cpw.mods.fml.common.event.FMLInitializationEvent;[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]import cpw.mods.fml.common.network.NetworkMod;[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]@Mod(modid = "Tutorial Mod", name = "Tutorial Mod", version = "1.0.0")[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]@NetworkMod(clientSideRequired = true, serverSideRequired = false)[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]public class Tutorial[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]{ [/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif] @Init[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif] public void load(FMLInitializationEvent event)[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif] {[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif] [/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif] }[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif][font=arial, helvetica, sans-serif]}[/font][/font]
[font=arial, helvetica, sans-serif]You're good to go! You are officially ready to start modding! Have fun![/font]
[font=arial, helvetica, sans-serif]When you're done you should go back to the list of tutorials here.[/font]
[font=arial, helvetica, sans-serif][/font]
[font=arial, helvetica, sans-serif][/font]
Blocks [font=arial, helvetica, sans-serif]
Basic Block part 1 [font=arial, helvetica, sans-serif]
Now, you're going to learn how to add a blog to Minecraft. It is very easy and it shouldn't take too long to master.
This is how your Tutorial class should look like
package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.Mod;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.Mod.Init;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.event.FMLInitializationEvent;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.network.NetworkMod;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]@Mod(modid = "Tutorial Mod", name = "Tutorial Mod", version = "1.0.0")[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]@NetworkMod(clientSideRequired = true, serverSideRequired = false)[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]public class Tutorial[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]{ [/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] @Init[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] public void load(FMLInitializationEvent event)[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] {[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] [/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] }[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
I suggest trying out Minecraft 1st before we start this tutorial. To do this, just hit the GREEN PLAY ARROW ">" on the Menu bar. This should start up forge, and it should help you download some stuff. A few moments latter Minecraft should start. If it crashes, you might have misspelled something. Look the the bottom left corner of Minecraft. Look at the number of mods installed. Does it say 4? If it does, that mean you have set up everything correctly.
Now, check out the list of mods from your Title Screen. You will notice that there is a Mod called Tutorial Mod.
Time to add your very first block to Minecraft!!!
public static Block UglyStoneBlock;
This should go above @Init. This creates a new Block variable called UglyStoneBlock. You will have more errors, just import the classes using Ctrl + Shift + O. Import the net.minecraft.src.Block class. It should solve all the error for now.
Now that you created a Block variable, you need it to have some properties (eg. Hardness, Resistance, LightValue, bla bla). To do this, you will need to add this bit of code. This goes inside public void load(FMLInitilizationEvent event){}
UglyStoneBlock = new UglyStoneBlock(501, Material.wood).setUnlocalizedName("UglyStone").setHardness(0.1F).setResistance(0.1F).setLightValue(1F);
Don't fall off your chairs! This is amazingly simple! UglyStoneBlock = new UglyStoneBlock(501) Creates a new UglyStoneBlock object. If you have played Minecraft for a while, you will know that every block has his own block ID. The number between the brackets UglyStoneBlock(501) is the block ID for this block. Easy. The ID for every block must be unique, or else Minecraft will crash.
The next part, .setUnlocalizedName("UglyStone").setHardness(0.1F).setResistance(0.1F).setLightValue(1F);
is also extremely simple. Lets break this into individual sections so we can understand this easier.
.setUnlocalizedName("UglyStone")
.setHardness(0.1F)
.setResistance(0.1F)
.setLightValue(1F)
The first one, .setUnlocalizedName("UglyStone") gives the block a name. This is used latter to register the Block. The second one is .setHardness(0.1F). This is how long you will need to hit the block before it breaks. It takes 1 parameter, a float. (0.1F) is extremely small. The block is very very very easy to break. Try bigger numbers if you want, but for this tutorial, lets set it to 0.1F. If you want to change the number, remember to a F behind it because it is a float. .setResistance(0.1F) Gives the block a resistance value to TNT. The bigger the number, the harder it is for TNT to blow it up. And finally, and most probably the funnest, .setLightValue(1F). This lets the block emit light, like glowstone. If you do not want your block to glow, then just remove this.
You should get errors on new UglyStoneBlock(501). Don't worry about it, it will be cleared in part 2.
Now lets register this Block with forge
GameRegistry.registerBlock(UglyStoneBlock, "UglyStone");
This registers the block with forge. The first parameter is the Block variable you declared. The second parameter should be the same is .setUnlocalizedName("UglyStone").
Next, lets give it a in-game name.
LanguageRegistry.addName(UglyStoneBlock, "UglyStone");
The first parameter is the Block variable you declared. The second parameter is the in-game name.
This is how your file should look like
package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.Mod;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.Mod.Init;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.event.FMLInitializationEvent;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.network.NetworkMod;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]@Mod(modid = "Tutorial Mod", name = "Tutorial Mod", version = "1.0.0")[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]@NetworkMod(clientSideRequired = true, serverSideRequired = false)[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]public class Tutorial[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]{ [/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] @Init[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] public void load(FMLInitializationEvent event)[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] {[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] UglyStoneBlock = new UglyStoneBlock(501, Material.wood).setUnlocalizedName("UglyStone").setHardness(0.1F).setResistance(0.1F).setLightValue(1F);
GameRegistry.registerBlock(UglyStoneBlock, "UglyStone");
LanguageRegistry.addName(UglyStoneBlock, "UglyStone");[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] }[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
Head back HEREafter you finished.
[font=Times New Roman][font=arial, helvetica, sans-serif] [/font][/font]
[font=arial, helvetica, sans-serif]Basic Block part 2 [/font]
[font=arial, helvetica, sans-serif]
Now, you will create a class for the Block.
This is the file we will start with.
package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.Mod;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.Mod.Init;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.event.FMLInitializationEvent;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import cpw.mods.fml.common.network.NetworkMod;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]@Mod(modid = "Tutorial Mod", name = "Tutorial Mod", version = "1.0.0")[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]@NetworkMod(clientSideRequired = true, serverSideRequired = false)[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]public class Tutorial[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]{ [/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] @Init[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] public void load(FMLInitializationEvent event)[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] {[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] UglyStoneBlock = new UglyStoneBlock(501, Material.wood).setUnlocalizedName("UglyStone").setHardness(0.1F).setResistance(0.1F).setLightValue(1F);
GameRegistry.registerBlock(UglyStoneBlock, "UglyStone");
LanguageRegistry.addName(UglyStoneBlock, "Ugly Stone");[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] }[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
First, import the classes needed if haven't already done that. (Ctrl+Shift+O). Move your cursor over new UglyStoneBlock(501) and you a small box should appear asking to create a class. Create the class.
package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]public class UglyStoneBlock{[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
The class should look like this. We need to extend the Block class, to do that, we have to type in
package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]import net.minecraft.block.Block;[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]public class UglyStoneBlock extends Block[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]{[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
Note that i imported the Block class. Next, you will have to add this bit of code in the class.
public UglyStoneBlock(int id, Material par2Material)
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]{[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] super(id, par2Material);[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] this.setCreativeTab(CreativeTabs.tabBlock);[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
Remember the UglyStoneBlock(501, Material.wood)? super(id, par2Material); takes the 2 parameters the block ID, and the Material. this.setCreativeTab(CreativeTabs.tabBlock); Lets your block appear in the creative inventory menu. You can change which tab it appears on by changing CreativeTabs.tabBlock. There is .tabDecorations, .tabCombat, and a few more.
Your file should look like this
package tutorial;
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]public class UglyStoneBlock{[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] public UglyStoneBlock(int id, Material par2Material)
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] {[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] super(id, par2Material);[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] this.setCreativeTab(CreativeTabs.tabBlock);[/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif] }[/font][/font]
[font=Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif]}[/font]
Import the classes needed if there are any, and you are done! Hit run and create a new world
You should find your block under the creative menu in the Blocks tab.!
Head back here when you're done.
FAQ
Feel free to post questions in this topic. I will try my best to answer all of them. Check out the FAQ(It is still empty, because I'm not sure what questions will you guys frequently ask >.<").[/font]
Nice, good for starting out, but needs a little more, most people ask or want these codes:
Biomes
Dimensions
Surface generation
Nether generation
End generation
Blocks
Items
Achievements
Custom sounds
Custom music
Custom block step sounds
Colorful item names
Enchantment effects
Shapeless recipes
Recipes
Furnace smelting recipes
Advanced blocks
Advances items
Brewing recipes
And even more
Just some tips to help you become famous in the feature!
Thanks.
Haha, thanks! I plan to slowly add more and more tutorials. But I've experienced a problem before and that is that Minecraft updates too fast. I might NOT be able to cover all the tutorials before Minecraft goes to a newer version. If forge updates, sometimes it also breaks my tutorials. =O
Keep up the good work!
http://www.sakkiswonderland.com
Your telling me, after camping its reather I go to bed or drink coffee at Daylight Dough-nuts
Yes I under stand, like when ModLoader updated to 1.5 I had many issues with like .setItemName and forge had changed from multiple pictures using .setItemCoord to a single picture.
If you need some help with development for forge I could help you with some codes.
Did you decompile your forge correctly? Which forge build are you using?
(I might not be able to reply you now, its 12 midnight here in Malaysia)