This tutorial will show you how to set your mod's metadata through the pre-init FML event. Now, first of all, what exactly is mod metadata? Well, if you've ever glanced at the various mods you have installed in the mods menu that is accessible through the Minecraft main menu, you'd notice that some mods have some extra information and perhaps even a logo. These mods have a special file, called the mcmod.info file, that contains all this information. Now, when FML loads a mod archive (a.k.a the mod's .zip/.jar file) it will look in the root of the archive for this mcmod.info file. FML will then set the mod's metadata to whatever is inside this mcmod.info file.
Now, from inside Eclipse, we can have an mcmod.info file, but it needs to be at the root of the src folder. This limitation only allows us to have one mod with the extra metadata. This is where hardcoded metadata comes into play. NEI and the rest of ChickenBones' mods have their metadata hard set (in other words: set in the code). This tutorial will show you how to access your mod's metadata, and even a few examples.
First off, in order to proceed with this tutorial, you will have to have the basic mod class already set up, as we will be adding some code to the pre-init method. I will assume you have completed that tutorial, if you haven't, right now would be a good time to go do it...
Okay, so, the way you access your mod's metadata is by use of a method found inside the FMLPreInitializationEvent pre-init method parameter. The method is called getModMetadata(). This method returns the unique mod metadata class for your mod. In this class, all the separate variables for your mod's metadata are accessible.
Now, some variables you can just set, while others you need to play around with them (the author list, dependencies list and dependants list are three prime examples).
Below are some examples.
event.getModMetadata().version = "1.0.0"; // Version setting
event.getModMetadata().name = "Tutorial Mod"; // Name setting
event.getModMetadata().description = "The MinecraftForgeTutorials Tutorial Mod description"; // Description setting
event.getModMetadata().authorList.add("Jcm2606"); // Adding my name to the mod's author list
event,getModMetadata().logoFile = "/path/to/your/logo/file/location/logo_file_name.png" // Setting the logo file location
Now, from inside Eclipse, we can have an mcmod.info file, but it needs to be at the root of the src folder. This limitation only allows us to have one mod with the extra metadata. This is where hardcoded metadata comes into play. NEI and the rest of ChickenBones' mods have their metadata hard set (in other words: set in the code). This tutorial will show you how to access your mod's metadata, and even a few examples.
First off, in order to proceed with this tutorial, you will have to have the basic mod class already set up, as we will be adding some code to the pre-init method. I will assume you have completed that tutorial, if you haven't, right now would be a good time to go do it...
Okay, so, the way you access your mod's metadata is by use of a method found inside the FMLPreInitializationEvent pre-init method parameter. The method is called getModMetadata(). This method returns the unique mod metadata class for your mod. In this class, all the separate variables for your mod's metadata are accessible.
Now, some variables you can just set, while others you need to play around with them (the author list, dependencies list and dependants list are three prime examples).
Below are some examples.
event.getModMetadata().version = "1.0.0"; // Version setting
event.getModMetadata().name = "Tutorial Mod"; // Name setting
event.getModMetadata().description = "The MinecraftForgeTutorials Tutorial Mod description"; // Description setting
event.getModMetadata().authorList.add("Jcm2606"); // Adding my name to the mod's author list
event,getModMetadata().logoFile = "/path/to/your/logo/file/location/logo_file_name.png" // Setting the logo file location