top of page

Beginning Mod File

Okay, now we've setup forge and minecraft forge source code, now its time to get into making our mod. To start, we must create all of our packages in  a source package named "src/main/java/". In here you will see ExampleMod. It is a small mod created by CPW to demonstrate how to make a basic Mod file. We are going to set up almost exactly like this. Im going to remove that package because we no longer need it and make me own. Usually, you start your packages with website.username.mod, ect. So mine will be this: "forgingmc.minecraftthing". If you dont have a website, your username will do fine.  Note: You can call it whatever you want. The first class im going to be a class named "Constants". This will hold all of our Constants we want in our mod like our mod id and mod name which I will get into a bit.  We do not need the Constants File but it is very handy later on and makes our code very neat and tidy. First lets make a class, right click on our package then go to new class and call it Constants.

 

Okay lets get into some code! All of this code is very self explanatory. 

As you can see, we've made 3 String contants, MOD_ID, VERSION and MOD_NAME. Typically in Java, Constants are in all upper case with underscores to mark spaces. We give the constants the 'final' modifer so it cannot be changed. The 'static' so it can be used in other classes as well as 'public'. Cool, now we have that setup, we can make our Mod File. Make a new class and Im going to call it "ForgingMC". 

As you can see, we used the Constants we set up in our mod file to determine our, mod_id, version and name. The Annontation ( @Mod() ) is used to tell Minecraft Forge that this is a mod and everything we add will be registered through here. The mod id is the id given to our mod, each mod has a different mod id so forge can determine mods from each other. Also, the mod id is needed for textures and other resources. The version is obvious; the version of the mod. The name is obvious too, just the name of the mod. The other methods are Mod Event Handlers. The first one is called before the mod is initialized, the second one is when it is initialized and the last one is after our mod is initialized. We mostly use the 'init' method. And thats it! Just run it and click mods and you'll see our mod there. Nice! Thankyou for reading this tutorial, see you soon when we make our first basic block!  

bottom of page