zh_cn:tutorial:mappings
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
zh_cn:tutorial:mappings [2019/12/18 11:25] – lightcolour | zh_cn:tutorial:mappings [2024/04/15 00:57] (current) – solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== 映射 ====== | ====== 映射 ====== | ||
- | ==== 介绍 | + | ==== 定义 |
- | + | ||
- | 映射定义类,字段和方法的名称。 在普通的织机环境中,使用[[https:// | + | |
+ | 映射(mapping)定义了类、字段和方法的名称。在常规的 loom 环境中,使用的是 [[https:// | ||
==== 使用映射 ==== | ==== 使用映射 ==== | ||
+ | 在 Loom 中,映射定义了你在开发环境中使用的 Minecraft 类、字段和方法的名称。这些名称可能因开发环境而异,取决于你安装的映射。 | ||
- | 在Loom中,映射定义了开发环境中使用的Minecraft类,字段和方法的名称。 根据安装的映射,这些名称可能因开发环境而异。 | + | Yarn 是 Loom 使用的默认映射。随着对贡献的接受,Yarn 逐渐改进并接受新的发布。Loom |
- | 毛线是Loom使用的默认映射。 随着贡献的增加,纱线会逐渐改进并获得新的版本。 使用构建脚本中的“映射”依赖项配置来指定Loom中的映射,并且可以通过更新依赖项来进行更新。 Minecraft以及mod增强的依赖项配置(例如 '' | + | < |
- | + | ||
- | < | + | |
dependencies { | dependencies { | ||
[...] | [...] | ||
Line 18: | Line 16: | ||
</ | </ | ||
- | 通过更改开发环境中的映射,可以预期Minecraft中的类,方法和字段的名称以及所有包含的mod均已更改,并且可能必须更新代码以引用更改后的名称。 [[tutorial: | + | 右改变您的开发环境中的映射,Minecraft |
- | Loom' | + | Loom 的 '' |
- | * **The ' | + | * **' |
- | * **Yarn | + | * **Yarn |
+ | |||
+ | === Mojang 的映射 === | ||
+ | |||
+ | 自 Loom 0.5,你也可以使用 Mojang 的官方映射而不是 Yarn,像这样: | ||
+ | |||
+ | <code groovy> | ||
+ | dependencies { | ||
+ | [...] | ||
+ | mappings minecraft.officialMojangMappings() | ||
+ | } | ||
+ | </ | ||
+ | Mojang 的映射带有可用的但比 Yarn 更严格的许可证。您需要自行承担使用的风险。 | ||
- | === Custom mappings | + | === 自定义映射 |
- | You can use custom tiny mappings for Fabric Loom for your Gradle project setup. | + | 您也可以在您的 Gradle 项目设置为 |
- | For example, if you have a custom branch of yarn which you want to use for mappings, you can build yarn with "./gradlew build" command, take out the jar file in "build/libs" directory, and move it to a folder "mapping" in your Gradle project. Then, change your mappings dependency entry to: | + | 比如,如果您有需要用于映射的自定义 Yarn 分支,你可以使用“./gradlew build”命令建立 yarn,拿出“build/libs”目录中的 jar 文件,然后移动到您的 Gradle 项目中的“mapping”文件夹下。然后,将您的映射依赖项更改为: |
- | < | + | < |
dependencies { | dependencies { | ||
mappings fileTree(dir: | mappings fileTree(dir: | ||
Line 38: | Line 48: | ||
</ | </ | ||
- | You can change the directory where you put mapping to have any custom name; just change the name in "dir" argument above. Note that Gradle build will fail if you have any other file than the mapping | + | 您可以更改放置映射的目录,使其具有任何自定义名称,只需更改上面的“dir”参数中的名称。注意,如果在映射目录中有映射 |
- | ==== Remapping | + | ==== 重映射 |
- | Remapping is the process of applying mappings to code, transforming from one set of names to another. Both Java source code and compiled | + | 重映射是将映射应用于代码,从一组名称转换为另一组名称的过程。Java 源代码和已编译的 |
- | [[https:// | + | [[https:// |
- | ==== Obfuscation and deobfuscation | + | ==== 混淆和反混淆 |
- | Releases of Minecraft Java Edition | + | Minecraft Java Edition |
- | Mappings like Yarn provide meaningful names for development. Using mappings it is possible to make sense of the Minecraft | + | 像 Yarn 这样的映射为开发提供了有意义的名称。使用映射可以理解 |
- | ==== Intermediary | + | ==== 中间名 |
- | A property of Minecraft's obfuscation is that it is not always consistent between | + | Minecraft |
- | Java code may be compiled for one version of a library and still work with another, making the two versions of the library binary compatible. Put simply, binary compatibility is achieved if the library exposes at least the same classes with the same methods and fields with the same names. The inconsistency in Minecraft's obfuscation presents a challenge when using Minecraft | + | Java 代码可以针对一个库版本进行编译,但仍可与另一个版本一起使用,从而使库的两个版本可以二进制兼容。简而言之,如果库公开了至少相同的类,相同的方法和具有相同名称的字段,则将实现二进制兼容性。当使用 |
- | Intermediary defines stable names for Minecraft's internals across | + | 中间名在 |
- | Being a stable mapping, Intermediary can make Minecraft | + | 作为稳定的映射,中间名可以使 |
zh_cn/tutorial/mappings.txt · Last modified: 2024/04/15 00:57 by solidblock