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/23 18:19] – [Major Edit] Add a first version of a proper introduction to Mixins as a subsystem rather than relying purely on other internal and external pages to give an introduction to the concept. This introduction it WIP, and the title has been marked as such. Due gauntrecluse | tutorial:mixin_introduction [2025/10/06 03:03] (current) – misc. rephrasings, replaced itemized list with table, add mention of MCDev gauntrecluse | ||
---|---|---|---|
Line 4: | Line 4: | ||
====== 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**, | + | whether it be through injecting custom logic, removing mechanics, or modifying values. Note that **only Mixins written in Java are directly supported**, |
- | Mixin is a complex subsystem which merges a mod' | + | Mixin is a complex subsystem which merges a mod' |
((Mixin classes are not classes in the same way as " | ((Mixin classes are not classes in the same way as " | ||
- | into the targeted classes' | + | into the targeted classes' |
- | It is not recommended to try and learn how Mixin works or how to use it without having some notion of what Bytecode is, as that may lead to unexpected behavior and misunderstandings. It is also recommended to know how to read Java Bytecode for your IDE of choice, as reading portions of the Bytecode may sometimes be necessary to use Mixin properly, notably when targeting anonymous classes, lambdas or code with a lot of '' | + | |
- | Similarly, Mixin and this documentation expects the user to already be familiar with [[tutorial: | + | |
- | Mixin does its work very early in the overall Fabric launching process, and must be, in rough terms, fully applied before | + | It is not recommended to try and learn how Mixin works or how to use it without having some notion of what Java bytecode is, as that may lead to unexpected behavior |
+ | Similarly, Mixin and this documentation expects | ||
+ | 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 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 |
- | ((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 your class and then transform and merge them into the target class. Here is a basic overview of Mixin's important annotations: | + | |
- | FIXME //There ought to be dedicated pages going more in depth about the different tools annotations later on. This segment | + | |
- | * The '' | + | There are different tools Mixin and MixinExtras |
- | * Injector Mixin annotations decorate a handler method((In the context of Mixins, 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 are 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, using the '' | + | |
- | //For more complete and thorough information on Mixin functionality, | + | Here is a cursory overview of some of Mixin's key features:\\ |
+ | 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 | Methods and a decorating annotation which creates a set of instructions that call back (called a " | ||
+ | | Redirectors/ | ||
+ | | Overwrites | Done via '' | ||
+ | |||
+ | //For more complete and thorough information on Mixin functionality, | ||
+ | |||
+ | The Fabric Wiki offers several articles that provide practical examples and explanations of some areas of Mixin and MixinExtras: | ||
* [[tutorial: | * [[tutorial: | ||
* [[tutorial: | * [[tutorial: |
tutorial/mixin_introduction.1758651563.txt.gz · Last modified: 2025/09/23 18:19 by gauntrecluse