Rework max health values. Fixes BUKKIT-4398

This commit is contained in:
Wesley Wolfe
2013-07-02 12:34:40 -05:00
parent e79d26d7d7
commit 22adf8a3ce
12 changed files with 21 additions and 60 deletions

View File

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