From 93c0d7e6b55d5393794decfbf5c6367c80c2ab12 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sun, 5 May 2013 17:54:41 +0300 Subject: [PATCH] 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. --- src/main/java/net/minecraft/server/EntityZombie.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index 8aa910380a..352127d02f 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) {