User Tools

Site Tools


tutorial:modding_tips

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tutorial:modding_tips [2026/01/24 13:36] – Fix misc. Mixin issues, mark Mixin segment as likely being removed in the future; gauntreclusetutorial:modding_tips [2026/01/24 23:01] (current) – [Mixins] Rephrase parentheses elaborating upon the term "chain" (phrasing inspired by flirora and skynotthelimit on Discord) gauntrecluse
Line 17: Line 17:
  
   * When needing to reference an instance of the target class in your Mixin and pass it to a method call or constructor, you cannot use ''this'' directly, as your Mixin class is not yet of the type of the target class. Instead, you must first cast to ''Object'' and then to the target class: ''(TargetClass) (Object) this''. This should not be used as a way to access the target class's fields or methods, as those can be accessed through ''@Shadow''.   * When needing to reference an instance of the target class in your Mixin and pass it to a method call or constructor, you cannot use ''this'' directly, as your Mixin class is not yet of the type of the target class. Instead, you must first cast to ''Object'' and then to the target class: ''(TargetClass) (Object) this''. This should not be used as a way to access the target class's fields or methods, as those can be accessed through ''@Shadow''.
-  * ''@Redirect'' and ''@ModifyConstant'' mixins cannot chain(be applied more than once on the same target at the same time). Alongside @Overwrite, which is incredibly incompatible as it replaces the method outright, please avoid them if possible and prioritize using options provided by MixinExtras:+  * ''@Redirect'' and ''@ModifyConstant'' mixins cannot chain(that is, only one ''@Redirect'' or ''@ModifyConstant'' can be applied to the same target at time, meaning that the second to be applied will fail, likely throwing a crash). Alongside @Overwrite, which is incredibly incompatible as it replaces the method outright, please avoid them if possible and prioritize using options provided by MixinExtras:
     * MixinExtras, a library for Mixin bundled with Fabric, provides alternatives to the aforementioned options that can chain when used in the same place as another Mixin. Mainly, ''@WrapOperation'' and ''@ModifyExpressionValue'' can be used instead of ''@Redirect'' and ''@ModifyConstant'' for all cases which do not involve intentionally clashing with another mod. ''@Overwrite'' should almost //never// be used over more precise modifications using injectors. See the [[https://github.com/LlamaLad7/MixinExtras/wiki|official MixinExtras wiki]] for more details on the library's features.     * MixinExtras, a library for Mixin bundled with Fabric, provides alternatives to the aforementioned options that can chain when used in the same place as another Mixin. Mainly, ''@WrapOperation'' and ''@ModifyExpressionValue'' can be used instead of ''@Redirect'' and ''@ModifyConstant'' for all cases which do not involve intentionally clashing with another mod. ''@Overwrite'' should almost //never// be used over more precise modifications using injectors. See the [[https://github.com/LlamaLad7/MixinExtras/wiki|official MixinExtras wiki]] for more details on the library's features.
  
tutorial/modding_tips.1769261812.txt.gz · Last modified: 2026/01/24 13:36 by gauntrecluse