AbstractArrowPickupFix.java
net.minecraft.util.datafix.fixes.AbstractArrowPickupFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.AbstractArrowPickupFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/AbstractArrowPickupFix.java
- 起始行号:L12
- 继承:DataFix
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
public AbstractArrowPickupFix(Schema outputSchema) @ L13
- 构造器名:AbstractArrowPickupFix
- 源码定位:L13
- 修饰符:public
参数:
- outputSchema: Schema
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected TypeRewriteRule makeRule() @ L17
- 方法名:makeRule
- 源码定位:L17
- 返回类型:TypeRewriteRule
- 修饰符:protected
参数:
- 无
说明:
TODO
private Typed<?> updateProjectiles(Typed<?> input) @ L23
- 方法名:updateProjectiles
- 源码定位:L23
- 返回类型:Typed<?>
- 修饰符:private
参数:
- input: Typed<?>
说明:
TODO
private static Dynamic<?> updatePickup(Dynamic<?> tag) @ L29
- 方法名:updatePickup
- 源码定位:L29
- 返回类型:Dynamic<?>
- 修饰符:private static
参数:
- tag: Dynamic<?>
说明:
TODO
private Typed<?> updateEntity(Typed<?> input, String name, Function<Dynamic<?>,Dynamic<?>> function) @ L38
- 方法名:updateEntity
- 源码定位:L38
- 返回类型:Typed<?>
- 修饰符:private
参数:
- input: Typed<?>
- name: String
- function: Function<Dynamic,Dynamic>
说明:
TODO
代码
public class AbstractArrowPickupFix extends DataFix {
public AbstractArrowPickupFix(Schema outputSchema) {
super(outputSchema, false);
}
@Override
protected TypeRewriteRule makeRule() {
Schema inputSchema = this.getInputSchema();
return this.fixTypeEverywhereTyped("AbstractArrowPickupFix", inputSchema.getType(References.ENTITY), this::updateProjectiles);
}
private Typed<?> updateProjectiles(Typed<?> input) {
input = this.updateEntity(input, "minecraft:arrow", AbstractArrowPickupFix::updatePickup);
input = this.updateEntity(input, "minecraft:spectral_arrow", AbstractArrowPickupFix::updatePickup);
return this.updateEntity(input, "minecraft:trident", AbstractArrowPickupFix::updatePickup);
}
private static Dynamic<?> updatePickup(Dynamic<?> tag) {
if (tag.get("pickup").result().isPresent()) {
return tag;
} else {
boolean fromPlayer = tag.get("player").asBoolean(true);
return tag.set("pickup", tag.createByte((byte)(fromPlayer ? 1 : 0))).remove("player");
}
}
private Typed<?> updateEntity(Typed<?> input, String name, Function<Dynamic<?>, Dynamic<?>> function) {
Type<?> oldType = this.getInputSchema().getChoiceType(References.ENTITY, name);
Type<?> newType = this.getOutputSchema().getChoiceType(References.ENTITY, name);
return input.updateTyped(DSL.namedChoice(name, oldType), newType, entity -> entity.update(DSL.remainderFinder(), function));
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置: