ItemCustomNameToComponentFix.java
net.minecraft.util.datafix.fixes.ItemCustomNameToComponentFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.ItemCustomNameToComponentFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/ItemCustomNameToComponentFix.java
- 起始行号:L12
- 继承:DataFix
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
public ItemCustomNameToComponentFix(Schema outputSchema) @ L13
- 构造器名:ItemCustomNameToComponentFix
- 源码定位:L13
- 修饰符:public
参数:
- outputSchema: Schema
说明:
TODO
方法
下面的方法块按源码顺序生成。
public TypeRewriteRule makeRule() @ L17
- 方法名:makeRule
- 源码定位:L17
- 返回类型:TypeRewriteRule
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class ItemCustomNameToComponentFix extends DataFix {
public ItemCustomNameToComponentFix(Schema outputSchema) {
super(outputSchema, false);
}
@Override
public TypeRewriteRule makeRule() {
Type<?> itemStackType = this.getInputSchema().getType(References.ITEM_STACK);
Type<Pair<String, String>> textComponentType = (Type<Pair<String, String>>)this.getInputSchema().getType(References.TEXT_COMPONENT);
OpticFinder<?> tagFinder = itemStackType.findField("tag");
OpticFinder<?> displayFinder = tagFinder.type().findField("display");
OpticFinder<?> customNameFinder = displayFinder.type().findField("Name");
OpticFinder<Pair<String, String>> textComponentFinder = DSL.typeFinder(textComponentType);
return this.fixTypeEverywhereTyped(
"ItemCustomNameToComponentFix",
itemStackType,
itemStack -> itemStack.updateTyped(
tagFinder,
tag -> tag.updateTyped(
displayFinder,
display -> display.updateTyped(
customNameFinder,
customName -> customName.update(
textComponentFinder, textComponent -> textComponent.mapSecond(LegacyComponentDataFixUtils::createTextComponentJson)
)
)
)
)
);
}
}引用的其他类
- Schema
- 引用位置:
参数
- 引用位置: