NamedEntityWriteReadFix.java
net.minecraft.util.datafix.fixes.NamedEntityWriteReadFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.NamedEntityWriteReadFix
- 类型:public abstract class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/NamedEntityWriteReadFix.java
- 起始行号:L15
- 继承:DataFix
- 职责:
TODO
字段/常量
-
name- 类型:
String - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
entityName- 类型:
String - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
type- 类型:
TypeReference - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public NamedEntityWriteReadFix(Schema outputSchema, boolean changesType, String name, TypeReference type, String entityName) @ L20
- 构造器名:NamedEntityWriteReadFix
- 源码定位:L20
- 修饰符:public
参数:
- outputSchema: Schema
- changesType: boolean
- name: String
- type: TypeReference
- entityName: String
说明:
TODO
方法
下面的方法块按源码顺序生成。
public TypeRewriteRule makeRule() @ L27
- 方法名:makeRule
- 源码定位:L27
- 返回类型:TypeRewriteRule
- 修饰符:public
参数:
- 无
说明:
TODO
private <S,T,A> TypeRewriteRule fix(Type<S> inputEntityType, Type<T> outputEntityType, Type<?> patchedEntityType, OpticFinder<A> choiceFinder) @ L37
- 方法名:fix
- 源码定位:L37
- 返回类型:<S,T,A> TypeRewriteRule
- 修饰符:private
参数:
说明:
TODO
protected abstract <T> Dynamic<T> fix(Dynamic<T> input) @ L48
- 方法名:fix
- 源码定位:L48
- 返回类型:
Dynamic - 修饰符:protected abstract
参数:
- input: Dynamic
说明:
TODO
代码
public abstract class NamedEntityWriteReadFix extends DataFix {
private final String name;
private final String entityName;
private final TypeReference type;
public NamedEntityWriteReadFix(Schema outputSchema, boolean changesType, String name, TypeReference type, String entityName) {
super(outputSchema, changesType);
this.name = name;
this.type = type;
this.entityName = entityName;
}
@Override
public TypeRewriteRule makeRule() {
Type<?> inputEntityType = this.getInputSchema().getType(this.type);
Type<?> inputEntityChoiceType = this.getInputSchema().getChoiceType(this.type, this.entityName);
Type<?> outputEntityType = this.getOutputSchema().getType(this.type);
OpticFinder<?> entityF = DSL.namedChoice(this.entityName, inputEntityChoiceType);
Type<?> patchedEntityType = ExtraDataFixUtils.patchSubType(inputEntityType, inputEntityType, outputEntityType);
return this.fix(inputEntityType, outputEntityType, patchedEntityType, entityF);
}
private <S, T, A> TypeRewriteRule fix(Type<S> inputEntityType, Type<T> outputEntityType, Type<?> patchedEntityType, OpticFinder<A> choiceFinder) {
return this.fixTypeEverywhereTyped(this.name, inputEntityType, outputEntityType, typed -> {
if (typed.getOptional(choiceFinder).isEmpty()) {
return ExtraDataFixUtils.cast(outputEntityType, typed);
} else {
Typed<?> fakeTyped = ExtraDataFixUtils.cast(patchedEntityType, typed);
return Util.writeAndReadTypedOrThrow(fakeTyped, outputEntityType, this::fix);
}
});
}
protected abstract <T> Dynamic<T> fix(final Dynamic<T> input);
}