ProjectileStoredWeaponFix.java

net.minecraft.util.datafix.fixes.ProjectileStoredWeaponFix

信息

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

    TODO

字段/常量

内部类/嵌套类型

构造器

public ProjectileStoredWeaponFix(Schema outputSchema) @ L16

  • 构造器名:ProjectileStoredWeaponFix
  • 源码定位:L16
  • 修饰符:public

参数:

  • outputSchema: Schema

说明:

TODO

方法

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

protected TypeRewriteRule makeRule() @ L20

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

参数:

说明:

TODO

private Function<Typed<?>,Typed<?>> fixChoice(String entityName) @ L32

  • 方法名:fixChoice
  • 源码定位:L32
  • 返回类型:Function<Typed,Typed>
  • 修饰符:private

参数:

  • entityName: String

说明:

TODO

private static <T> Function<Typed<?>,Typed<?>> fixChoiceCap(String entityName, Type<?> inputEntityChoiceType, Type<T> outputEntityChoiceType) @ L38

  • 方法名:fixChoiceCap
  • 源码定位:L38
  • 返回类型: Function<Typed,Typed>
  • 修饰符:private static

参数:

  • entityName: String
  • inputEntityChoiceType: Type<?>
  • outputEntityChoiceType: Type

说明:

TODO

代码

public class ProjectileStoredWeaponFix extends DataFix {
    public ProjectileStoredWeaponFix(Schema outputSchema) {
        super(outputSchema, true);
    }
 
    @Override
    protected TypeRewriteRule makeRule() {
        Type<?> inputEntityType = this.getInputSchema().getType(References.ENTITY);
        Type<?> outputEntityType = this.getOutputSchema().getType(References.ENTITY);
        return this.fixTypeEverywhereTyped(
            "Fix Arrow stored weapon",
            inputEntityType,
            outputEntityType,
            ExtraDataFixUtils.chainAllFilters(this.fixChoice("minecraft:arrow"), this.fixChoice("minecraft:spectral_arrow"))
        );
    }
 
    private Function<Typed<?>, Typed<?>> fixChoice(String entityName) {
        Type<?> inputEntityChoiceType = this.getInputSchema().getChoiceType(References.ENTITY, entityName);
        Type<?> outputEntityChoiceType = this.getOutputSchema().getChoiceType(References.ENTITY, entityName);
        return fixChoiceCap(entityName, inputEntityChoiceType, outputEntityChoiceType);
    }
 
    private static <T> Function<Typed<?>, Typed<?>> fixChoiceCap(String entityName, Type<?> inputEntityChoiceType, Type<T> outputEntityChoiceType) {
        OpticFinder<?> entityF = DSL.namedChoice(entityName, inputEntityChoiceType);
        return input -> input.updateTyped(
            entityF, outputEntityChoiceType, typed -> Util.writeAndReadTypedOrThrow(typed, outputEntityChoiceType, UnaryOperator.identity())
        );
    }
}

引用的其他类

  • Schema

    • 引用位置: 参数
  • Util

    • 引用位置: 方法调用
    • 关联成员: Util.writeAndReadTypedOrThrow()
  • ExtraDataFixUtils

    • 引用位置: 方法调用
    • 关联成员: ExtraDataFixUtils.chainAllFilters()