- Mixin is a Java library that patches Minecraft's compiled classes at load time.
- Mods describe where to inject code, not what the file looks like, so patches survive game updates.
- Fabric is built on Mixin and applies each mod's mixins during class loading.
- You never install Mixin yourself; the loader bundles it.
Mixin is a Java library that lets a mod patch Minecraft's compiled classes while the game loads, without editing the original source. Mods write small classes that say "add this code at this point in this game method," and Mixin weaves them into the bytecode at runtime. Fabric uses it as its core modding mechanism.
Where Opal fits
Opal is a Fabric mod, so it builds on Mixin under the hood. You do not install Mixin yourself; the setup guide covers getting Opal and Fabric running.
How Mixin works
Mixin edits classes after they compile but before the JVM runs them. A mod ships a mixin class that targets a real game class. Annotations on that class mark where the injected code goes: the start of a method, the end, a specific method call, or a returned value. When Minecraft loads the target class, Mixin rewrites its bytecode to splice in the mod's code.
This matters because Minecraft is not designed to be extended. The game has no official plugin points for most behavior. Mixin gives mods a way in by treating the compiled game itself as the extension surface.
Why mods use it instead of editing the game
Two reasons: compatibility and updates.
Editing the game's source directly means shipping a whole modified copy, which nobody else can build on and which breaks the moment the game updates. Mixin patches are small and surgical, so many mods can patch the same game without each shipping a full fork.
The patches also describe where to inject rather than what the file looks like, so a mixin written against one version often still applies after a game update, as long as the target method still exists.
How it fits with Fabric
Fabric is built on Mixin. The loader reads each mod's mixin config, then hands the listed mixin classes to Mixin so they apply during class loading. A typical Fabric mod is mostly its own classes plus a handful of mixins that hook the few game methods it needs to change.
Common injection points
| Annotation | What it does |
|---|---|
@Inject | Runs your code at a chosen point inside a target method |
@Redirect | Replaces a specific method call inside the target |
@ModifyArg | Changes an argument passed to a call inside the target |
@ModifyVariable | Rewrites a local variable mid-method |
@Overwrite | Replaces a whole method (last resort; breaks easily) |
@Inject is the default tool because it is the least invasive and the most likely to survive a game update. @Overwrite is avoided because it clashes with any other mod touching the same method.
FAQ
No. Mixin is a library that mods are built with. You do not install it on its own; a loader like Fabric bundles it and applies the mixins your mods provide.
No. The patches happen in memory as classes load. The files on disk stay untouched, which is why removing a mod cleanly removes its changes.
If both patch the same method in incompatible ways, especially with @Overwrite, one can undo or break the other. Well-written mixins use narrow injection points to avoid stepping on each other.
No. Mixin is a general Java bytecode framework, but Minecraft modding is where it is used most heavily, and Fabric adopting it made it the standard there.