summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityTrackerEntry.java
diff options
context:
space:
mode:
authorT00thpick1 <t00thpick1dirko@gmail.com>2013-07-23 21:30:38 -0500
committerWesley Wolfe <weswolf@aol.com>2013-07-23 21:52:17 -0500
commit1192f2a53a20354e7d2292a1c710d6bfe779b600 (patch)
tree0a543ad3c73860cd3b5ccec64e429c85ca2bdd41 /src/main/java/net/minecraft/server/EntityTrackerEntry.java
parent4ad3cdd4b5cfe90f319cfba6c4dabc9bff10a59d (diff)
downloadcraftbukkit-1192f2a53a20354e7d2292a1c710d6bfe779b600.tar
craftbukkit-1192f2a53a20354e7d2292a1c710d6bfe779b600.tar.gz
craftbukkit-1192f2a53a20354e7d2292a1c710d6bfe779b600.tar.lz
craftbukkit-1192f2a53a20354e7d2292a1c710d6bfe779b600.tar.xz
craftbukkit-1192f2a53a20354e7d2292a1c710d6bfe779b600.zip
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
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityTrackerEntry.java')
-rw-r--r--src/main/java/net/minecraft/server/EntityTrackerEntry.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index 673c2042..e05296c7 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -250,6 +250,11 @@ public class EntityTrackerEntry {
Set set = attributemapserver.b();
if (!set.isEmpty()) {
+ // CraftBukkit start - Send scaled max health
+ if (this.tracker instanceof EntityPlayer) {
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(set, false);
+ }
+ // CraftBukkit end
this.broadcastIncludingSelf(new Packet44UpdateAttributes(this.tracker.id, set));
}
@@ -321,6 +326,11 @@ public class EntityTrackerEntry {
AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).aW();
Collection collection = attributemapserver.c();
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
+ if (this.tracker.id == entityplayer.id) {
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(collection, false);
+ }
+ // CraftBukkit end
if (!collection.isEmpty()) {
entityplayer.playerConnection.sendPacket(new Packet44UpdateAttributes(this.tracker.id, collection));
}