Update maxhealth for entities that have variable max health. Fixes BUKKIT-3308

Slimes and wolves have health that can change based on certain
conditions. So we check if their max health should be updated, and if
it has been customized in any way.

We also scale the wolf's health for their tail
This commit is contained in:
feildmaster
2012-12-26 19:07:47 -06:00
parent b908c192bf
commit 509e3d2a32
3 changed files with 27 additions and 4 deletions

View File

@@ -1155,6 +1155,16 @@ public abstract class Entity {
this.b(this.yaw, this.pitch);
this.a(nbttagcompound);
// CraftBukkit start
if (this instanceof EntityLiving) {
EntityLiving entity = (EntityLiving) this;
// If the entity does not have a max health set yet, update it (it may have changed after loading the entity)
if (!nbttagcompound.hasKey("Bukkit.MaxHealth")) {
entity.maxHealth = entity.getMaxHealth();
}
}
// CraftBukkit end
// CraftBukkit start - exempt Vehicles from notch's sanity check
if (!(this.getBukkitEntity() instanceof Vehicle)) {
if (Math.abs(this.motX) > 10.0D) {