tutorial:mixin_export
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tutorial:mixin_export [2020/03/15 17:41] – created draylar | tutorial:mixin_export [2025/12/21 23:19] (current) – Expanded to describe dumping targets on failure and navigating an exported Mixin class gauntrecluse | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Exporting Mixin Classes | + | ====== Exporting |
| + | |||
| + | ===== Exporting a Transformed Class ===== | ||
| When debugging mixins, it's useful to be able to see the finalized classes with your changes and injects inserted. Mixin provides a flag that allows for this: | When debugging mixins, it's useful to be able to see the finalized classes with your changes and injects inserted. Mixin provides a flag that allows for this: | ||
| Line 8: | Line 10: | ||
| {{https:// | {{https:// | ||
| - | === Notes ==== | + | ==== Only Exporting Required Classes ==== |
| + | Dumping every mixined class can be useful, but is often unnecessary and does slow down minecraft a bit. Mixin provides a convenient annotation for applying debug features to individual mixins: | ||
| + | |||
| + | @Debug(export = true) // Enables exporting for the targets of this mixin | ||
| + | @Mixin(...) | ||
| + | public class MyMixin { | ||
| + | // Mixin code here | ||
| + | } | ||
| + | |||
| + | |||
| + | ===== Dumping on Failure ===== | ||
| + | In some cases, you may want to be able to inspect a target class upon Mixin failing and likely throwing a crash. Mixin provides an additional flag for this: | ||
| + | |||
| + | '' | ||
| + | |||
| + | Adding this to your VM options similarly to the export flag will dump the class as it was just as Mixin failed the injection. This can be particularly useful if the cause of the error cannot be understood from the errors, target code and Mixin as they are in the development environment. | ||
| + | |||
| + | Dumping will place the dumped classes to the same filepath as it would for a regular export. | ||
| + | |||
| + | |||
| + | ===== Navigating an Exported Class ===== | ||
| + | |||
| + | Once you have an exported Mixin class, you should look for '' | ||
| + | |||
| + | ==== Reading Mangled Names ==== | ||
| + | |||
| + | The mangled names, on Fabric Mixin, follow the structure of ''< | ||
| + | The following table can be used to match the injector type prefix to the corresponding annotation: | ||
| + | |||
| + | ^ Injector Annotation | ||
| + | | Base Mixin || | ||
| + | | @Inject | ||
| + | | @ModifyArg | ||
| + | | @ModifyArgs | ||
| + | | @ModifyConstant | ||
| + | | @ModifyVariable | ||
| + | | @Redirect | ||
| + | | MixinExtras | ||
| + | | @ModifyExpressionValue | modifyExpressionValue | | ||
| + | | @ModifyReceiver | ||
| + | | @ModifyReturnValue | ||
| + | | @WrapWithCondition | ||
| + | | @WrapOperation | ||
| + | |||
| + | |||
| + | ==== Annotations on Merged Members ==== | ||
| + | On top of being mangled, the handler is also annotated to provide additional information about the injector used. The handler will keep all of its '' | ||
| + | |||
| + | Outside of expression annotations, | ||
| + | |||
| + | <code java> | ||
| + | @MixinMerged( | ||
| + | mixin = "< | ||
| + | priority = <Mixin class priority>, | ||
| + | sessionId = "< | ||
| + | ) | ||
| + | </ | ||
| + | (Formatting not necessarily consistent between decompilers) | ||
| + | |||
| + | This also applies to most merged members, though other annotations may be present depending on the member, such as '' | ||
| + | |||
| + | An example '' | ||
| + | <code java> | ||
| + | @MixinMerged( | ||
| + | mixin = " | ||
| + | priority = 1000, | ||
| + | sessionId = " | ||
| + | ) | ||
| + | </ | ||
| + | |||
| + | Using the mangled name and the '' | ||
| + | |||
| + | |||
| + | ===== Notes ===== | ||
| + | |||
| + | ==== At what point are classes exported ==== | ||
| + | Mixins are applied relative to when the target class is loaded. As such, classes may be transformed and exported at any point between the game starting and an in-game world loading. If a class is not being exported at all without errors, make sure your test run goes as far as world loading. | ||
| - | Some classes may not appear until the game is running (or a world is loading). | + | ==== '' |
| + | When using the '' | ||
tutorial/mixin_export.1584294083.txt.gz · Last modified: 2020/03/15 17:41 by draylar