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
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:modding_tips [2019/09/16 16:46] – [Pitfalls] changed code to be surrounded by monospace block manxboytutorial:modding_tips [2020/09/14 01:49] – [Pitfalls] manxboy
Line 14: Line 14:
  
   * To cast a class to an interface it doesn't implement, or cast a final class, or cast the mixin to your target class, you can use the "(TargetClass) (Object) sourceClassObject" trick.   * To cast a class to an interface it doesn't implement, or cast a final class, or cast the mixin to your target class, you can use the "(TargetClass) (Object) sourceClassObject" trick.
-  * To modify a constructor, use "<init>" (or "<clinit>" for static constructors) as the method name. Please note that @Inject on constructors only works with @At("RETURN") - no other forms of injection are officially supported! 
   * @Redirect and @ModifyConstant mixins cannot currently be nested (applied by more than one mod in the same area at the same time). This might change later in development - however, for now, alongside @Overwrite, please avoid them if possible (or discuss bringing the hook over to Fabric's API, or - for more niche things - consider putting it in a JAR-in-JAR once that's out).   * @Redirect and @ModifyConstant mixins cannot currently be nested (applied by more than one mod in the same area at the same time). This might change later in development - however, for now, alongside @Overwrite, please avoid them if possible (or discuss bringing the hook over to Fabric's API, or - for more niche things - consider putting it in a JAR-in-JAR once that's out).
   * If you're adding custom fields or methods, especially if they're not attached to an interface - prefix them with "[modid]_" or another unique string. Essentially, "mymod_secretValue" instead of "secretValue". This is to avoid conflicts between mods adding a field or method named the same way!   * If you're adding custom fields or methods, especially if they're not attached to an interface - prefix them with "[modid]_" or another unique string. Essentially, "mymod_secretValue" instead of "secretValue". This is to avoid conflicts between mods adding a field or method named the same way!
Line 24: Line 23:
 ===== Pitfalls ===== ===== Pitfalls =====
  
-  * Avoid using the ''java.awt'' package and its subpackages. AWT does not work well on all systems. Several users have reported that it tends to hang Minecraft.+  * Avoid using the ''java.awt'' package and its subpackages. AWT does not work well on all systems. Several users have reported that it hangs Minecraft.
tutorial/modding_tips.txt · Last modified: 2024/04/15 02:25 by solidblock