User Tools

Site Tools


zh_cn:tutorial:reading_mc_code

Differences

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

Link to this comparison view

Next revision
Previous revision
zh_cn:tutorial:reading_mc_code [2021/10/10 00:18] – created solidblockzh_cn:tutorial:reading_mc_code [2023/08/29 10:28] (current) – [查找你想要看到的类] solidblock
Line 10: Line 10:
  
 ==== Intellij IDEA ==== ==== Intellij IDEA ====
-    - 按 ''Ctrl + N'' 打开搜索面板+    - 按 {{https://i.ibb.co/rmztpCy/IMG-0712.png?height=64}} 或 mac 上的 {{https://i.ibb.co/2SDypGK/kbs-meta-o.png?height=80}} 打开搜索面板
     - 将搜索范围设为 ''项目和库'' 或者更大范围     - 将搜索范围设为 ''项目和库'' 或者更大范围
     - 在搜索框中输入类名称     - 在搜索框中输入类名称
Line 21: Line 21:
  
 ===== 查找你想要看到的类 ==== ===== 查找你想要看到的类 ====
-Locating the part of code you want to see is a challenging task. Here are some tips. +定位到你需要岔开的代码部分并不容易。这里是一些小技巧:
- +
-    * Take full advantage of IDE's ability to find the relevant code such as ''Call hierarchy'', ''Method hierarchy'' or ''Type hierarchy''+
-    * Take a look at open source mods which are similar to what you want to make. +
-    * If you are adding a new content, there is a good chance you need to access registries defined in ''net.minecraft.util.registry.Registry''+
-    * Keep in mind that everything starts from one main class (''net.minecraft.client.main.Main'' for client, ''net.minecraft.server.Main'' for dedicated server).+
  
 +    * 充分利用 IDE 的查找相关代码的能力,如调用递归、方法递归、类型递归等。
 +    * 看看与你需要制作的模组类似地开源模组是怎么做的。
 +    * 如果你需要添加新内容,可以访问在 ''net.minecraft.util.registry.Registries'' 中定义的注册表。
 +    * 记住一切都是从主类(客户端 ''net.minecraft.client.main.Main'',专用服务器 ''net.minecraft.server.Main'')开始的。
 +    * 在 Minecraft 代码中查找翻译键。''assets/assets/minecraft/lang/en_us.json'' 包含了原版使用的所有翻译键。
 ===== 阅读字节码 ===== ===== 阅读字节码 =====
 有时必须要阅读字节码,这是因为 有时必须要阅读字节码,这是因为
Line 33: Line 33:
     * 反编译器(FernFlower)并不完美,有时会产生一些无效的 Java 代码,比如 ''int i = true;''     * 反编译器(FernFlower)并不完美,有时会产生一些无效的 Java 代码,比如 ''int i = true;''
  
-如果你不熟悉 Java 字节码,请参考 [[https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-6.html|JVM 指定]]。+如果你不熟悉 Java 字节码,请参考 [[https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-6.html|JVM 规范]]。
  
 查看字节码有以下步骤: 查看字节码有以下步骤:
Line 39: Line 39:
 ==== Intellij IDEA ==== ==== Intellij IDEA ====
     - 打开你需要查看字节码的类     - 打开你需要查看字节码的类
-    - 从主菜单中选择 ''查看'' +    - 从主菜单中选择 ''视图(View)'' 
-    - 选择 ''显示字节码''+    - 选择 ''显示字节码(Show Bytecode)''
  
 ==== 外部工具 ==== ==== 外部工具 ====
zh_cn/tutorial/reading_mc_code.1633825125.txt.gz · Last modified: 2021/10/10 00:18 by solidblock