tutorial:mixin_introduction
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:mixin_introduction [2025/09/26 22:32] – Move footnote about redirects also alternatively being named redirect injectors to be directly at the term in question. gauntrecluse | tutorial:mixin_introduction [2025/11/21 13:26] (current) – ↷ Links adapted because of a move operation gauntrecluse | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | FIXME //The Mixin related pages of the Fabric Wiki are undergoing a more thorough review, and are subject to change, rewrites or being replaced. Many pages may be outdated, inaccurate, inactive or incomplete. It is strongly recommended to use the Fabric wiki and linked resources to get a rudimentary Mixin understanding, | + | FIXME //The Mixin related pages of the Fabric Wiki are undergoing a more thorough review, and are subject to change, rewrites or being replaced. Many pages may be outdated, inaccurate, inactive or incomplete. It is strongly recommended to use the Fabric wiki and linked resources to get a rudimentary Mixin understanding, |
| - | //This page specifically is under heavy revisions, and may change in large ways almost overnight as a result. Always prioritize learning from the dedicated external Wikis and asking questions in support channels when in doubt// | + | |
| ====== Introduction to Mixins (WIP) ====== | ====== Introduction to Mixins (WIP) ====== | ||
| Mixins are a powerful and important tool used in the Fabric ecosystem and other modding frameworks for Minecraft. Their primary use case is modifying existing code in the base game, | Mixins are a powerful and important tool used in the Fabric ecosystem and other modding frameworks for Minecraft. Their primary use case is modifying existing code in the base game, | ||
| - | whether it be through injecting custom logic, removing mechanics, or modifying values. Note that **only Mixins written in Java are directly supported**, even if you use Kotlin or another language running on the Java Virtual Machine for the rest of your mod. Whilst it may be technically possible to use other JVM languages | + | whether it be through injecting custom logic, removing mechanics, or modifying values. Note that **only Mixins written in Java are directly supported**.((This applies |
| - | Mixin is a complex subsystem which merges | + | Mixin is a complex subsystem which uses a mod's Mixin classes |
| - | ((Mixin classes are not classes in the same way as " | + | ((Mixin classes are not classes in the same way as " |
| - | into the targeted classes' | + | to transform |
| - | It is not recommended to try and learn how Mixin works or how to use it without | + | It is not recommended to try and learn how Mixin works or how to use it without |
| - | Similarly, Mixin and this documentation expects the user to already be familiar with [[tutorial: | + | Similarly, Mixin and this documentation expects the user to already be familiar with [[tutorial: |
| + | It is recommended to leverage the [[https:// | ||
| - | Mixin can do its work throughout the game's lifecycle, however, a mixin must be applied before the targeted class has loaded. For the majority of mixins, this is very early in the overall Fabric launching process, but do mind that the game launching without Mixin crashing or logging warns doesn' | + | Mixin can do its work throughout the game's lifecycle, however, a Mixin' |
| - | There are different | + | There are different tools Mixin and MixinExtras |
| - | ((Since Fabric Loader 0.15, MixinExtras is bundled with Fabric. Since Loader version 0.17.0, MixinExtras major version 0.5.0 is included, and allows access to [[https:// | + | ((Since Fabric Loader 0.15, MixinExtras is bundled with Fabric. Since Loader version 0.17.0, MixinExtras major version 0.5.0 is included, and allows access to [[https:// |
| - | provide for modifying source code. Those tools come in the form of Java annotations, | + | provide for modifying source code. Most of these tools are provided to the users in the form of Java annotations, |
| - | FIXME //There ought to be dedicated pages going more in depth about the different tools annotations later on. This segment as it is edited should be kept to an introductory level to Mixin annotations and features.// | + | |
| - | * The '' | + | As to make reading more precise documentation easier, here is a basic overview |
| - | * Injector Mixin annotations decorate a handler method((In the context of Mixin, handler methods are the methods that are merged into the target class, and invoked at the relevant point the decorating annotation specifies as a target. For most cases, think of them as the methods decorated by injector or redirector annotations.)) and will inject it into the target class and then call it at the injection point. Injectors are distinguished by the fact they do not overwrite the targeted bytecode((As described on the [[https:// | + | FIXME //There ought to be dedicated pages going more in depth about the different |
| - | * Redirector Mixin annotations | + | |
| - | * Overwriting, | + | |
| - | * Mixin' | + | |
| - | //For more complete and thorough information on Mixin functionality, | + | ^ Feature ^ Overview ^ Notes ^ |
| + | | '' | ||
| + | | Merging | Mixin merges a Mixin class' | ||
| + | | Injectors | An injector typically refers to an annotation and an associated " | ||
| + | | Redirectors(rarely called Redirect Injectors) | Similar to injectors as described above, with the important difference that redirectors replace the target instructions with the callback, rather than only injecting new instructions. This makes it impossible for more than on Redirector to apply to the same target, making them impractical unless a hard incompatibility is intended. | Redirectors include mainly '' | ||
| + | | Overwriting | Done explicitly via '' | ||
| - | The Fabric Wiki offers several articles that provide practical examples and explanations of some areas of the Mixin and MixinExtras | + | //For more complete information on Mixin functionality and usage view the [[https:// |
| + | |||
| + | The Fabric Wiki offers several articles that provide practical examples and explanations of some areas of Mixin and MixinExtras: | ||
| + | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
| Line 38: | Line 42: | ||
| * [[tutorial: | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
| - | * [[tutorial:accesswideners | + | * [[tutorial:accesswidening|Access |
| * [[tutorial: | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
tutorial/mixin_introduction.1758925937.txt.gz · Last modified: 2025/09/26 22:32 by gauntrecluse