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.
This commit is contained in:
ST-DDT 2013-05-05 17:54:41 +03:00 committed by Nate Mortensen
parent 045121d095
commit 93c0d7e6b5

View File

@ -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) {