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

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

No files matched your search

@@ -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();
}