Setting Up a Forge Mod Development Environment
Minecraft mods written in Java are built against Forge, a modding API and loader that hooks into the base game. Forge ships a Mod Development Kit (MDK), a ready-to-go Gradle project you build your mod on top of instead of starting from nothing.
What you'll need
- A Java Development Kit matching your target Minecraft version (JDK 17 for modern 1.20.x Forge).
- The Forge MDK for the Minecraft version you're targeting, downloaded from Forge's files page and unzipped into your project folder.
- An IDE with Gradle support, IntelliJ IDEA or Eclipse both work well.
Getting the MDK running
From inside the unzipped MDK folder:
./gradlew genIntellijRuns
(genEclipseRuns for Eclipse instead), this generates run configurations for launching Minecraft with your mod loaded. Then launch the game itself:
./gradlew runClient
The first run downloads a full Minecraft client and Forge's patched sources, expect it to take a while. If it succeeds, you'll see the normal Minecraft title screen with your (currently empty) mod already loaded.
mods.toml
Every Forge mod describes itself in src/main/resources/META-INF/mods.toml:
modLoader="javafml"
loaderVersion="[47,)"
[[mods]]
modId="examplemod"
version="1.0.0"
displayName="Example Mod"
modId is the mod's unique internal identifier, lowercase, no spaces, you'll reference it constantly in code and in every resource file path.