RemapASMForMixin
基本信息
| 属性 | 值 |
|---|---|
| 全名 | io.github.legacymoddingmc.unimixins.compat.api.RemapASMForMixin |
| 文件 | module-compat/src/main/java/…/compat/api/RemapASMForMixin.java |
| 类型 | 注解(@interface) |
| 保留策略 | RUNTIME |
| 目标 | ElementType.TYPE(仅类) |
| 启用版本 | Minecraft 1.7.10 |
源码注释原文(白话)
Decorate your class with this annotation to make UniMixins remap references to
org.objectweb.asmto the ASM package name used by the current Mixin environment.This is needed if you have a mixin config plugin compiled against this package name, and you want to pass the
ClassNodereference to a different class, since otherwise UniMixins only remaps references inside the mixin config plugin class.
解决的问题
ASMRemapperTransformer 对 org.objectweb.asm(Mixin 0.8 包名)
的默认重映射只作用于 mixin config plugin 类内部。
若你有一个 config plugin,想把 ClassNode 引用传给另一个类处理,
那个类里的 org.objectweb.asm 引用就不会被重映射 → 运行期 NoClassDefFoundError。
本注解就是显式给那个「另一个类」打标记,把它的引用纳入重映射范围。
实现要点
⚠️ @Target(ElementType.TYPE) 只允许标在类/接口/枚举上,
不能标在方法或字段上。
⚠️ @Retention(RUNTIME) —— 运行时可见,
因为 ASMRemapperTransformer 是在字节码层面
按类型注解判定范围的,不是编译期行为。
⚠️ 本注解无任何元素(@interface 体为空),
它是纯标记(marker annotation),不存在可配置参数。
⚠️ 这是 module-compat 下唯一位于 api/ 子包的类,
说明它是对外暴露的 API:供第三方 mod 的 config plugin 使用。
⚠️ 本仓库自身没有任何类标注 @RemapASMForMixin ——
它纯粹是给外部 mod 用的。在本仓的 87 个文件里 grep 该注解名,
只能命中定义处。
相关条目
- ASMRemapperTransformer - 消费本注解
- module-compat - 所属模块
- CompatConfig -
enableRemapper开关