SPIGOT-3813: Player.setHealth not reliable in conjunction with attribute API

This commit is contained in:
md_5 2018-02-12 08:59:32 +11:00
parent 49ecc7c7a2
commit 8bb4f6ccc1
2 changed files with 6 additions and 3 deletions

View File

@ -257,7 +257,7 @@
+ player.setRealHealth(f);
+ }
+
+ this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(player.getScaledHealth()));
+ player.updateScaledHealth();
+ return;
+ }
+ // CraftBukkit end

View File

@ -1382,9 +1382,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
injectScaledMaxHealth(set, true);
// SPIGOT-3813: Attributes before health
if (getHandle().playerConnection != null) {
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set));
sendHealthUpdate();
}
getHandle().getDataWatcher().set(EntityLiving.HEALTH, (float) getScaledHealth());
sendHealthUpdate();
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set));
getHandle().maxHealthCache = getMaxHealth();
}