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
tutorial:modding_tips [2021/04/06 20:22] florenstutorial:modding_tips [2024/03/28 22:43] (current) – Add javax.swing to the packages that don't work well on all systems earthcomputer
Line 13: Line 13:
  
   * 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.
-  * @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 small JAR-in-JAR API). 
-  * 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 non-private custom fields or methods, prefix them with "[modid]$" or another unique string and annotate them with @Unique. Essentially, "mymod$secretValue" instead of "secretValue". This is to avoid conflicts between mods adding a field or method named the same way.
  
 ===== Networking ===== ===== Networking =====
Line 22: Line 22:
 ===== 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 hangs Minecraft.+  * Avoid using the ''java.awt'' or ''javax.swing'' package and their subpackages. AWT does not work well on all systems. Several users have reported that it hangs Minecraft.
tutorial/modding_tips.1617740549.txt.gz · Last modified: 2021/04/06 20:22 by florens