drafts:mixin_obfuscation
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| drafts:mixin_obfuscation [2025/12/24 02:41] – [What is Obfuscation?] gauntrecluse | drafts:mixin_obfuscation [2025/12/29 11:14] (current) – gauntrecluse | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Mixins and Obfuscation (DRAFT) ====== | ====== Mixins and Obfuscation (DRAFT) ====== | ||
| - | ===== What is Obfuscation? | + | ===== Introduction |
| Obfuscation refers to a process used by Mojang up until 26.1, in which the names in the game's code were made obfuscated, in other words were scrambled to be meaningless. In order to get around this and be able to mod with meaningful names, the MC modding community has been using mappings, including mainly Yarn mappings, a libre-licensed set of mappings developed by and mainly for Fabric until obfuscation was dropped, and Mojang/" | Obfuscation refers to a process used by Mojang up until 26.1, in which the names in the game's code were made obfuscated, in other words were scrambled to be meaningless. In order to get around this and be able to mod with meaningful names, the MC modding community has been using mappings, including mainly Yarn mappings, a libre-licensed set of mappings developed by and mainly for Fabric until obfuscation was dropped, and Mojang/" | ||
| Line 10: | Line 10: | ||
| - | ==== Which MC versions are not obfuscated? | + | ==== Obfuscated Versions |
| Minecraft is obfuscated up to and including 1.21.11, meaning that the first unobfuscated versions will be 26.1 and its snapshots. An easy way to remember it is that MC versions are obfuscated up until the change to the new versioning scheme. | Minecraft is obfuscated up to and including 1.21.11, meaning that the first unobfuscated versions will be 26.1 and its snapshots. An easy way to remember it is that MC versions are obfuscated up until the change to the new versioning scheme. | ||
| Line 16: | Line 16: | ||
| Unobfuscated versions will no longer require any obfuscation mappings or remapping, meaning that MC code will be targetable in roughly the same ways as any other Java library present at runtime and not loaded before Mixin. | Unobfuscated versions will no longer require any obfuscation mappings or remapping, meaning that MC code will be targetable in roughly the same ways as any other Java library present at runtime and not loaded before Mixin. | ||
| - | ==== Are mods Obfuscated? | + | ==== Modded targets |
| The short answer is no, mods are not obfuscated. //However// an important thing to note is that obfuscated methods will still need remapping even if targeting an override within a non-obfuscated class. This is typically seen with MC method overrides in another mod. | The short answer is no, mods are not obfuscated. //However// an important thing to note is that obfuscated methods will still need remapping even if targeting an override within a non-obfuscated class. This is typically seen with MC method overrides in another mod. | ||
| - | ===== How does obfuscation | + | ===== How obfuscation |
| - | ==== Mixin Refmaps | + | ==== The Mixin Refmap |
| The refmap is used by Mixins to map meaningful names in Mixin classes to runtime mappings. | The refmap is used by Mixins to map meaningful names in Mixin classes to runtime mappings. | ||
| - | In current versions of Loom, the annotation processor | + | In current versions of Loom, the Annotation Processor (AP) is disabled entirely and no refmap is needed as Loom remaps |
| <code groovy> | <code groovy> | ||
| loom { | loom { | ||
| Line 39: | Line 39: | ||
| - | ==== Remapping | + | ==== Toggling Mixin Remapping ==== |
| By default on obfuscated versions, Mixin classes have remapping enabled for every injector, if you are targeting unobfuscated targets, there are two scopes to turn remapping on or off: | By default on obfuscated versions, Mixin classes have remapping enabled for every injector, if you are targeting unobfuscated targets, there are two scopes to turn remapping on or off: | ||
| Line 47: | Line 47: | ||
| Remapping should be set to false when targeting unobfuscated targets, which includes most mods' methods, but excludes overrides of obfuscated code, such as an override of an MC method in a mod's class. | Remapping should be set to false when targeting unobfuscated targets, which includes most mods' methods, but excludes overrides of obfuscated code, such as an override of an MC method in a mod's class. | ||
| - | ==== Local Capture ==== | + | ==== Local Capture |
| The standard method of capturing local variables in a target method is via MixinExtras' | The standard method of capturing local variables in a target method is via MixinExtras' | ||
| - | The reason this is an issue is because of ordinals and especially indices being " | + | The reason this is an issue is because of ordinals and especially indices being " |
| This means that when targeting obfuscated methods, one should avoid directly capturing locals when possible. Certain injectors such as '' | This means that when targeting obfuscated methods, one should avoid directly capturing locals when possible. Certain injectors such as '' | ||
| Unobfuscated targets such as post-1.21.11 MC or mods allow targeting local variables by name, which gives a much more expressive option for targeting locals that is not nearly as brittle. | Unobfuscated targets such as post-1.21.11 MC or mods allow targeting local variables by name, which gives a much more expressive option for targeting locals that is not nearly as brittle. | ||
| + | |||
| + | :!: Note that there is a bug with capturing method parameters by name fixed in the version of Fabric Mixin bundled with Loader version 0.18.4 and above. In older versions, Mixin stores parameter names as '' | ||
drafts/mixin_obfuscation.1766544083.txt.gz · Last modified: 2025/12/24 02:41 by gauntrecluse