2. Your first mod

Ok, now we have setup our Forge workspace and it's time to open your project, make small settings to our intellij workspace and create template for our mod. So, let's start by opening up our project!

What we will learn in this chapter

Before we dive in the chapter, I like giving away information what you'll learn in it beforehand. In this chapter you will learn basic things with IntelliJ IDE like opening your project, creating class files, creating packages, launching your game, editing your mod's mcmod.info file, printing text to console, creating Proxy for your mod, creating event handlers for your mod and how to fix imports in your project. A lot, but this is all required before we actually dive in for creating your mod! :)

Opening Project

  1. First start by opening your installed IntelliJ software. If you have not yet installed that, do that now. Install the IntelliJ Community edition.
  2. So, open up IntelliJ. Select "Open Project". Navigate to your forge folder and open forge1710.ipr.
  3. As IntelliJ opens up, you should see your project files on the left. Go ahead and take a look what's in there. Open some files and explore. Also one thing; everything in your src folder can also be found under your forge installation folder.

Hello Minecraft!

Now it is time. Time to start your mod and fire up the game. Let's first start by launching our game to see that it works.

Launch Game

To launch the game, click Debug Minecraft Client icon on top of your intellij. Your game should now start and debug window should open up in intellij. Once you see Minecraft Main Menu show up, press the Mods button. This screen lists all mods you have installed. As you might have noticed, there is also a mod called Example Mod. That is actually the mod that gets shipped with Forge and where we can start making edits into.

Editing your mod information

Okay, we'll first edit the details that gets shown in that Mods screen. So stop your game if you had it running and in your intellij navigate to: src.main.resources. Open the file mcmod.info. You might wonder what that src.main.and.so.on means and the answer is simple: the file mcmod.info is actually under yourforgeinstallation/src/main/resources folder. In Java we call folders packages and we separate folders and files with . instead of /.

Okay, so your mcmod.info file should look like this by default:

  "modid": "examplemod",
  "name": "Example Mod",
  "description": "Example placeholder mod.",
  "version": "${version}",
  "mcversion": "${mcversion}",
  "url": "",
  "updateUrl": "",
  "authorList": ["ExampleDude"],
  "credits": "The Forge and FML guys, for making this example",
  "logoFile": "",
  "screenshots": [],
  "dependencies": []

That file is in json format. Let's do some changes to it. Change id examplemod to followermod and name Example Mod to Follower Mod. Feel free to other changes to the file too, should you wish. You can for ex. change credits, authors and description for the mod. Save the file. Now we should also navigate to your mod's source folder to change the modid from there too. To do that, navigate to src.main.java.com.example.examplemod and open the file ExampleMod. Inside that file change this line:

public static final String MODID = "examplemod";

to have the same modid that you just wrote in your mcmod.info file:

public static final String MODID = "followermod";

Now start your Client (Press the Start Minecraft Client button that looks like a bug in the intellij topbar) and verify in the Mods screen that your mod still got loaded and you are seeing your mod name there. Good. Now it's time to start creating basic structure for your mod.

Hello Minecraft! and how I was made

So open up your ExampleMod file if you already did not have that open. We don't really want to keep that named as ExampleMod, so let's rename it to FollowerMod. To do that, right click the ExampleMod on the left panel and select Refactor => Rename and rename the file to FollowerMod. We also do not want to keep the file in package com.example.examplemod (remember, we call folders packages in Java) so we'll move the file FollowerMod to package com.followermod.

To move the file, right click on the file FollowerMod again and select Refactor => Move. Replace the com.example.examplemod with com.followermod and press Refactor. Press yes if it asks you if you are sure. After that it's time to make your first edit into the file to see text Hello Minecraft in your console when the Client starts. To do that, replace the line:

System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());


System.out.println("HELLO MINECRAFT");

Note that when you are typing something, intellij automatically suggests you code. That is very useful in lots of cases. Well, more of that later. Now we should start our client, watch carefully for our console aaaaand... Saw it? Nice! (it could be hard to find that line as forge prints so much stuff in your console, but it is there) :) So time to move on to create some basic structure for your mod to support forge events and to actually start creating our mod.

Building your House aka. Mod Structure

Now that we got past the usual fanfare of having your first Minecraft mod to print "HELLO" something in console, it is time to add Forge Events into your mod so we can actually modify the game behavior.... Forge Events are the thing that makes modding so easy with Forge and the preferred way to mod your game. You can add events in your game that gets called whenever your game gets drawn, user receives a chat message, user joins the server, user uses item and so on and so forth. And you can then add your own code inside these events like when someone presses on your block, fire effect gets triggered.

