ScoreboardDisplayNameFix.java

net.minecraft.util.datafix.fixes.ScoreboardDisplayNameFix

信息

  • 全限定名:net.minecraft.util.datafix.fixes.ScoreboardDisplayNameFix
  • 类型:public class
  • 包:net.minecraft.util.datafix.fixes
  • 源码路径:src/main/java/net/minecraft/util/datafix/fixes/ScoreboardDisplayNameFix.java
  • 起始行号:L13
  • 继承:DataFix
  • 职责:

    TODO

字段/常量

  • name

    • 类型: String
    • 修饰符: private final
    • 源码定位: L14
    • 说明:

      TODO

  • type

    • 类型: TypeReference
    • 修饰符: private final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

构造器

public ScoreboardDisplayNameFix(Schema outputSchema, String name, TypeReference type) @ L17

  • 构造器名:ScoreboardDisplayNameFix
  • 源码定位:L17
  • 修饰符:public

参数:

  • outputSchema: Schema
  • name: String
  • type: TypeReference

说明:

TODO

方法

下面的方法块按源码顺序生成。

protected TypeRewriteRule makeRule() @ L23

  • 方法名:makeRule
  • 源码定位:L23
  • 返回类型:TypeRewriteRule
  • 修饰符:protected

参数:

说明:

TODO

代码

public class ScoreboardDisplayNameFix extends DataFix {
    private final String name;
    private final TypeReference type;
 
    public ScoreboardDisplayNameFix(Schema outputSchema, String name, TypeReference type) {
        super(outputSchema, false);
        this.name = name;
        this.type = type;
    }
 
    @Override
    protected TypeRewriteRule makeRule() {
        Type<?> inputType = this.getInputSchema().getType(this.type);
        OpticFinder<?> displayNameF = inputType.findField("DisplayName");
        OpticFinder<Pair<String, String>> textComponentF = DSL.typeFinder((Type<Pair<String, String>>)this.getInputSchema().getType(References.TEXT_COMPONENT));
        return this.fixTypeEverywhereTyped(
            this.name,
            inputType,
            team -> team.updateTyped(
                displayNameF,
                displayName -> displayName.update(
                    textComponentF, textComponent -> textComponent.mapSecond(LegacyComponentDataFixUtils::createTextComponentJson)
                )
            )
        );
    }
}

引用的其他类