User Tools

Site Tools


tutorial:mappings

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:mappings [2019/06/08 13:49] – [Using mappings] There is more than modCompile now jamieswhiteshirttutorial:mappings [2022/05/22 08:38] (current) – Clarify correct build task daomephsta
Line 20: Line 20:
 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. [[tutorial:migratemappings|This process can be partially automated]]. You will also have to run ''genSources'' to access Minecraft sources with the updated mappings. 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. [[tutorial:migratemappings|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. 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.+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.
  
   * **The '-dev' jar (the ''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''.   * **The '-dev' jar (the ''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 names are only applied in a development environment**. Outside a development environment, only intermediary names exist, meaning the code will not match exactly what you see and wrote. Loom transparently handles this transition for you, but be cautious when using reflection.   * **Yarn names are only applied in a development environment**. Outside a development environment, only intermediary names exist, meaning the code will not match exactly what you see and wrote. Loom transparently handles this transition for you, but be cautious when using reflection.
 +
 +=== Mojang's mappings ===
 +
 +As of Loom 0.5, you can also use Mojang's official mappings rather than Yarn, like this:
 +
 +<code>
 +dependencies {
 +    [...]
 +    mappings loom.officialMojangMappings()
 +}
 +</code>
 +
 +Mojang's mappings come with a usable yet more restrictive license than Yarn. Use them at your own risk.
 +
 +
 +=== Custom mappings ===
 +
 +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:
 +
 +<code>
 +dependencies {
 +    mappings fileTree(dir: "mapping", include: "**.jar")
 +}
 +</code>
 +
 +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!
  
 ==== Remapping ==== ==== Remapping ====
  
-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.+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 [[tutorial:reflection|reflection]].
  
 [[https://github.com/FabricMC/tiny-remapper|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. [[https://github.com/FabricMC/tiny-remapper|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.
tutorial/mappings.1560001756.txt.gz · Last modified: 2019/06/08 13:49 by jamieswhiteshirt