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

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
zh_cn:tutorial:modding_tips [2022/01/30 03:11] – [基本(API)] solidblockzh_cn:tutorial:modding_tips [2022/05/27 23:54] – external edit 127.0.0.1
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.txt · Last modified: 2024/04/15 02:25 by solidblock