Creating a Minecraft 1.7.10 mod from scratch
- Published
The year is 2026. The current version of Minecraft (Java Edition) is 1.21.11 and you want to write a mod for 1.7.10, which came out 12 years ago. Where do you even begin?
Searching around nets you few results as most forums are dead and abandoned, some having moved to closed platforms such as Discord. Why not try forking an existing mod and see how that goes? Nearly all of them have dependencies that return 404. Is nobody developing for 1.7.10 anymore?
What if I told you the modding scene for 1.7.10 is still thriving? That new mods are still actively being developed? And that it requires no prior Java knowledge nor a dedicated Java IDE?
Disclaimer
Now, I must confess that documentation and active projects do exist. I'm not a Java developer and found both the IDE (Eclipse or JetBrains, pick your poison, I dislike both) and tooling (Gradle is a total black box, Kotlin makes things complicated, not to mention all the different version of Java you can choose from) a rather frustrating experience.
If you are a Java developer, I would recommend looking at the GTNH example mod. It seems this is the go-to standard for modern legacy mods.
If you are not a Java developer, like myself, and convinced yourself that things don't need to be this complicated, please do keep on reading. I've managed to create and publish a mod myself using the methods described below.
Setting up Java 8
Minecraft is written in Java (Bedrock doesn't exist), but like many languages, Java has many versions. In theory, any version of Java can be used to create Minecraft mods, but given the dependency on Forge and ForgeGradle, I've found Java 8 the easiest to work with. Make sure to install JDK 1.8, if it's not installed already.
Note: If you're on Windows, make sure to add the JDK bin directory to your system variables. You can verify the JDK being installed correctly by running:
java -version
and it returning openjdk version "1.8.0_492".
Setting up (Forge) Gradle
Minecraft mods for 1.7.10 rely on Forge, and using Forge is significantly easier if you use ForgeGradle, which relies on Gradle. The original ForgeGradle is long dead and forks all rely on different versions of Gradle.
I use juanmuscaria's ForgeGradle fork, together with Gradle 4.4.1. I found it easiest to copy gradlew, gradlew.bat and the gradle folder from other projects. Make sure all prerequisites are met.
Afterwards, create a build.gradle file. I believe this is the absolute minimum required (mostly copy-pasted from other projects):
build.gradle
buildscript {
repositories {
mavenCentral()
maven {
name = "github"
url = "https://github.com/juanmuscaria/maven/raw/master"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:[1.2-1.4.6-SNAPSHOT,)'
}
}
plugins {
id 'java-library'
id 'maven-publish'
}
apply plugin: 'java'
apply plugin: 'forge'
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = project.version
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "eclipse"
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
filesMatching('mcmod.info') {
expand 'version':project.version, 'mcversion':project.minecraft.version
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
task devJar(type: Jar) {
classifier = "dev"
from sourceSets.main.output
}
task sourcesJar(type: Jar) {
classifier = "sources"
from sourceSets.main.allSource
}
artifacts {
archives devJar
archives sourcesJar
}
Afterwards, run:
./gradlew setupDecompWorkspace
and
./gradlew build
This'll create a build folder if done correctly. Make sure to check build/tmp/recompSrc. If that folder doesn't exist, the project is not building correctly.
Note: Make sure to set up your Java environment correctly, otherwise you might be hit with a JAVA_HOME is not set and no 'java' command could be found in your PATH.
Note: If you're getting Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain, make sure your gradle-wrapper.jar isn't corrupt. If you're downloading a git project with LFS it might not download correctly.
Setting up the mod
Code is stored in src/main/java/<tld>/<author>/<name> and resources are stored in src/main/resources.
A bare minimum example mod:
src/main/java/com/demo/example/Example.java
package com.demo.example;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
public class Example
{
public static final String MODID = "example";
public static final String VERSION = "0.0.1";
public void preInit(FMLPreInitializationEvent event) {}
public void init(FMLInitializationEvent event) {}
public void postInit(FMLPostInitializationEvent event) {}
}
src/main/resources/mdmod.info
[{
"modid": "example",
"name": "Example Mod",
"description": "",
"version": "0.0.1",
"mcversion": "${mcversion}",
"url": "",
"updateUrl": "",
"authorList": ["Chronocide"],
"credits": "",
"logoFile": "",
"screenshots": [],
"dependencies": []
}]
Running gradlew build should generate demo.jar, demo-dev.jar and demo-sources.jar inside build/libs.
Conclusion
It's not actually that complicated to setup a minimal Minecraft 1.7.10 modding environment. If you're a Java developer, you're probably better off looking at ExampleMod1.7.10 as it seems to have more bells and whistles and probably gives a better developer experience. I personally use VSCodium for my own mods and don't have any linting or autocompletion, which might be a deal breaker for you.