User Tools

Site Tools


zh_cn:tutorial:modding_tips

Differences

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

Link to this comparison view

Next revision
Previous revision
zh_cn:tutorial:modding_tips [2021/05/20 11:32] – created solidblockzh_cn:tutorial:modding_tips [2024/04/15 02:25] (current) solidblock
Line 5: Line 5:
 ===== 基本(API) ===== ===== 基本(API) =====
  
-  * 由于Fabric API开发的基于注的方法,我们不需要以用户可见的方式彻底修改类。发现一些你做不到的东西时,你有时只需要找原版类的Fabric扩展。比如: +  * 由于 Fabric API 开发的基于注的方法,我们不需要以用户可见的方式彻底修改类。发现一些你做不到的东西时,你有时只需要找原版类的 Fabric 扩展。比如: 
-    * Block.Settings -> FabricBlockSettings+    * Block.Settings -> FabricBlockSettings(除了 1.20.5)
     * EntityType.Builder -> FabricEntityTypeBuilder     * EntityType.Builder -> FabricEntityTypeBuilder
   * 对于内建的资源包或者数据包,请确保分别存在“assets/模组id”或“data/模组id”的目录!IDEA用户可能会发现他们偶然创建了“assets.模组id”目录——这不起作用。   * 对于内建的资源包或者数据包,请确保分别存在“assets/模组id”或“data/模组id”的目录!IDEA用户可能会发现他们偶然创建了“assets.模组id”目录——这不起作用。
Line 12: Line 12:
 ===== Mixins ===== ===== Mixins =====
  
-  * 要将类强制转换为它未实现的接口,或强制转换为最终类,或将mixin强制转换为目标类,你可以使用“(TargetClass) (Object) sourceClassObject”的技巧。 +  * 要将类强制转换为它未实现的接口,或强制转换为最终类,或将 mixin 强制转换为目标类,你可以使用“(TargetClass) (Object) sourceClassObject”的技巧。 
-  * @Redirect 和 @ModifyConstant mixins 目前无法嵌套(多个模组同时应用在同一个地方)。这在开发中可能以后会改变——然而,目前,同@Overwrite一样,请尽量避免使用(or discuss bringing the hook over to Fabric'API, or - for more niche things - consider putting it in a small JAR-in-JAR API). +  * @Redirect 和 @ModifyConstant mixins 目前无法嵌套(多个模组同时应用在同一个地方)。这在开发中可能以后会改变——然而,目前,同 @Overwrite 一样,请尽量避免使用(或尝试将钩子桥接至 Fabric API,或者考虑放在小的 JAR 中 JAR API 中。 
-  * 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.+  * 如果你要添加非私有的自定义字段或方法,请加上“模组id$”的前缀,或者加上其他独一无二的字符串并注解为 @Unique。比如,“mymod$secretValue”而不是“secretValue”。这样可以避免多个模组以相同方式添加字段或者方法。
  
 ===== 网络 ===== ===== 网络 =====
  
-  * 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**.+  * 封包永远是在**网络线程**开始执行的,但它对 Minecraft 大多数内容的访问都不是线程安全的。因此,如果你确定你在做什么,你应该在网络线程解析封包(将所有值读出来),然后使用**任务队列****主服务器/客户端线程**上执行额外操作。
  
-===== 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.+  * 避免使用 ''java.awt'' 包以及其子包。AWT 在有的系统上运作不佳。一些用户已经报告了该包会挂起 Minecraft
zh_cn/tutorial/modding_tips.1621510363.txt.gz · Last modified: 2021/05/20 11:32 by solidblock