Minecraft 1.8 Forge Modding Quick Start

This guide will get you started with Forge modding on Minecraft 1.8.

Setup

Go to the 1.8.9 Minecraft Forge download page and select the "Mdk" (Mod Development Kit) option. Extract the contents of the downloaded archive into a folder. This folder will serve as the workspace for our mod so feel free to rename it.

Open IntelliJ IDEA and select "Open". Then, select the folder containing our extracted contents. This folder should contain a build.gradle file. Click "OK". Wait for the initial build to complete.

Warning: You will see this message in the build dialog:

This mapping 'stable_20' was designed for MC 1.8.8! Use at your own peril.

This refers to the deobfuscation mappings that translate the symbols of Minecraft's decompiled bytecode into sensible names. If you will be extensively modifying Minecraft's source code directly, you may wish to download the Mod Development Kit for 1.8.8 instead.

Open ExampleMod.java (inside src > main > java > com.example.examplemod). A message at the top of the editor will appear asking you to select the module JDK. Click it and select 1.8. If you haven't already, you should install the 1.8 Java Development Kit for your platform before performing this step. Alternatively, you can select it by opening your Project Structure (under the File menu) and choosing it from the Project SDK drop-down.

You will notice that IntelliJ does not detect any of Forge's packages. To fix this, click on Gradle on the right sidebar and expand forgegradle. Then, run setupDecompWorkspace.

Warning: You may see this error message appear:

Out of memory, GC overhead limit exceeded

To fix this, create a new file named gradle.properties next to build.gradle and add this line to it:

org.gradle.jvmargs=-Xmx4096M

This will increase the amount of memory allocated to Gradle. Run setupDecompWorkspace again.

After this, run setupDevWorkspace. Finally, click the refresh icon at the top left of the Gradle panel and then Forge's packages and symbols will be recognised.

Testing

Open the Gradle panel and under forgegradle run runClient. This will open Minecraft with your mod automatically loaded. Any messages printed to standard output or log messages (including errors) will be shown in the Run dialog.

To set a specific username for the client player, add this snippet to your build.gradle file:

runClient {
	args "--username", "<username>"
}

while replacing <username> with your preferred username.

To authenticate with a specific account, use this snippet instead:

runClient {
	args "--username", "<username>", "--password", "<password>"
}

Exporting

Open the Gradle panel and under build, run build. This will generate a jar file inside of the build > libs folder in the form of [mod-id]-[version].jar. You can install your mod by dragging it into the mods folder of your client.

Customisation

To change your mod identifier we will need to edit several files.

First, open ExampleMod.java again and change the string assigned to the static variable MODID. You will also need to rename the last component of your package path (com.example.examplemod). It is recommended you rename the entire package path according to the Java naming guidelines.

Next, open mcmod.info (inside src > main > resources) and change the modid field. You may edit other fields to your discretion.

Finally, open build.gradle and change the group variable to your new package path. You should also change archivesBaseName to your new mod identifier. This will alter the name of the exported jar file.

Further reading