Rework max health values. Fixes BUKKIT-4398

By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
CraftBukkit/Spigot 2013-07-02 12:34:40 -05:00
parent a578800a63
commit 4c2d673bd3

View file

@ -19,6 +19,7 @@ import net.minecraft.server.EntitySnowball;
import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityPotion; import net.minecraft.server.EntityPotion;
import net.minecraft.server.EntityWitherSkull; import net.minecraft.server.EntityWitherSkull;
import net.minecraft.server.GenericAttributes;
import net.minecraft.server.MobEffect; import net.minecraft.server.MobEffect;
import net.minecraft.server.MobEffectList; import net.minecraft.server.MobEffectList;
import net.minecraft.server.Packet42RemoveMobEffect; import net.minecraft.server.Packet42RemoveMobEffect;
@ -83,13 +84,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} }
public double getMaxHealth() { public double getMaxHealth() {
return getHandle().maxHealth; return getHandle().getMaxHealth();
} }
public void setMaxHealth(double amount) { public void setMaxHealth(double amount) {
Validate.isTrue(amount > 0, "Max health must be greater than 0"); Validate.isTrue(amount > 0, "Max health must be greater than 0");
getHandle().maxHealth = (float) amount; getHandle().a(GenericAttributes.a).a(amount);
if (getHealth() > amount) { if (getHealth() > amount) {
setHealth(amount); setHealth(amount);