52 lines
2.1 KiB
Java
52 lines
2.1 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.google.common.collect.Sets
|
|
* com.mojang.datafixers.DSL
|
|
* com.mojang.datafixers.DataFix
|
|
* com.mojang.datafixers.TypeRewriteRule
|
|
* com.mojang.datafixers.schemas.Schema
|
|
* com.mojang.serialization.Dynamic
|
|
*/
|
|
package net.minecraft.util.datafix.fixes;
|
|
|
|
import com.google.common.collect.Sets;
|
|
import com.mojang.datafixers.DSL;
|
|
import com.mojang.datafixers.DataFix;
|
|
import com.mojang.datafixers.TypeRewriteRule;
|
|
import com.mojang.datafixers.schemas.Schema;
|
|
import com.mojang.serialization.Dynamic;
|
|
import java.util.Optional;
|
|
import java.util.Set;
|
|
import net.minecraft.util.datafix.fixes.References;
|
|
|
|
public class EntityHealthFix
|
|
extends DataFix {
|
|
private static final Set<String> ENTITIES = Sets.newHashSet((Object[])new String[]{"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) {
|
|
float health;
|
|
Optional oldHealF = input.get("HealF").asNumber().result();
|
|
Optional oldHealth = input.get("Health").asNumber().result();
|
|
if (oldHealF.isPresent()) {
|
|
health = ((Number)oldHealF.get()).floatValue();
|
|
input = input.remove("HealF");
|
|
} else if (oldHealth.isPresent()) {
|
|
health = ((Number)oldHealth.get()).floatValue();
|
|
} else {
|
|
return input;
|
|
}
|
|
return input.set("Health", input.createFloat(health));
|
|
}
|
|
|
|
public TypeRewriteRule makeRule() {
|
|
return this.fixTypeEverywhereTyped("EntityHealthFix", this.getInputSchema().getType(References.ENTITY), input -> input.update(DSL.remainderFinder(), this::fixTag));
|
|
}
|
|
}
|
|
|