diff options
author | ST-DDT <ST-DDT@gmx.de> | 2013-05-05 17:54:41 +0300 |
---|---|---|
committer | Nate Mortensen <nate.richard.mortensen@gmail.com> | 2013-06-13 16:53:35 -0600 |
commit | 93c0d7e6b55d5393794decfbf5c6367c80c2ab12 (patch) | |
tree | e098076741c22d10f423eba9a759749d978c21a4 /src/main/java/net/minecraft | |
parent | 045121d095bacebc92db8901d96c6dc48b4b4d8a (diff) | |
download | craftbukkit-93c0d7e6b55d5393794decfbf5c6367c80c2ab12.tar craftbukkit-93c0d7e6b55d5393794decfbf5c6367c80c2ab12.tar.gz craftbukkit-93c0d7e6b55d5393794decfbf5c6367c80c2ab12.tar.lz craftbukkit-93c0d7e6b55d5393794decfbf5c6367c80c2ab12.tar.xz craftbukkit-93c0d7e6b55d5393794decfbf5c6367c80c2ab12.zip |
Fix negative damage from Zombies. Fixes BUKKIT-4193
Currently, the method used for calculating the damage of zombies is scaled
to their health, but it uses the default max health rather than the real
max health value. If zombies have more health than the default max health
value, the amount of damage they deal becomes negative.
This is caused by EntityZombie.getMaxHealth() returning a hardcoded value of
20, which is the vanilla max health for zombies. Rather than using this value
when calculating zombie damage, the call is changed to instead use
((CraftLivingEntity) this.bukkitEntity).getMaxHealth(). This uses the true
maximum health of the Entity. "this.maxHealth" could be used instead of the
aforementioned method, however that creates a very unclear diff, and a
confusing change.
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityZombie.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index 8aa91038..352127d0 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.Calendar; //CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityCombustEvent; //CraftBukkit end @@ -154,7 +155,8 @@ public class EntityZombie extends EntityMonster { public int c(Entity entity) { ItemStack itemstack = this.bG(); - float f = (float) (this.getMaxHealth() - this.getHealth()) / (float) this.getMaxHealth(); + // CraftBukkit - getMaxHealth() -> ((CraftLivingEntity) this.bukkitEntity).getMaxHealth() + float f = (float) (((CraftLivingEntity) this.bukkitEntity).getMaxHealth() - this.getHealth()) / (float) ((CraftLivingEntity) this.bukkitEntity).getMaxHealth(); int i = 3 + MathHelper.d(f * 4.0F); if (itemstack != null) { |