Paper/patches/server/0753-Add-player-health-update-API.patch
Nassim Jahnke 058d7c1aa3
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
13eb4146 SPIGOT-5217, SPIGOT-6183: Add RespawnReason to PlayerRespawnEvent

CraftBukkit Changes:
5ee3419b7 SPIGOT-5217, SPIGOT-6183: Add RespawnReason to PlayerRespawnEvent

Spigot Changes:
514cf03a Rebuild patches and add RespawnReason.PLUGIN to Player#respawn
2023-04-10 10:03:36 +02:00

38 lines
1.9 KiB
Diff

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 657b7d30c1f84dfad3af3eb0b94ad82591652316..ee85c2f718c01c91e8fd850f448f189d42687900 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2385,9 +2385,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 {
@@ -2396,6 +2398,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;