As Minecraft consists of Minecraft Client and Dedicated Server (and when you open your local game for LAN, it also starts a server for that), we will first need to add Forge Proxy to your mod which can be used to apply certain changes in your client, certain changes in your server and certain changes for both your client and server. To do that, first add this in your FollowerMod file after the String VERSION:

@SidedProxy(clientSide = "com.followermod.proxy.ProxyClient", serverSide = "com.followermod.proxy.ProxyServer")
public static IProxy proxy;

clientSide argument sets where the client code will be executed and serverside sets the server part. You might notice that your proxy got red underlining. That means that there is a error there. And that error shows up because we have not yet created our IProxy file.

Let's create that IProxy file:

  • Right click at com.followermod in the left panel and select New => Package. Package name should be proxy. Press OK.
  • Now right click the newly created proxy package and select New => Java Class. Name should be IProxy.

Open the IProxy file and replace the code in that class with this:

package com.followermod.proxy;

public interface IProxy
     * Register all Forge Events here.
    public void registerEvents();

Now we'll need to create another class called ProxyCommon that implements that mentioned IProxy and has code inside that gets executed both in client and server.

Create class CommonProxy inside proxy package. Inside that file add this:

package com.followermod.proxy;

public class ProxyCommon implements IProxy
    public void registerEvents()

Great, now we'll need to also create one file for client and one for server. So first start by creating file ProxyClient inside your proxy package. Add this content in that file:

package com.followermod.proxy;

public class ProxyClient extends ProxyCommon
    public void registerEvents()

And then create file ProxyServer inside your proxy package with this content inside:

package com.followermod.proxy;

public class ProxyServer extends ProxyCommon
    public void registerEvents()

Great! You made it! :) Now if you look at the left panel of your IDE, you will see that the file FollowerMod has red text color, which means that it has errors. Let's look what's the problem there!

Fixing Imports

Open up your Follower Mod file and you will notice that the variable IProxy has red color. That means that that variable has a error. Now hover over your mouse cursor in that variable and check what it states. It states: "Cannot resolve symbol IProxy". Well, you already had created that IProxy file. What the heck? The answer is simple. Classes that are not in the same folder as the current class will need to be imported before they can be used. As you have a powerful IDE in your hands, this IDE can actually automatically import the file for you. To do that, just hold left ctrl, press enter and select "Import Class". It then imports the IProxy class by adding a import clause on top of your file. Cool! Note that you can do this for every import from here on and for every error in your code you can press Ctrl + Enter for IDE to suggest you fixes.

Creating Forge Event Handlers

Now that we have our proxy file set that can be used to separately add things for client and server we can now create our event handler classes and easily hook those up into our system. This is fairly simple as now we know how to create classes:

  • Create new package eventhandlers in your followermod package. You should then get this kind of structure: followermod.eventhandlers.
  • Create classes EventHandlerClient and EventHandlerServer in your eventhandlers package.

Now we just need to tell Forge to use those two event handlers. First to do that in client, open your ProxyClient file and add these two lines in your registerEvents method:

FMLCommonHandler.instance().bus().register(new EventHandlerClient());
MinecraftForge.EVENT_BUS.register(new EventHandlerServer());

After pasting the code, IDE will ask do you want to import classes. press OK and all required files are being automatically imported.

For server that is pretty much the same behavior. Open ProxyServer file and add these to your registerEvents method:

FMLCommonHandler.instance().bus().register(new EventHandlerServer());
MinecraftForge.EVENT_BUS.register(new EventHandlerServer());

And just one more step before we are ready to start modding. Open your FollowerMod file and inside the file you should see this:

// some example code
System.out.println("HELLO MINECRAFT");

That was some example code we added there to test that things work. Now replace that code with this:


Ok! Now when Minecraft starts and Forge calls that init() method, it then automatically calls your Proxy registerEvent method always in ProxyCommon and when you are launching Client, it calls your ProxyClient.registerEvents() method and on server your ProxyServer.registerEvents() method.

What's next?

I know that that was a lot of things and I know it can be pretty confusing. Good thing is that you do not need to "get" everything in this chapter yet. We will be using those same classes in the upcoming tutorials. In the next chapter we'll actually start modding and create new item in Minecraft which can be used later on to spawn NPCs in the world.

Download sources for this chapter

Tutorial 2 sources

Archive contains folder src and all the sources inside. Just place that folder in your forge folder.

Next Chapter

Click here to teleport into next chapter.