Creating our first mod classes

For this tutorial we will be creating the main class for the mod. First delete the package that is already in the ‘src/main/java’ , then create a new package in the ‘src/main/java’, the convention for the name of package is as follows yoururl.modname . For example mine would be ‘’, however I prefer to do ‘’ as I feel this is more intuitive. There is nothing wrong with doing this as it is only convention and all people have their own way of doing it, you can leave the URL part out entirely and just have the mod name.

We now want to create a Class within our main package, give this Class the same name as your mod (Classes start with uppercase), click finish and then wait for it to be created. In the class we want to create to functions.

public void preInit(FMLPreInitializationEvent event){


public void Init(FMLInitializationEvent event){


public void PostInit(FMLPostInitializationEvent event){


These functions are the main functions that forge will look at when loading your mod, it will load them in order PreInit -> Init -> PostInit. When Forge does this is loads all mods PreInits first then all of the Inits and then all of the PostInits, this means that if your mod has functionality with another mod it is best waiting until Init/PostInit to add dependent recipes.

Just above the Class we want to define our mod, by putting this code.

@Mod(modid=ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION)

We will give values to these further down in a new class, you could replace them with strings but it is better practise to use constants in a reference class. So now create a new package youname.modname.reference . Then inside this package create a new Class called ModInfo, inside this class we will write:

public static final String MOD_ID = "TutorialMod";
public static final String MOD_NAME = "Tutorial Mod";
public static final String MOD_VERSION = "0.0.1";

You can replace the strings with appropriate ones of your own mine are their to show you what they mean. The first is the mod ID this could be lower case or camel case, the second is the name of the mod so just write that as you want it to be seen. For the mod version you can use a different version method if you want, the one above is just the method I prefer.

Finally we have to setup Proxy classes, these will help synchronise the Client and the Server later on when we get into rendering and advanced stuff. So create a new package yourname.modname.proxy, in this package create three new classes CommonProxy,ClientProxy,ServerProxy. In ClientProxy and ServerProxy we need to make them extend CommonProxy, so add an ‘extends CommonProxy’ to the opening of the class.

public class ClientProxy extends CommonProxy{


public class ServerProxy extends CommonProxy {


That is the base of our mod now setup and ready to start creating items/blocks and who knows what, join me next time when we delve into item creation.


Leave a Reply