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/27 04:03] – Very minor phrasing addition gauntrecluse | tutorial:mixin_introduction [2025/12/23 00:49] (current) – Rephrase around JVM bytecode to make it sound a bit less imperative to be able to properly understand JVM bytecode for Mixins 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:reading_mc_code|reading Minecraft and external source code]], and be able to set up an initial development environment, | + | |
| - | Mixin can do its work throughout | + | Similarly, |
| + | It is recommended to leverage | ||
| - | There are different kinds of tools Mixin and MixinExtras | + | Mixin can do its work throughout the game's lifecycle, however, a Mixin's transformations must be applied before the targeted class has loaded. For the majority |
| - | ((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, those annotations decorate((AKA annotate, are attached to)) members of the Mixin class and are passed arguments which are used to associate the necessary information so that Mixin knows how to process | + | |
| - | 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 '' | + | There are different tools Mixin and MixinExtras |
| - | * 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.)) | + | ((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:// |
| - | * Redirector Mixin annotations | + | provide for modifying source |
| - | * Overwriting, | + | |
| - | * One of Mixin's most fundamental features, upon which most of its tools are built upon, is merging a Mixin class into the target | + | |
| - | //For more complete and thorough information on Mixin functionality, | + | As to make reading |
| + | 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 | ||
| - | The Fabric Wiki offers several articles that provide practical examples and explanations of some areas of the Mixin and MixinExtras | + | ^ 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 '' | ||
| + | |||
| + | //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: | ||
| + | * [[https:// | ||
| * [[tutorial: | * [[tutorial: | ||
| - | * [[tutorial: | + | * [[tutorial: |
| * [[tutorial: | * [[tutorial: | ||
| + | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
| Line 37: | Line 44: | ||
| * [[tutorial: | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
| - | * [[tutorial: | + | * [[tutorial: |
| - | * [[tutorial:accesswideners | + | * [[tutorial:accesswidening|Access |
| * [[tutorial: | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
| * [[tutorial: | * [[tutorial: | ||
tutorial/mixin_introduction.1758945804.txt.gz · Last modified: 2025/09/27 04:03 by gauntrecluse