tutorial:mixin_your_first_mixin
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
tutorial:mixin_your_first_mixin [2025/10/10 15:10] – ↷ Page name changed from tutorial:mixin_making_your_first_mixin to tutorial:mixin_your_first_mixin gauntrecluse | tutorial:mixin_your_first_mixin [2025/10/10 16:00] (current) – Misc. changes, elaborate closing thoughts gauntrecluse | ||
---|---|---|---|
Line 6: | Line 6: | ||
===== Preamble ===== | ===== Preamble ===== | ||
- | This is meant to be a complementary | + | This is meant to be complementary to the [[tutorial: |
This tutorial will be made using a 1.21.1 Fabric Project as reference. It is recommended to develop using IntelliJ IDEa Community Edition to be able to leverage the [[https:// | This tutorial will be made using a 1.21.1 Fabric Project as reference. It is recommended to develop using IntelliJ IDEa Community Edition to be able to leverage the [[https:// | ||
Line 96: | Line 96: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | |||
+ | //Sidenote: one does not need to put '' | ||
Now, if you're following along with MCDev you'll likely notice that our handler method, '' | Now, if you're following along with MCDev you'll likely notice that our handler method, '' | ||
Line 137: | Line 139: | ||
</ | </ | ||
- | The constructor is irrelevant | + | The constructor is irrelevant |
---- | ---- | ||
Line 161: | Line 163: | ||
} | } | ||
</ | </ | ||
- | + | Setting a Mixin to be exported makes it so that once the targeted class has been transformed and has loaded (which could be anytime between the client starting and a world loading) Mixin will export a decompiled version of that now transformed | |
- | Setting a Mixin to be exported makes it so that once the targeted class has been transformed and has loaded (which could be anytime between the client starting and a world loading) Mixin will export a decompiled version of that class, which will now contain the different transformations applied by Mixin to the class. It should be exported to the directory '' | + | |
=== Why do my merged Mixins' | === Why do my merged Mixins' | ||
- | One thing you will notice in an exported class is that your Mixin handler methods' | + | One thing you will notice in an exported class is that your Mixin handler methods' |
- | :!: //The '' | + | :!: //The '' |
=== Breakpoints and MCDev === | === Breakpoints and MCDev === | ||
- | Breakpoints don't natively work with Mixin classes as they get merged at runtime. However, MCDev adds breakpoint support in Mixin Classes directly, allowing you to debug with them by directly putting | + | Breakpoints don't natively work with Mixin classes as they get merged at runtime. However, MCDev adds breakpoint support in Mixin Classes directly, allowing you to debug them by directly putting |
=== Loggers === | === Loggers === | ||
- | Logger calls can be very handy when trying to debug complex logical flows or just for general warning and error notifications. And whilst that may be useful for debugging, one should be particularly careful when using them anywhere that' | + | Logger calls can be very handy when trying to debug complex logical flows or just for general warning and error notifications. And whilst that may be useful for debugging, one should be particularly careful when using them anywhere that' |
---- | ---- | ||
Line 184: | Line 184: | ||
Assuming nothing blew up, you've completed your first functioning Mixin, and hopefully you learned a bit about how Mixin is used and broadly works along the way. //What now?// | Assuming nothing blew up, you've completed your first functioning Mixin, and hopefully you learned a bit about how Mixin is used and broadly works along the way. //What now?// | ||
+ | |||
+ | Some principles to keep in mind are that Mixin is a very case-by-case tool, so this injector example was tailored to its specific use-case, but Mixin and MixinExtras provide a multitude of tools to use for different scenarios. Knowing which one to use comes down to knowing what effect you want to have in the code, and what is the most compatible and smallest change you can make to the target for your goal. You must also remember that Mixin is not always the solution, there are times where events or other modding framework tools outside of Mixins are already available, and you should prioritize using those rather than Mixins if you can afford to, as it is typically safer for compatibility. | ||
==== Further Reading ==== | ==== Further Reading ==== | ||
- | For more thorough and formal intros to the topic, you should read through the [[tutorial: | + | For more thorough and formal intros to the topic, you should read through the [[tutorial: |
- | Namely, those are the [[https:// | + | Namely, those are the [[https:// |
- | Other than that, the most important step from here is trial, error, and asking for help/ | + | Other than that, the most important step from here is trial, error, and asking for help/ |
tutorial/mixin_your_first_mixin.txt · Last modified: 2025/10/10 16:00 by gauntrecluse