English | 简体中文
Morphism Gradle is a convention plugin based on ModDevGradle, providing a ready-to-use environment for Minecraft mod development.
Choose the appropriate plugin variant based on your target Minecraft version:
- For Minecraft versions below 1.21 (LegacyForge)
plugins {
id("io.github.morphismmc.morphismgradle.legacyforge") version "1.1.0"
}- For Minecraft 1.21 and above (NeoForge)
plugins {
id("io.github.morphismmc.morphismgradle.neoforge") version "1.1.0"
}Define the following properties in gradle.properties:
minecraft_version=1.21.1
forge_version=21.1.77
parchment_version=2024.11.13
mod_id=examplemod
mod_name=Example Mod
mod_version=1.0.0
mod_group_id=com.example- Sets the project
grouptomod_group_id - Sets the project
versiontominecraft_version-mod_version - Sets the base filename of the archive to
modId - Configures
JavaCompiletasks to read source files using UTF-8 encoding - Adds a
localRuntimedependency configuration for declaring optional dependencies used only for runtime testing, which won't be pulled by dependencies of this mod. LegacyForge users should usemodLocalRuntimeto declare obfuscated dependencies.
Automatically applies ModDevGradle and configures it as follows:
- Sets the Forge/NeoForge version to
forge_version - Configures Parchment with game version
minecraft_versionand mapping versionparchment_version - Creates a mod with ID
mod_idfor the main source set and creates client and server run configurations
Automatically scans template files in the src/main/templates directory, replaces ${propertyName} placeholders with project property values, and includes them in the main source set resources.
Creates a data generation run configuration with:
- output: The output directory for data generation (default:
project.file("src/main/generated/resources/")) - existing: The directory to look for existing resources (default:
project.fileTree("src/main/resources/"))
morphism {
mod {
dataGen {
output = file("build/generated/data")
}
}
}Adds launch parameters to all run configurations:
- enabled: Whether to enable hotswap (default:
true) - useAgent: Whether to use HotswapAgent (default:
false)
- logLevel: Game log level (default:
Level.DEBUG) - enabledMarkers: Enabled log markers (default:
REGISTRIES) - disabledMarkers: Disabled log markers (default: empty)
- export: Whether to export post-mixin class files to
run/.mixin.out - decompile: Whether to decompile exported class files
- asyncDecompile: Whether to decompile asynchronously
- dumpTargetOnFailure: Whether to dump target class files on mixin failure
morphism {
mod {
launch {
hotswap {
useAgent = true
}
gameLogging {
logLevel = Level.INFO
}
mixinDebug {
export = true
}
}
}
}- Adds mod development dependencies to the test source set and includes them in the mod with ID
mod_id. You can write game tests here, which won't be included in the JAR. - Creates a
gameTestServerrun configuration that starts a game test server, runs all registered tests, and exits.
morphism {
mod {
enableGameTest()
}
}- IDEA: Automatically applies the IDEA plugin and enables downloading sources and javadoc JARs for dependencies.
- Eclipse: Automatically applies the Eclipse plugin.
Similar to Java plugin's withSourceJar(), when using the lombok plugin, generates a clean source JAR without Lombok annotations by delomboking the source code.
morphism {
withDelombokSourceJar()
}Adds JUnit test framework dependencies and configures the test task to use the JUnit platform. When using NeoForge, automatically adds NeoForge test framework dependencies and enables ModDevGradle's JUnit integration.
morphism {
useJunit()
}Adds Mixin to annotation processors and includes MixinConfigs in the JAR's MANIFEST.MF. Supports specifying the Mixin version via parameter.
morphism {
useMixin("0.8.5")
}Adds Mixin Extras to dependencies and annotation processors, and includes Mixin Extras dependencies in the JAR. Supports specifying the Mixin Extras version via parameter.
morphism {
useMixinExtras("0.2.1")
}