Setup Minecraft client mod development for Windows

Post date: Jan 08, 2017 8:48:11 PM

These instructions collect all of the steps to build a Minecraft client mod, using IntelliJ IDEA with a plugin to simplify things.

Prerequisites

    • Windows with Internet connection.

    • Minecraft Client with Forge Mod Loader installed

Download Java JDK

Browse to the Oracle site for Java SE.

Click the Download link for JDK.

Select "Accept the License Agreement".

Click the download link for Windows x64, i.e.jdk-8u112-windows-x64.exe

Installing Java JDK

After downloading, run the installer.

Click "Yes" to continue.

Click "Next >", "Next >" to begin the JDK installation.

Click "Next >" to begin the JRE installation.

Click "Close" when the installation completes.

Installing IntelliJ IDEA

An Integrated Development Environment may not be necessary, but the tutorials I'm reading use IntelliJ :)

Browse to the IntelliJ IDEA download page.

Download the Community edition.

Run the installer, and click "Yes" when prompted by UAC.

Click "Next", "Next".

Select "64-bit launcher" to create a desktop shortcut.

Click "Next", "Install".

Click "Finish" when the installation completes.

Run the desktop shortcut for the 64-bit launcher.

Click "OK" to complete the installation without importing settings.

Click "Accept" to accept the privacy agreement.

Click "Skip All and Set Defaults".

The "Welcome to IntelliJ IDEA" dialog box loads.

Installing Minecraft Development for IntelliJ IDEA plugin

Select "Configure", "Plugins".

Click "Browse repositories", and search for "Minecraft".

Click "Install".

Click "Close", "OK", and then click "Restart".

The GitHub page has installation instructions, and the latest version. The JetBrains site has a page for downloading the plugin.

Create new project

Click "Create New Project".

Select "Minecraft Plugin".

Select "Forge Mod", and click "Next".

GroupId, ArtifactId, and Version require some thought. Use letters and period only.

    • GroupId is a unique namespace for your Java code. The convention is to start with an Internet domain you control (in reverse order), and append the project name, i.e. io.github.axus.forgetest

    • ArtifactId corresponds to the expected file name for the plugin, without version information, i.e. forgetest

    • Version is a unique version string for this build. The default 1.0-SNAPSHOT is fine for now.

Click "Next".

The options for Forge Version, MCP Version, and Minecraft Version are populated automatically by the IDEA plugin, which calls the Forge API.

Select the Minecraft version you wish to build the plugin for. The recommended Forge and MCP versions will be updated automatically.

Fill in any optional settings you like, and click "Next".

Set the project name, i.e. forgetest, and click "Finish".

The Minecraft IDEA plugin runs gradlew setupDecompWorkspace, generates the directory structure for forgetest.java. and mcmod.info, and other tasks. This takes several minutes.

The IntelliJ IDEA editor finishes loaded, and "Import Module from Gradle" dialog appears.

Click "OK".

Close the "Tip of the Day" dialog.

The Windows Firewall may prompt you to allow access. Select the box for "Public Networks", and click "Allow Access".

Configure new project

Open the "View" menu, "Tool Window", "Terminal"

In the terminal, run gradlew genIntellijRuns

Click "Yes" to reload the project.

Select "Run" menu, "Edit Configurations...".

Change "User classpath of module" to "forgetest_main". The default of "forgetest" was incorrect.

Click "OK".

Build and test Minecraft Forge mod

If everything went well, Forgetest.java is displayed with no errors. It should look like this:

package io.github.axus.forgetest.forgetest;

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

@Mod(

modid = Forgetest.MOD_ID,

name = Forgetest.MOD_NAME,

version = Forgetest.VERSION

)

public class Forgetest {

public static final String MOD_ID = "forgetest";

public static final String MOD_NAME = "Forgetest";

public static final String VERSION = "1.0-SNAPSHOT";

@EventHandler

public void init(FMLInitializationEvent event) {

}

}

Click the "Run" menu, "Run 'forgetest run client'".

Minecraft will start with a profile for the appropriate Minecraft version and Forge version.

Package the mod

Open the "View" menu, "Tool Window", "Terminal"

In the terminal, run gradlew build .

The JAR file is created under %USERPROFILE%\IdeaProjects\forgetest\build\libs\.

Copy the JAR file to %APPDATA%\.minecraft\mods\VERSION\, where VERSION is the desired Minecraft version.

Start the Minecraft Launcher, and select a profile for the desired Minecraft and Forge version.