zh_cn:tutorial:mappings
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
zh_cn:tutorial:mappings [2019/12/18 11:23] – created lightcolour | zh_cn:tutorial:mappings [2020/11/17 03:25] – [介绍] solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | ==== Introduction | + | ==== 定义 |
- | Mappings define the names of classes, fields and methods. In an ordinary | + | 映射(mapping)定义了类、字段和方法的名称。在常规的loom环境中,使用[[https:// |
+ | ==== 使用映射 ==== | ||
- | ==== Using mappings ==== | + | 在Loom中,映射定义了开发环境中使用的Minecraft类,字段和方法的名称。 根据安装的映射,这些名称可能因开发环境而异。 |
- | In Loom, the mappings define the names for Minecraft classes, fields and methods used in your development environment. These names may vary from one development environment to another depending on the installed mappings. | + | 毛线是Loom使用的默认映射。 随着贡献的增加,纱线会逐渐改进并获得新的版本。 使用构建脚本中的“映射”依赖项配置来指定Loom中的映射,并且可以通过更新依赖项来进行更新。 |
- | + | ||
- | Yarn is the default mapping used by Loom. Yarn gradually improves and receives new releases as contributions are accepted. Mappings in Loom are specified using the '' | + | |
< | < | ||
Line 18: | Line 17: | ||
</ | </ | ||
- | By changing the mappings in your development environment, | + | 通过更改开发环境中的映射,可以预期Minecraft中的类,方法和字段的名称以及所有包含的mod均已更改,并且可能必须更新代码以引用更改后的名称。 |
- | Loom' | + | Loom的'' |
+ | * **' | ||
+ | * **纱线名称仅在开发环境中应用**。 在开发环境之外,仅存在中间名称,这意味着代码将与您看到和编写的内容完全不匹配。 Loom可以为您透明地处理此过渡,但是在使用反射时要格外小心。 | ||
- | * **The ' | + | === 自定义映射 |
- | * **Yarn names are only applied in a development environment**. Outside a development environment, | + | |
- | + | ||
- | + | ||
- | === Custom mappings | + | |
You can use custom tiny mappings for Fabric Loom for your Gradle project setup. | You can use custom tiny mappings for Fabric Loom for your Gradle project setup. | ||
- | 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 " | + | 例如,如果您有一个要用于映射的自定义毛线分支,则可以使用'' |
< | < | ||
dependencies { | dependencies { | ||
Line 38: | Line 34: | ||
</ | </ | ||
- | 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 | + | 您可以将放置映射的目录更改为任何自定义名称。 只需在上面的'' |
- | ==== Remapping | + | ==== 重新映射 |
- | Remapping is the process of applying mappings to code, transforming from one set of names to another. Both Java source code and compiled | + | 重新映射是将映射应用于代码,从一组名称转换为另一组名称的过程。 |
- | [[https:// | + | [[https:// |
- | ==== Obfuscation and deobfuscation | + | ==== 混淆和反混淆 |
- | Releases of Minecraft Java Edition | + | Minecraft Java Edition的发行版是混淆的jar文件,这意味着它们是已编译的二进制文件,其中剥离了任何有意义的命名信息,仅保留了裸露的逻辑。 模糊处理的动机是防止反向工程并减小文件大小。 像Minecraft这样的Java程序很容易反编译,但是混淆处理剥夺了很多对修改目的有用的信息。 也许有人会怀疑一开始如何为Minecraft进行开发。 |
- | Mappings like Yarn provide meaningful names for development. Using mappings it is possible to make sense of the Minecraft | + | 像Yarn这样的映射为开发提供了有意义的名称。 使用映射可以理解Minecraft代码并为其创建mod。 映射可以提供类,字段,方法,参数和局部变量的名称。 显然,这些映射并不完美。 绘制《我的世界》的整个地图需要来自多个贡献者的大量猜测。 映射可能不完整,有时会随着找到更准确的名称而更改。 |
- | ==== Intermediary | + | ==== 中间名 |
- | A property of Minecraft's obfuscation is that it is not always consistent between | + | Minecraft的混淆特性是,它在Minecraft版本之间并不总是一致的。在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 as a library for mods because of the lack of binary compatibility. | + | Java代码可以针对一个库版本进行编译,但仍可与另一个版本一起使用,从而使库的两个版本可以二进制兼容。简而言之,如果库公开了至少相同的类,相同的方法和具有相同名称的字段,则将实现二进制兼容性。当使用Minecraft作为mods的库时,由于缺乏二进制兼容性,Minecraft的混淆问题带来了挑战。 |
- | Intermediary defines stable names for Minecraft's internals across | + | 中介为Minecraft版本之间的Minecraft内部定义稳定名称。中介名称的目的是始终引用相同的类,字段或方法。与纱线名称不同,中间名称没有意义,而是遵循数字模式,例如'' |
- | Being a stable mapping, Intermediary can make Minecraft | + | 作为稳定的映射,中间名可以使Minecraft二进制兼容多个版本(例如快照版本)!仅对于版本之间未更改的游戏部分,才保证兼容性。当安装在开发环境之外时,Fabric Loader通过在游戏开始之前重新映射Minecraft(和Realms客户端)来为环境提供中间名称。通过查看安装了Fabric Loader的生产环境中的崩溃报告可以观察到此情况,该报告将包含中间名称。用Loom所应用的中间名称编译的Mod与此环境自然兼容。 |
zh_cn/tutorial/mappings.txt · Last modified: 2024/04/15 00:57 by solidblock