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
modding:tips [2019/01/22 19:44] asietutorial: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.
  
 ===== Mixins ===== ===== Mixins =====
  
-  * To modify constructor, use "<init>" (or "<clinit>" for static constructorsas the method name. Please note that @Inject on constructors only works with @At("RETURN"- no other forms of injection are officially supported! +  * To cast class to an interface it doesn't implementor cast a final class, or cast the mixin to your target class, you can use the "(TargetClass) (ObjectsourceClassObject" 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 =====
  
   * Packets always begin execution on the **network thread**, however accesses to most Minecraft things are not thread-safe. In general, if you're not exactly sure what you're doing, you want to parse the packet on the network thread (read all the values out), then use the **task queue** to perform additional operations on the **main server/client thread**.   * Packets always begin execution on the **network thread**, however accesses to most Minecraft things are not thread-safe. In general, if you're not exactly sure what you're doing, you want to parse the packet on the network thread (read all the values out), then use the **task queue** to perform additional operations on the **main server/client thread**.
 +
 +===== Pitfalls =====
 +
 +  * 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