Getting Started with ForgeGradle
If you have never used ForgeGradle before, here is the minimum amount of information needed to get a development environment setup.
Prerequisites
- An installation of the Java Development Kit (JDK)
Minecraft Versions | Java Development Kit Version |
---|---|
1.12 - 1.16 | JDK 8 |
1.17 | JDK 16 |
1.18 - 1.20.4 | JDK 17 |
1.20.5 - 1.21 | JDK 21 |
- Familiarity with an Integrated Development Environment (IDE)
- It is preferable to use one with some form of Gradle integration
Setting Up ForgeGradle
- First download a copy of the Modder Development Kit (MDK) from MinecraftForge and extract the zip to an empty directory.
- Open the directory you extracted the MDK to within your IDE of choice. If your IDE integrates with Gradle, import it as a Gradle project.
- Customize your Gradle buildscript for your mod:
- Set
archivesBaseName
to the desired mod id. Additionally, replace all occurrences ofexamplemod
with the mod id as well. - Change the
group
to your desired package name. Make sure to follow existing naming conventions. - Change the
version
number to reflect the current version of your mod. It is highly recommended to use Forge's extension on semantic versioning.
- Set
caution
Make sure that any changes to the mod id are reflected in the mods.toml and main mod class. See Structuring Your Mod on the NeoForge docs for more information.
- Reload or refresh your Gradle project using your IDE. If your IDE does not have Gradle integration, run the following from a shell in your project's directory:
./gradlew build --refresh-dependencies
- If your IDE is either Eclipse, IntelliJ IDEA, or Visual Studio Code, you can generate run configurations using one of the following commands, respectively:
Eclipse
./gradlew genEclipseRuns
IntelliJ IDEA
./gradlew genIntellijRuns
Visual Studio Code
./gradlew genVSCodeRuns
You can the run the client, server, etc. using one of the generated run configurations.
tip
If your IDE is not listed, you can still run the configurations using ./gradlew run*
(e.g., runClient
, runServer
, runData
). You can use these commands with the supported IDEs as well.
Congratulations, now you have a development environment set up!