mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 20:30:28 +01:00
Fix scaling for player health. Fixes BUKKIT-4431
This commit is contained in:
parent
e1a3fb56b5
commit
adcb293a03
@ -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) {
|
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
|
// CraftBukkit - Optionally scale health
|
||||||
this.playerConnection.sendPacket(new Packet8UpdateHealth((float) (this.getHealth() * this.getMaxHealth() / 20.0D), this.foodData.a(), this.foodData.e()));
|
this.playerConnection.sendPacket(new Packet8UpdateHealth(getBukkitEntity().getScaledHealth(), this.foodData.a(), this.foodData.e()));
|
||||||
this.bP = this.getHealth();
|
this.bP = this.getHealth();
|
||||||
this.bQ = this.foodData.a();
|
this.bQ = this.foodData.a();
|
||||||
this.bR = this.foodData.e() == 0.0F;
|
this.bR = this.foodData.e() == 0.0F;
|
||||||
|
@ -61,6 +61,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
private final Set<String> channels = new HashSet<String>();
|
private final Set<String> channels = new HashSet<String>();
|
||||||
private final Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap();
|
private final Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap();
|
||||||
private int hash = 0;
|
private int hash = 0;
|
||||||
|
private boolean scaledHealth;
|
||||||
|
|
||||||
public CraftPlayer(CraftServer server, EntityPlayer entity) {
|
public CraftPlayer(CraftServer server, EntityPlayer entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
@ -997,4 +998,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
|
|
||||||
this.server.getScoreboardManager().setPlayerBoard(this, scoreboard);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user