From ffdc63259ad30022e76c97a9fc9bfcff56583603 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 27 Jun 2023 07:36:06 +1000 Subject: [PATCH] #1220: Add Player#sendHealthUpdate() By: Parker Hawke --- .../org/bukkit/craftbukkit/entity/CraftPlayer.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 9bace5f289..3dfcd56766 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -83,6 +83,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeMapBase; import net.minecraft.world.entity.ai.attributes.AttributeModifiable; import net.minecraft.world.entity.ai.attributes.GenericAttributes; import net.minecraft.world.entity.player.EntityHuman; +import net.minecraft.world.food.FoodMetaData; import net.minecraft.world.inventory.Container; import net.minecraft.world.item.EnumColor; import net.minecraft.world.level.EnumGamemode; @@ -1885,8 +1886,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().maxHealthCache = getMaxHealth(); } + @Override + public void sendHealthUpdate(double health, int foodLevel, float saturation) { + getHandle().connection.send(new PacketPlayOutUpdateHealth((float) health, foodLevel, saturation)); + } + + @Override public void sendHealthUpdate() { - getHandle().connection.send(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel())); + FoodMetaData foodData = getHandle().getFoodData(); + sendHealthUpdate(getScaledHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel()); } public void injectScaledMaxHealth(Collection collection, boolean force) {