1 个不稳定版本
0.1.0 | 2024年1月8日 |
---|
#5 in #obfuscated
16KB
197 代码行,不包括注释
Yarn Remapper
yarn_remapper
is a Rust library that remaps Minecraft Yarn named mappings to their obfuscated counterparts. It parses the TINY v2 mapping format provided by FabricMC and enables the remapping of class names, method names, field names, and their descriptors. This tool is essential for accessing obfuscated classes, fields, and methods via the Java Native Interface (JNI) and is a foundational component of LiquidBounce Lite, a Minecraft DLL injection client written in Rust.
工作原理
The yarn_remapper
library leverages the TINY v2 mapping format, which uses hierarchical sections to define mappings between named, intermediary, and official obfuscated class names, method names, field names, and descriptors. These mappings help transform names from the readable Yarn mappings to the obfuscated names used in Minecraft's official releases.
TINY v2 格式片段示例
tiny 2 0 official intermediary named
c a class_123 pkg/SomeClass
f [I a field_789 someField
m (III)V a method_456 someMethod
p 1 param_0 x
p 2 param_1 y
p 3 param_2 z
c b class_234 pkg/xy/AnotherClass
m (Ljava/lang/String;)I a method_567 anotherMethod
安装
Add yarn_remapper to your Cargo.toml dependencies
[dependencies]
yarn_remapper = "0.1.0"
确保你已经下载了所需的映射文件进行重映射
TINY v2 映射文件:yarn-1.20.4-rc1+build.1-mergedv2.jar
用法
Here's an example of how to use yarn_remapper in your Rust project
use yarn_remapper::{Mapping, parse_tiny_v2};
use std::path::Path;
fn main() -> Result<(), Error> {
// Path to the TINY v2 mapping file
let path = Path::new("path/to/mappings.tiny");
// Parse mappings
let mapping = parse_tiny_v2(&path)?;
// Remap a class name
if let Some(obfuscated_name) = mapping.remap_class("net/minecraft/client/MinecraftClient") {
println!("Obfuscated class name: {}", obfuscated_name);
}
// Remap a method name with descriptor
if let Some(obfuscated_method_name) = mapping.remap_method("net/minecraft/client/MinecraftClient", "getWindowTitle", "()Ljava/lang/String;") {
println!("Obfuscated method name: {}", obfuscated_method_name);
}
// Remap a field name with descriptor
if let Some(obfuscated_field_name) = mapping.remap_field("net/minecraft/client/MinecraftClient", "inGameHud", "Lnet/minecraft/client/gui/hud/InGameHud;") {
println!("Obfuscated field name: {}", obfuscated_field_name);
}
Ok(())
}
许可证
This project is licensed under the GNU GPLv3 License - see the LICENSE file for details.
贡献
欢迎贡献!请打开一个 pull request 或 issue 以贡献到项目或提出改进建议。
此项目与 Mojang 或 Minecraft 无关。
依赖项
~1.5MB
~38K SLoC