Blogs Tutorial

Minecraft Mod Making - Episode 2 - Basic Files

  • 526 views 0 today
  • 4
  • 1
  • 6
mysteryman3546
Lvl 75Legendary Creeper Hugger
143

Introduction


In this tutorial I will show you how to create your very first basic file that you will need before you can add anything to the game.

THERE IS A WEIRD PROBLEM WITH THE

Step 1 [Getting Ready]


1) Open Up your Minecraft Directory in Eclipse
2) Then "src"
3) Then Right Click anywhere on any package
4) Press New and Create a New Package inside of the Common Folder in Eclipse.
5) When you click that a window will pop up that asks you for the package name.
*The Name could be anything, but I recommend your Mod Name*
6) Now Select the Package you just created and right click again
7) Press New and Select Class
8) Again a window will pop up telling you that you need to give it a name. The file you are going to create right now is the mod file. It will contain the most important information about your mod. It will contain recipes, blocks, items and much more. *I suggest giving this file the name of your mod*
9) When you created your File it should look like this:

Starting Command Lines
package Your_Name;

public class Your_Name {



}


Step 2 [Naming and Configuring your Mod]


1) Add the following Line above the Public Class Your_Name Line. It should be something like this:


Line Above Public Class Line
@Mod(modid = Your_Name.modid, name = "Mod_Name", version = "1.0")


Step 2a [Explanation for Step 2]


1) Inside of the quotation marks is the Mod ID of your Mod. *This has to be unique for every single mod or it will crash*
2) Right now you will have an error under modid. That is because you are trying to access a variable you haven't made just yet. We will do that in just a second.
3) Inside of the brackets is the Mod Name. This will show up inside of the Minecraft Client.
4) The last thing is the Version Number. This one will as well show up inside of the Minecraft Client.
5) You will probably get some errors right now under @Mod.
6) To Fix this Press: "Ctrl, Shift, O" [Windows] or "Command, Shift, O" [Mac]. It should add this line to your file just below the line with the package:
*If it does not import, you will have to type it yourself*

Line Below the Package
package Your_Name;

import cpw.mods.fml.common.Mod;


Step 3 [Adding Variables]


1) Now you should make the variable, by adding this one line between the brackets just after Your_Name.
2) It should look like this [The Line between the Brackets]:
*To get this in your mod you have to keep everything the same except for the thing between the quotation marks. In here you add your name and your mod name*

The Variable between the Brackets

public class Your_Name


{


public static final String modid = "YourName_ModName";


}


Step 4 [@Mod and @Network Lines]


1) The Second Line that you need to add goes right between the @Mod line and the Public Class Line. It should look like this:


@Mod and @Network Lines

@Mod(modid = Your_Name.modid, name = "Mod Name", version = "1.0")


@NetworkMod(clientSideRequired = true, serverSideRequired = false)


Step 4a [Explanation for Step 4]


1) This line will make sure that people using this mod can connect to servers that don't have it and that they can't connect to servers that have it when they don't.
2) You need to have it this way or it will crash your mod when you try to connect to a server.
3) Once again you will get an error under @NetworkMod.

4) Again you have to Press "Ctrl, Shift, O" [Windows] or "Command, Shift, O" [Mac]. And if that still doesn't work you have to add this line inside of your file. And it should look like this:


Line Below Package 2
package Your_Name;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.network.NetworkMod;


Step 5 [The Result, but not Final]



The Result
package Your_Name;

import cpw.mods.fml.common.Mod;


import cpw.mods.fml.common.network.NetworkMod;



@Mod(modid = Your_Name.modid, name = "Mod Name", version = "1.0")


@NetworkMod(clientSideRequired = true, serverSideRequired = false)


public class Your_Name


{


public static final String modid = "YourName_ModName";


}


Step 6 [Almost There]


1) The next thing you have to add is this Line to one Line below the public static final
2) It should look like this:

Public Void

public class Your_Name
{


public static final String modid = "YourName_ModName";



@Init


public void load(FMLInitializationEvent event)


{



}


}


Step 6a [Explanation for Step 6]


1) This has to be added inside of the brackets below the Public Class Your_Name Line.
2) The public void load() is the first method in your mod. A method is a piece of the code that can be called from outside. The @Init above makes sure that forge will call it during the Init phase of start-up.3) Inside of this method will be most of the code for your mod. It is a very important method and it will become very big.
4) You might get errors under @Init and inside of the load brackets. Fix it by Pressing: "Ctrl, Shift, O" [Windows] or "Command, Shift, O" [Mac].

The Final Result



The Final Result
package Your_Name;

import cpw.mods.fml.common.Mod;


import cpw.mods.fml.common.Mod.Init;


import cpw.mods.fml.common.event.FMLInitializationEvent;


import cpw.mods.fml.common.network.NetworkMod;



@Mod(modid = Your_Name.modid, name = "Mod Name", version = "1.0")


@NetworkMod(clientSideRequired = true, serverSideRequired = false)


public class Your_Name
{


public static final String modid = "YourName_ModName";



@Init


public void load(FMLInitializationEvent event)


{



}


}


Conclusion



Next Tutorial I will show you how to add a Basic Block. Check for Episode 3 for more.
More Tutorials are Coming Soon!!!

VvIfWlpng

More like this

  Have something to say?

Wafflegum
12/29/2013 12:01 am
Level 29 : Expert Waffle
I can't find my src and what is the Minecraft directory in eclipse?
1
mysteryman3546
12/29/2013 7:29 pm
Level 75 : Legendary Creeper Hugger
Did you follow episode 1?
The src file and minecraft directory are from episode 1 and tehy are supposed to be on the sidebar.
1
GigabyteGiant
07/21/2013 6:50 pm
Level 42 : Master Droid
Great tutorial, will be using these as I learn how to use Forge for modding. I am only familiar with writing mods with ModLoader, but Forge seems to be more in-depth, so that is what I decided to learn how to use...
1
mysteryman3546
07/21/2013 8:52 pm
Level 75 : Legendary Creeper Hugger
Glad to help. :D
1
HammerCraft
06/04/2013 7:44 am
Level 48 : Master Pyro
Thanks for doing these tutorials! They may help in the future.

- The HammerCraft Team
1
mysteryman3546
06/04/2013 8:42 am
Level 75 : Legendary Creeper Hugger
Anytime. I know people search on how to make mod tutorials and I try to make mine as detailed a possible. :D Glad it helped
1

Welcome