aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0754-Add-player-health-update-API.patch
blob: 6d91fc4c0f088dadfba87f37f7e75939e62bc05e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: SamB440 <sam@islandearth.net>
Date: Wed, 17 Nov 2021 12:31:42 +0000
Subject: [PATCH] Add player health update API


diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index e5a9d5862461f2458987eecf05ea9a395afe368c..64c2026a5b4231434bb750bdf95a7751942cd701 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2347,9 +2347,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
         this.getHandle().maxHealthCache = getMaxHealth();
     }
 
-    public void sendHealthUpdate() {
+    // Paper start
+    @Override
+    public void sendHealthUpdate(final double health, final int foodLevel, final float saturationLevel) {
         // Paper start - cancellable death event
-        ClientboundSetHealthPacket packet = new ClientboundSetHealthPacket(this.getScaledHealth(), this.getHandle().getFoodData().getFoodLevel(), this.getHandle().getFoodData().getSaturationLevel());
+        ClientboundSetHealthPacket packet = new ClientboundSetHealthPacket((float) health, foodLevel, saturationLevel);
         if (this.getHandle().queueHealthUpdatePacket) {
             this.getHandle().queuedHealthUpdatePacket = packet;
         } else {
@@ -2358,6 +2360,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
         // Paper end
     }
 
+    @Override
+    public void sendHealthUpdate() {
+        this.sendHealthUpdate(this.getScaledHealth(), this.getHandle().getFoodData().getFoodLevel(), this.getHandle().getFoodData().getSaturationLevel());
+    }
+    // Paper end
+
     public void injectScaledMaxHealth(Collection<AttributeInstance> collection, boolean force) {
         if (!this.scaledHealth && !force) {
             return;