EntityHealthFix.java
net.minecraft.util.datafix.fixes.EntityHealthFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.EntityHealthFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/EntityHealthFix.java
- 起始行号:L12
- 继承:DataFix
- 职责:
TODO
字段/常量
ENTITIES- 类型:
Set<String> - 修饰符:
private static final - 源码定位:
L13 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public EntityHealthFix(Schema outputSchema, boolean changesType) @ L50
- 构造器名:EntityHealthFix
- 源码定位:L50
- 修饰符:public
参数:
- outputSchema: Schema
- changesType: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public Dynamic<?> fixTag(Dynamic<?> input) @ L54
- 方法名:fixTag
- 源码定位:L54
- 返回类型:Dynamic<?>
- 修饰符:public
参数:
- input: Dynamic<?>
说明:
TODO
public TypeRewriteRule makeRule() @ L72
- 方法名:makeRule
- 源码定位:L72
- 返回类型:TypeRewriteRule
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class EntityHealthFix extends DataFix {
private static final Set<String> ENTITIES = Sets.newHashSet(
"ArmorStand",
"Bat",
"Blaze",
"CaveSpider",
"Chicken",
"Cow",
"Creeper",
"EnderDragon",
"Enderman",
"Endermite",
"EntityHorse",
"Ghast",
"Giant",
"Guardian",
"LavaSlime",
"MushroomCow",
"Ozelot",
"Pig",
"PigZombie",
"Rabbit",
"Sheep",
"Shulker",
"Silverfish",
"Skeleton",
"Slime",
"SnowMan",
"Spider",
"Squid",
"Villager",
"VillagerGolem",
"Witch",
"WitherBoss",
"Wolf",
"Zombie"
);
public EntityHealthFix(Schema outputSchema, boolean changesType) {
super(outputSchema, changesType);
}
public Dynamic<?> fixTag(Dynamic<?> input) {
Optional<Number> oldHealF = input.get("HealF").asNumber().result();
Optional<Number> oldHealth = input.get("Health").asNumber().result();
float health;
if (oldHealF.isPresent()) {
health = oldHealF.get().floatValue();
input = input.remove("HealF");
} else {
if (!oldHealth.isPresent()) {
return input;
}
health = oldHealth.get().floatValue();
}
return input.set("Health", input.createFloat(health));
}
@Override
public TypeRewriteRule makeRule() {
return this.fixTypeEverywhereTyped(
"EntityHealthFix", this.getInputSchema().getType(References.ENTITY), input -> input.update(DSL.remainderFinder(), this::fixTag)
);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置: