2021-12-04 15:10:57 +01:00
|
|
|
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
|
2023-04-14 01:52:42 +02:00
|
|
|
index 855b20e198983470b83ebbb38ebe5cba580cecd6..9329bd7ace628fef7734fbae263a9bc1a4faa8c4 100644
|
2021-12-04 15:10:57 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2023-04-14 01:52:42 +02:00
|
|
|
@@ -2384,9 +2384,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-12-04 15:10:57 +01:00
|
|
|
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 {
|
2023-04-14 01:52:42 +02:00
|
|
|
@@ -2395,6 +2397,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-12-04 15:10:57 +01:00
|
|
|
// Paper end
|
|
|
|
}
|
2023-03-14 23:13:41 +01:00
|
|
|
|
2021-12-04 15:10:57 +01:00
|
|
|
+ @Override
|
|
|
|
+ public void sendHealthUpdate() {
|
|
|
|
+ this.sendHealthUpdate(this.getScaledHealth(), this.getHandle().getFoodData().getFoodLevel(), this.getHandle().getFoodData().getSaturationLevel());
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2023-03-14 23:13:41 +01:00
|
|
|
+
|
2021-12-04 15:10:57 +01:00
|
|
|
public void injectScaledMaxHealth(Collection<AttributeInstance> collection, boolean force) {
|
|
|
|
if (!this.scaledHealth && !force) {
|
|
|
|
return;
|