aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0807-Add-player-health-update-API.patch
blob: 24160f8b5ea2d3f84876990b3b87d98759f8f995 (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
38
39
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 415bcb2b53e943fefeaa58c49d901b029bfd2049..1c5be0cb22c568aee4fe6a13be591a123de100f5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2130,9 +2130,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 {
@@ -2140,7 +2142,13 @@ 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;