From 1192f2a53a20354e7d2292a1c710d6bfe779b600 Mon Sep 17 00:00:00 2001 From: T00thpick1 Date: Tue, 23 Jul 2013 21:30:38 -0500 Subject: Add API to control scaled health. Adds BUKKIT-4590 This commit implements the ability to set the scale of hearts that the client renders. When the Packet44UpdateAttributes packet is sent, the max health attribute is replaced with a scaled version, to preserve the scaled health illusion clientside. In order to accurately display the scaled health for players, a true health is stored within CraftPlayer, and the datawatcher now stores the scaled health. The getHealth() method for players still returns their true health. Changed setHealth() within EntityLiving to appropriately handle health for instances of EntityPlayer. Inlined a call to setHealth(getMaxHealth()) within the EntityLiving constructor to work around CraftEntity instantiation. Additionally fixes the health values sent when eating food within FoodMetaData and ItemFood, which previously sent the unscaled health; this commit alters them to send the properly scaled health. Additionally fixes BUKKIT-4535, BUKKIT-4536, and BUKKIT-4127 --- src/main/java/net/minecraft/server/ItemFood.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/net/minecraft/server/ItemFood.java') diff --git a/src/main/java/net/minecraft/server/ItemFood.java b/src/main/java/net/minecraft/server/ItemFood.java index c0274094..78bbb59b 100644 --- a/src/main/java/net/minecraft/server/ItemFood.java +++ b/src/main/java/net/minecraft/server/ItemFood.java @@ -36,7 +36,7 @@ public class ItemFood extends Item { entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, this.getSaturationModifier()); } - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new Packet8UpdateHealth(entityhuman.getHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new Packet8UpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); // CraftBukkit end world.makeSound(entityhuman, "random.burp", 0.5F, world.random.nextFloat() * 0.1F + 0.9F); -- cgit v1.2.3