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
Last revisionBoth sides next revision
tutorial:modding_tips [2020/09/14 01:49] – [Pitfalls] manxboytutorial:modding_tips [2024/03/28 22:43] – Add javax.swing to the packages that don't work well on all systems earthcomputer
Line 8: Line 8:
     * Block.Settings -> FabricBlockSettings     * Block.Settings -> FabricBlockSettings
     * EntityType.Builder -> FabricEntityTypeBuilder     * EntityType.Builder -> FabricEntityTypeBuilder
-  * While an official configuration system is being worked on, one replacement for now is to use Java .properties or JSON. 
   * For a built-in resource pack or data pack, please ensure that an "assets/[mod id]" or "data/[mod id]" directory path is present, respectively! IDEA users might find themselves accidentally creating an "assets.[mod id]" directory - this won't work.   * For a built-in resource pack or data pack, please ensure that an "assets/[mod id]" or "data/[mod id]" directory path is present, respectively! IDEA users might find themselves accidentally creating an "assets.[mod id]" directory - this won't work.
  
Line 14: 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 23: 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.txt · Last modified: 2024/04/15 02:25 by solidblock