diff options
author | T00thpick1 <t00thpick1dirko@gmail.com> | 2013-07-23 21:30:38 -0500 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2013-07-23 21:52:17 -0500 |
commit | 1192f2a53a20354e7d2292a1c710d6bfe779b600 (patch) | |
tree | 0a543ad3c73860cd3b5ccec64e429c85ca2bdd41 /src/main/java/net/minecraft/server/EntityPlayer.java | |
parent | 4ad3cdd4b5cfe90f319cfba6c4dabc9bff10a59d (diff) | |
download | craftbukkit-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/EntityPlayer.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityPlayer.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 955b75c3..58e52179 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -51,6 +51,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public int newLevel = 0; public int newTotalExp = 0; public boolean keepLevel = false; + public double maxHealthCache; // CraftBukkit end public EntityPlayer(MinecraftServer minecraftserver, World world, String s, PlayerInteractManager playerinteractmanager) { @@ -84,6 +85,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.displayName = this.name; this.listName = this.name; // this.canPickUpLoot = true; TODO + this.maxHealthCache = this.getMaxHealth(); // CraftBukkit end } @@ -234,7 +236,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (this.getHealth() != this.bP || this.bQ != this.foodData.a() || this.foodData.e() == 0.0F != this.bR) { // CraftBukkit - Optionally scale health - this.playerConnection.sendPacket(new Packet8UpdateHealth(getBukkitEntity().getScaledHealth(), this.foodData.a(), this.foodData.e())); + this.playerConnection.sendPacket(new Packet8UpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.a(), this.foodData.e())); this.bP = this.getHealth(); this.bQ = this.foodData.a(); this.bR = this.foodData.e() == 0.0F; @@ -246,6 +248,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.f, this.getLocalizedName(), com.google.common.collect.ImmutableList.of(this)); } + // CraftBukkit start - Force max health updates + if (this.maxHealthCache != this.getMaxHealth()) { + this.getBukkitEntity().updateScaledHealth(); + } + // CraftBukkit end + if (this.expTotal != this.lastSentExp) { this.lastSentExp = this.expTotal; this.playerConnection.sendPacket(new Packet43SetExperience(this.exp, this.expTotal, this.expLevel)); |