Mappings defined the names of classes, fields and methods on obfuscated Minecraft versions including 1.21.11 and below. Developers using Fabric for these versions primarily use either Fabric's Yarn mappings, which provide meaningful names for the Minecraft codebase as decided by the community, or the official Mojang Mappings, available since 1.14 and providing official names for the entirety of Minecraft. Intermediary mappings were also used by Fabric to provide a stable base for community mappings. The need for mappings came from the fact that Minecraft releases prior to 26.1 were obfuscated, which presents multiple challenges. Remapping is the process of applying mappings to compiled classes or source files.
When using a variant of Loom that supports remapping, the mappings define the names for Minecraft classes, fields and methods used in your development environment. These names may vary from one development environment to another depending on the installed mappings.
Mappings in Loom are specified using the mappings dependency configuration in the buildscript and can be updated by updating the dependency. Minecraft as well as dependencies included with mod-augmented dependency configurations like modCompileOnly and modImplementation are remapped to your chosen mappings. If your mapping layer is incomplete, you may notice classes, fields and methods will use Intermediary names like class_1234, method_1234 and field_1234.
By changing the mappings in your development environment, you can expect that names of classes, methods and fields in Minecraft and any included mods have changed, and that your code might have to be updated to reference the changed names. This process can be partially automated. You will also have to run genSources to access Minecraft sources with the updated mappings.
Loom's remapJar task will produce the primary mod artifact, which is a built jar using intermediary names. However it does not perform testing or validation, build should always be used to produce JARs for end user use. Additionally, if a sourcesJar task is present, remapSourcesJar will produce a sources jar using intermediary names. These jars can be installed as mods or included in a development environment with the modCompile dependency configuration.
jar task output) does not use intermediary names, and is therefore not useful. It cannot be installed as a mod outside a development environment and will only work in a development environment with matching mappings. The regular jar (the remapJar task output) should be used instead and installed in development environments using mod-augmented dependency configurations like modCompile.Yarn was a community developed mapping set that was the default for Fabric users from Fabric's inception until 1.21.10. If you are referencing older tutorials, or prefer the names, you can apply it like this:
dependencies {
[...]
mappings "net.fabricmc:yarn:${project.yarn_mappings}"
}
Since 1.14, Mojang has provided its own official mappings rather than Yarn. Note that unlike Yarn, Mojang Mappings do not include paramater names or Javadocs. If you are referencing newer tutorials, prefer the names, or plan to upgrade your mod to 26.1 or above, you can apply it like this:
dependencies {
[...]
mappings loom.officialMojangMappings()
}
Mojang's mappings come with a usable yet more restrictive license than Yarn. Use them at your own risk.
Users of Mojang Mappings may wish to have paramater names and Javadocs. For that purpose, third party projects like Parchment exist. Parchment parameter names and docs are applied via layered mappings on top of Mojang mappings like this:
dependencies {
[...]
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${project.parchment_mappings}@zip")
}
}
Mojang's mappings come with a usable yet more restrictive license than Yarn. Use them at your own risk.
You can use custom tiny mappings for Fabric Loom for your Gradle project setup.
For example, if you have a custom branch of yarn which you want to use for mappings, you can build yarn with “./gradlew build” command, take out the jar file in “build/libs” directory, and move it to a folder “mapping” in your Gradle project. Then, change your mappings dependency entry to:
dependencies {
mappings fileTree(dir: "mapping", include: "**.jar")
}
You can change the directory where you put mapping to have any custom name; just change the name in “dir” argument above. Note that Gradle build will fail if you have any other file than the mapping jar in the mapping directory!
You can also use layered mappings to override specific mappings, see the following:
mappings loom.layered {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
mappings file("override.tiny")
}
Remapping is the process of applying mappings to code, transforming from one set of names to another. Both Java source code and compiled Java code can be remapped. It involves changing the names of references according to the mappings, as well as carefully renaming methods to preserve overrides. It does not change what the code does, although it will affect names used in reflection.
Tiny Remapper is a tool that can remap compiled Java code. It has a command line interface as well as a programmable interface. Loom uses Tiny Remapper for a number of tasks, and Fabric Loader uses Tiny Remapper to remap the Minecraft code to intermediary. Loom is also capable of remapping Java source code.
Releases of Minecraft Java Edition prior to 26.1 snapshots are obfuscated jar files, which means they are compiled binaries stripped of any meaningful naming information, leaving only the bare logic behind. The motivation behind obfuscation is to prevent reverse engineering and to reduce file sizes. Java programs like Minecraft are rather simple to decompile, but obfuscation stripped away a lot of information that would be useful for modding purposes. One might wonder how it was possible to develop for these obfuscated versions in the first place.
Mappings like Yarn provided meaningful names for development. Using mappings it is possible to make sense of the Minecraft code and create mods for it. Mapping can provide names for classes, fields, methods, parameters, and local variables. It should be obvious these mappings are not perfect. Mapping the entirety of Minecraft involved a lot of guesswork from multiple contributors. Mappings may be incomplete and sometimes change as more accurate names are found.
A property of Minecraft's obfuscation is that it is not always consistent between Minecraft versions. A class may be called abc in one version of Minecraft, and abd in another. The same inconsistency applies to fields and methods. The inconsistency creates binary incompatibility between Minecraft versions.
Java code may be compiled for one version of a library and still work with another, making the two versions of the library binary compatible. Put simply, binary compatibility is achieved if the library exposes at least the same classes with the same methods and fields with the same names. The inconsistency in Minecraft's obfuscation presents a challenge when using Minecraft as a library for mods because of the lack of binary compatibility.
Intermediary defines stable names for Minecraft's internals across Minecraft versions. The purpose of an Intermediary name is that it will always refer to the same class, field or method. Unlike Yarn names, Intermediary names are not meaningful and instead follow a numeric pattern like class_1234, method_1234 and field_1234.
Being a stable mapping, Intermediary can make Minecraft binary compatible across multiple versions (such as snapshot versions)! Compatibility is guaranteed only for the parts of the game that are unchanged between versions. When installed on an obfuscated version outside a development environment, Fabric Loader provides an environment with intermediary names by remapping Minecraft (and the Realms client) before the game is started. This can be observed by looking at a crash report from a production environment with Fabric Loader installed, which will contain intermediary names. Mods, compiled with intermediary names as applied by Loom, are naturally compatible with this environment.