@Mod Introductory
The @Mod file also referred to as the core mod file is the center of your mod file. In the end almost all of the code will find its way back here. Below is an example of a basic @Mod file.
package your.package.here;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
//This line of code is what gives your mod its identity. The modID is simply a way for forge to identify your mod.
//I recommend giving your modID the same variable as your modname. The version number is simply to show what
//version of the mod you are running.
@Mod(modid = "ModID", name = "modname", version = "version number")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class CoreModFileName
{
//This is a place for you to add your declarations such as public statics
//This is a place for you to add registries and such.
@cpw.mods.fml.common.Mod.Init
public void Init(FMLInitializationEvent event){
//This is were you can put in things like language registries and class references.
}
//This method is helpful and allows us to Pre initialize code
@cpw.mods.fml.common.Mod.PreInit
public void PreInit(FMLPreInitializationEvent event){
//The code that will be pre initialized will go here.
}
//This method is also helpful and will allow us to Post Initialize some code.
@cpw.mods.fml.common.Mod.PostInit
public void PostInit(FMLPostInitializationEvent event){
//The code that will be post Initialized will go here.
}
}
The reason for having an @Mod class is so we can actually load our code into the game. This class file is the equivalent to the mod_ classes from ModLoader.
Annotations are a feature in Java which Forge and FML takes advantage of. These annotations Forge and FML add can help us out in a variety of ways.
package your.package.here;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
//This line of code is what gives your mod its identity. The modID is simply a way for forge to identify your mod.
//I recommend giving your modID the same variable as your modname. The version number is simply to show what
//version of the mod you are running.
@Mod(modid = "ModID", name = "modname", version = "version number")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class CoreModFileName
{
//This is a place for you to add your declarations such as public statics
//This is a place for you to add registries and such.
@cpw.mods.fml.common.Mod.Init
public void Init(FMLInitializationEvent event){
//This is were you can put in things like language registries and class references.
}
//This method is helpful and allows us to Pre initialize code
@cpw.mods.fml.common.Mod.PreInit
public void PreInit(FMLPreInitializationEvent event){
//The code that will be pre initialized will go here.
}
//This method is also helpful and will allow us to Post Initialize some code.
@cpw.mods.fml.common.Mod.PostInit
public void PostInit(FMLPostInitializationEvent event){
//The code that will be post Initialized will go here.
}
}
The reason for having an @Mod class is so we can actually load our code into the game. This class file is the equivalent to the mod_ classes from ModLoader.
Annotations are a feature in Java which Forge and FML takes advantage of. These annotations Forge and FML add can help us out in a variety of ways.