summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2013-07-02 23:08:55 -0500
committerWesley Wolfe <weswolf@aol.com>2013-07-02 23:09:43 -0500
commitadcb293a036c88a4977f05bb5ff4e0d91b8ec9d1 (patch)
tree8ace7f0e6f5c8a0bd04560b0dc95213c2350b7f1 /src
parente1a3fb56b5f6df7cde5a8c5933d017aa9d8de07c (diff)
downloadcraftbukkit-adcb293a036c88a4977f05bb5ff4e0d91b8ec9d1.tar
craftbukkit-adcb293a036c88a4977f05bb5ff4e0d91b8ec9d1.tar.gz
craftbukkit-adcb293a036c88a4977f05bb5ff4e0d91b8ec9d1.tar.lz
craftbukkit-adcb293a036c88a4977f05bb5ff4e0d91b8ec9d1.tar.xz
craftbukkit-adcb293a036c88a4977f05bb5ff4e0d91b8ec9d1.zip
Fix scaling for player health. Fixes BUKKIT-4431
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayer.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java13
2 files changed, 15 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 69a76792..b38aa108 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -233,8 +233,8 @@ 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 - this.getHealth() -> this.getScaledHealth() - Magic number 20 -> original max health
- this.playerConnection.sendPacket(new Packet8UpdateHealth((float) (this.getHealth() * this.getMaxHealth() / 20.0D), this.foodData.a(), this.foodData.e()));
+ // CraftBukkit - Optionally scale health
+ this.playerConnection.sendPacket(new Packet8UpdateHealth(getBukkitEntity().getScaledHealth(), this.foodData.a(), this.foodData.e()));
this.bP = this.getHealth();
this.bQ = this.foodData.a();
this.bR = this.foodData.e() == 0.0F;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 583b99c9..977adff6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -61,6 +61,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private final Set<String> channels = new HashSet<String>();
private final Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap();
private int hash = 0;
+ private boolean scaledHealth;
public CraftPlayer(CraftServer server, EntityPlayer entity) {
super(server, entity);
@@ -997,4 +998,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.server.getScoreboardManager().setPlayerBoard(this, scoreboard);
}
+
+ public float getScaledHealth() {
+ return (float) (this.scaledHealth ? getHealth() / getMaxHealth() * 20.0D : getHealth());
+ }
+
+ public void setScaleHealth(boolean scale) {
+ this.scaledHealth = scale;
+ }
+
+ public boolean isScaledHealth() {
+ return this.scaledHealth;
+ }
}