FixProjectileStoredItem.java
net.minecraft.util.datafix.fixes.FixProjectileStoredItem
信息
- 全限定名:net.minecraft.util.datafix.fixes.FixProjectileStoredItem
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/FixProjectileStoredItem.java
- 起始行号:L16
- 继承:DataFix
- 职责:
TODO
字段/常量
EMPTY_POTION- 类型:
String - 修饰符:
private static final - 源码定位:
L17 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.util.datafix.fixes.FixProjectileStoredItem.SubFixer- 类型:
interface - 修饰符:
private - 源码定位:
L72 - 说明:
TODO
- 类型:
构造器
public FixProjectileStoredItem(Schema outputSchema) @ L19
- 构造器名:FixProjectileStoredItem
- 源码定位:L19
- 修饰符:public
参数:
- outputSchema: Schema
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected TypeRewriteRule makeRule() @ L23
- 方法名:makeRule
- 源码定位:L23
- 返回类型:TypeRewriteRule
- 修饰符:protected
参数:
- 无
说明:
TODO
private Function<Typed<?>,Typed<?>> fixChoice(String entityName, FixProjectileStoredItem.SubFixer<?> fixer) @ L39
- 方法名:fixChoice
- 源码定位:L39
- 返回类型:Function<Typed,Typed>
- 修饰符:private
参数:
- entityName: String
- fixer: FixProjectileStoredItem.SubFixer<?>
说明:
TODO
private static <T> Function<Typed<?>,Typed<?>> fixChoiceCap(String entityName, FixProjectileStoredItem.SubFixer<?> fixer, Type<?> inputEntityChoiceType, Type<T> outputEntityChoiceType) @ L45
- 方法名:fixChoiceCap
- 源码定位:L45
- 返回类型:
Function<Typed,Typed> - 修饰符:private static
参数:
- entityName: String
- fixer: FixProjectileStoredItem.SubFixer<?>
- inputEntityChoiceType: Type<?>
- outputEntityChoiceType: Type
说明:
TODO
private static <T> Typed<T> fixArrow(Typed<?> typed, Type<T> outputType) @ L52
- 方法名:fixArrow
- 源码定位:L52
- 返回类型:
Typed - 修饰符:private static
参数:
- typed: Typed<?>
- outputType: Type
说明:
TODO
private static String getArrowType(Dynamic<?> input) @ L56
- 方法名:getArrowType
- 源码定位:L56
- 返回类型:String
- 修饰符:private static
参数:
- input: Dynamic<?>
说明:
TODO
private static <T> Typed<T> fixSpectralArrow(Typed<?> typed, Type<T> outputType) @ L60
- 方法名:fixSpectralArrow
- 源码定位:L60
- 返回类型:
Typed - 修饰符:private static
参数:
- typed: Typed<?>
- outputType: Type
说明:
TODO
private static Dynamic<?> createItemStack(Dynamic<?> input, String itemName) @ L64
- 方法名:createItemStack
- 源码定位:L64
- 返回类型:Dynamic<?>
- 修饰符:private static
参数:
- input: Dynamic<?>
- itemName: String
说明:
TODO
private static <T> Typed<T> castUnchecked(Typed<?> input, Type<T> outputType) @ L68
- 方法名:castUnchecked
- 源码定位:L68
- 返回类型:
Typed - 修饰符:private static
参数:
- input: Typed<?>
- outputType: Type
说明:
TODO
代码
public class FixProjectileStoredItem extends DataFix {
private static final String EMPTY_POTION = "minecraft:empty";
public FixProjectileStoredItem(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 AbstractArrow item type",
inputEntityType,
outputEntityType,
ExtraDataFixUtils.chainAllFilters(
this.fixChoice("minecraft:trident", FixProjectileStoredItem::castUnchecked),
this.fixChoice("minecraft:arrow", FixProjectileStoredItem::fixArrow),
this.fixChoice("minecraft:spectral_arrow", FixProjectileStoredItem::fixSpectralArrow)
)
);
}
private Function<Typed<?>, Typed<?>> fixChoice(String entityName, FixProjectileStoredItem.SubFixer<?> fixer) {
Type<?> inputEntityChoiceType = this.getInputSchema().getChoiceType(References.ENTITY, entityName);
Type<?> outputEntityChoiceType = this.getOutputSchema().getChoiceType(References.ENTITY, entityName);
return fixChoiceCap(entityName, fixer, inputEntityChoiceType, outputEntityChoiceType);
}
private static <T> Function<Typed<?>, Typed<?>> fixChoiceCap(
String entityName, FixProjectileStoredItem.SubFixer<?> fixer, Type<?> inputEntityChoiceType, Type<T> outputEntityChoiceType
) {
OpticFinder<?> entityF = DSL.namedChoice(entityName, inputEntityChoiceType);
return input -> input.updateTyped(entityF, outputEntityChoiceType, typed -> ((FixProjectileStoredItem.SubFixer<T>)fixer).fix(typed, outputEntityChoiceType));
}
private static <T> Typed<T> fixArrow(Typed<?> typed, Type<T> outputType) {
return Util.writeAndReadTypedOrThrow(typed, outputType, input -> input.set("item", createItemStack(input, getArrowType(input))));
}
private static String getArrowType(Dynamic<?> input) {
return input.get("Potion").asString("minecraft:empty").equals("minecraft:empty") ? "minecraft:arrow" : "minecraft:tipped_arrow";
}
private static <T> Typed<T> fixSpectralArrow(Typed<?> typed, Type<T> outputType) {
return Util.writeAndReadTypedOrThrow(typed, outputType, input -> input.set("item", createItemStack(input, "minecraft:spectral_arrow")));
}
private static Dynamic<?> createItemStack(Dynamic<?> input, String itemName) {
return input.createMap(ImmutableMap.of(input.createString("id"), input.createString(itemName), input.createString("Count"), input.createInt(1)));
}
private static <T> Typed<T> castUnchecked(Typed<?> input, Type<T> outputType) {
return new Typed<>(outputType, input.getOps(), (T)input.getValue());
}
private interface SubFixer<F> {
Typed<F> fix(final Typed<?> input, final Type<F> outputType);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.writeAndReadTypedOrThrow()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ExtraDataFixUtils.chainAllFilters()
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置: