Hello everyone and welcome to part 2 of Minecraft 1.13 modding with forge, today we are going to set up the main mod class and make Minecraft load our mod. So start your IDE and start modding!
First, we need to create the main mod class.
- Create a package in the “src/main/java” source folder. I will call it “com.suppergerrie2.tutorial”. But you should think of your own name, I will be referring to this package as the mod package. This package will contain all of the classes we are going to create.
- Create a class in the mod package and I will call it TutorialMod I will be referring to this class as the Main class. This class will be the entry point of the mod. Everything will start here.
- One last class before we can start coding, I will call it Reference. This class is going to contain all of the of the constant values. For example the modid.
The basic files are now set up so let’s start coding!
In the reference class add 1 public static final String variable: MODID, this will be the id of your mod, it can be whatever you want, but it has to be all lowercase.
In the Main class add an @Mod annotation above the class declaration. This will tell forge that this is a mod file. @Mod requires the modid as an attribute, so let’s add it.
It should now look like this:
We also need to add a couple of files to the “src/main/resources” folder.
Create a file called pack.mcmeta. In this file you specify some of the metadata for the mods resources. It follows the exact same format as for 1.12 but you need to use a pack_format of 4:
Create a new folder with the name META-INF. In this folder create a file named mods.toml. The mods.toml will tell forge which mods exist and some things like the name, modId, version etc. You should look into the toml format to understand how the file works. But the example from forge shows you a lot. We don’t need everything in that example, we only need to specify:
- The modloader
- The loader version
- The mods we are making, which need to contain:
- The modid (Needs to be the same as in the @Mod annotation
- The version
- The display name
- The description
Your mods.toml file should look something like this:
This is enough for forge to load the mod, so press the run button (or run gradlew runClient).
If everything is good the game will start and load the mod. You can click on Mods and see if your mod is in there.
Next time we will add a custom item, I hope to see you next time!
I also made a github repository for this tutorial.
And as always, if you have any question don’t hesitate to ask in the comments! Also if you saw any errors in the tutorial please let me know so I can fix it!
Till next time!