Modding: Your first file

Now we are finally done with the boring things. You can now start making some actual minecraft code that will change the way you play Minecraft.
To start open your common folder. Right click it and select New, Package.
The name should be your mod name.common.
For this tutorial I will be using: Tutorial.common. Now place your mouse on this package and right click. This time you select New, Class. A pretty complicated screen pops up. The only thing that you will have to think about is the name. The file name should have the name of your mod. In my case it will be called: Tutorial. After adding the title simply hit finish.
Eclipse will open the file for you now. It should look like this, but with your file name instead of Tutorial.


package Tutorial.common;

public class Tutorial
{

}


Now you have to add those 2 lines above public class FileName.


@Mod(modid = “YourName_ModName”, name = “ModName”, version = “Version number”)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)


Another thing that you should add inside of these brackets{} is this:

@Init
public void load(FMLInitializationEvent event)
{

}


The full file should now look like this.


package Tutorial.common;

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 = “YourName_ModName”, name = “ModName”, version = “Version number”)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Tutorial
{
@Init
public void load(FMLInitializationEvent event)
{

}
}


I will now explain everything that is now in the file.


package Tutorial.common;


Is the location of the file.


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;


These are all the imports from eclipse. You need these to use the things that come below. Usually Eclipse will import them for you. If it doesn’t use: Ctrl, Shift, O.


@Mod(modid = “YourName_ModName”, name = “ModName”, version = “Version number”)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)


The modid is the in-game code of your mod. You should make sure that this is a unique name.
The name is the name of your mod and will be displayed in-game.
The version is simply the version of your mod and will be displayed in-game.
The clientSideRequired part asks if you need this on the client to use this mod. This should be true.
The serverSideRequired part asks if you need this on the server for the client to be able to connect. This should always be false, else you can’t join a server if the server doesn’t have the mod installed, but you do.


public class Tutorial
{
@Init
public void load(FMLInitializationEvent event)
{

}
}


public class Tutorial is the file name.
@Init is used by forge to decide when it whould read the method below. Almost everything should be in here.
public void load(FMLInitializationEvent event){} Is the method in which you will be placing most of the code that you need for your mods.

In the next tutorial I will teach you how to add almost every possible crafting recipe to the game.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">