ForgeGradle Configurations
ForgeGradle has numerous configurations that can change how the development environment is configured. Most configurations are set using the minecraft
block; however, some others can be specified within the dependencies
block or modify the built jar
, such as reobfJar
.
Enabling Access Transformers
Access Transformers can widen the visibility or modify the final
flag of Minecraft classes, methods, and fields. To enable access transformers in the production environment, you can set accessTransformer
to configuration file in question:
minecraft {
// ...
// Add an access transformer file relative to the project's directory
accessTransformer = project.file('src/main/resources/META-INF/accesstransformer.cfg')
}
While the access transformer in the development environment can be read from anywhere the user specifies, in production, the file will only be read from META-INF/accesstransformer.cfg
.
Human-Readable Mappings
Minecraft's source code is obfuscated. As such, all classes, methods, and fields have machine-generated names with no package structures. Function-local variable names, meanwhile, are turned into a snowman (☃
) due to how the Local Variable Table is stored. It is difficult to create mods using obfuscated names as reverse engineering them is tedious, may change between versions, and may be invalid in the language itself but not in the bytecode.
To address the last two issues, Forge fuzzily maps each class, method, field, and parameter to a unique identifier, known as the SRG name, via the ForgeAutoRenamingTool. SRG mappings are used in production when the game is being run by the user client.
To allow easier development, ForgeGradle allows the user to choose a mapping set to apply on top of SRG mappings, which we will refer to as human-readable mappings. ForgeGradle knows how to convert the mod jar to SRG mappings for use in production via the reobf*
task.
The mapping set used can be specified by setting the mappings
field in the minecraft
block. The mappings
field takes in two arguments: channel
which is the type of the mapping set, and version
which is the version of the mapping set to apply.
Currently, there are three default mapping sets built into ForgeGradle:
official
- This uses the mapping set provided by Mojang. These mappings do not have parameter names and only exist from 1.14 onward.stable
- This uses a mapping set generated by MCP. These are typically incomplete and no longer exist as of 1.17.snapshot
- This also is a mapping set generated by MCP, similar to a nightly build of a program. These are also typically incomplete and no longer exist as of 1.17.
The class names used in production are from stable
prior to 1.17 and from official
from 1.17 onwards.
mappings {
// Sets the mappings to use those from Mojang for Minecraft 1.19.4.
mappings channel: 'official', version: '1.19.4'
// ...
}
Parchment
Parchment is an official project maintained by ParchmentMC which provides open, community-sourced parameter names and javadocs on top of the official
mapping set. You can learn how setup and use the parchment mapping set on their website.