zh_cn:tutorial:mappings
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
zh_cn:tutorial:mappings [2019/12/18 11:25] – lightcolour | zh_cn:tutorial:mappings [2023/08/16 02:48] – [中间名] wjz_p | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== 映射 ====== | ====== 映射 ====== | ||
- | ==== 介绍 | + | ==== 定义 |
- | + | ||
- | 映射定义类,字段和方法的名称。 在普通的织机环境中,使用[[https:// | + | |
+ | 映射(mapping)定义了类、字段和方法的名称。在常规的loom环境中,使用[[https:// | ||
==== 使用映射 ==== | ==== 使用映射 ==== | ||
+ | 在Loom中,映射定义了你在开发环境中使用的Minecraft类、字段和方法的名称。这些名称可能因开发环境而异,取决于你安装的映射。 | ||
- | 在Loom中,映射定义了开发环境中使用的Minecraft类,字段和方法的名称。 根据安装的映射,这些名称可能因开发环境而异。 | + | Yarn是Loom使用的默认映射。随着对贡献的接受,Yarn逐渐改进并接受新的发布。Loom中的映射是使用buildcraft中的'' |
- | + | ||
- | 毛线是Loom使用的默认映射。 随着贡献的增加,纱线会逐渐改进并获得新的版本。 使用构建脚本中的“映射”依赖项配置来指定Loom中的映射,并且可以通过更新依赖项来进行更新。 Minecraft以及mod增强的依赖项配置(例如 '' | + | |
< | < | ||
Line 18: | Line 16: | ||
</ | </ | ||
- | 通过更改开发环境中的映射,可以预期Minecraft中的类,方法和字段的名称以及所有包含的mod均已更改,并且可能必须更新代码以引用更改后的名称。 [[tutorial: | + | 通过改变您的开发环境中的映射,Minecraft中类、方法和字段的名称和包括的模组都可能会改变,您的代码可能需要更新才能引用更改的名称。[[tutorial: |
- | Loom' | + | Loom的'' |
- | * **The ' | + | * **' |
- | * **Yarn | + | * **Yarn名称仅应用于开发环境**。在开发环境之外,只存在中间名,也就是说代码不会准确地匹配你看见和写的东西。Loom transparently可以为您处理这个转换,但是使用反射(reflection)时要谨慎。 |
+ | |||
+ | === Mojang的映射 === | ||
+ | |||
+ | 对于Loom 0.5,你也可以使用Mojang的官方映射而不是Yarn,像这样: | ||
+ | |||
+ | < | ||
+ | dependencies { | ||
+ | [...] | ||
+ | mappings minecraft.officialMojangMappings() | ||
+ | } | ||
+ | </ | ||
+ | Mojang的映射带有可用的但比Yarn更严格的许可证。您需要自行承担使用的风险。 | ||
- | === Custom mappings | + | === 自定义映射 |
- | You can use custom tiny mappings for Fabric Loom for your Gradle project setup. | + | 您也可以在您的Gradle项目设置为Fabric Loom使用自定义的微型(tiny)映射。 |
- | 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”文件夹下。然后,将您的映射依赖项更改为: |
< | < | ||
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”参数中的名称。注意,如果在映射目录中有映射jar文件以外的任何其他文件,Gradle构建将失败! |
- | ==== 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的混淆问题(为mod在不同游戏版本间的兼容性)带来了挑战。 |
- | 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