DataComponentRemainderFix.java

net.minecraft.util.datafix.fixes.DataComponentRemainderFix

信息

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

    TODO

字段/常量

  • name

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

      TODO

  • componentId

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

      TODO

  • newComponentId

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

      TODO

内部类/嵌套类型

构造器

public DataComponentRemainderFix(Schema outputSchema, String name, String componentId) @ L17

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

参数:

  • outputSchema: Schema
  • name: String
  • componentId: String

说明:

TODO

public DataComponentRemainderFix(Schema outputSchema, String name, String componentId, String newComponentId) @ L21

  • 构造器名:DataComponentRemainderFix
  • 源码定位:L21
  • 修饰符:public

参数:

  • outputSchema: Schema
  • name: String
  • componentId: String
  • newComponentId: String

说明:

TODO

方法

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

public final TypeRewriteRule makeRule() @ L28

  • 方法名:makeRule
  • 源码定位:L28
  • 返回类型:TypeRewriteRule
  • 修饰符:public final

参数:

说明:

TODO

protected abstract <T> Dynamic<T> fixComponent(Dynamic<T> input) @ L42

  • 方法名:fixComponent
  • 源码定位:L42
  • 返回类型: Dynamic
  • 修饰符:protected abstract

参数:

  • input: Dynamic

说明:

TODO

代码

public abstract class DataComponentRemainderFix extends DataFix {
    private final String name;
    private final String componentId;
    private final String newComponentId;
 
    public DataComponentRemainderFix(Schema outputSchema, String name, String componentId) {
        this(outputSchema, name, componentId, componentId);
    }
 
    public DataComponentRemainderFix(Schema outputSchema, String name, String componentId, String newComponentId) {
        super(outputSchema, false);
        this.name = name;
        this.componentId = componentId;
        this.newComponentId = newComponentId;
    }
 
    @Override
    public final TypeRewriteRule makeRule() {
        Type<?> dataComponentsType = this.getInputSchema().getType(References.DATA_COMPONENTS);
        return this.fixTypeEverywhereTyped(this.name, dataComponentsType, components -> components.update(DSL.remainderFinder(), remainder -> {
            Optional<? extends Dynamic<?>> component = remainder.get(this.componentId).result();
            if (component.isEmpty()) {
                return remainder;
            } else {
                Dynamic<?> newComponent = this.fixComponent((Dynamic<?>)component.get());
                return remainder.remove(this.componentId).setFieldIfPresent(this.newComponentId, Optional.ofNullable(newComponent));
            }
        }));
    }
 
    protected abstract <T> @Nullable Dynamic<T> fixComponent(Dynamic<T> input);
}

引用的其他类