Send all attributes on respawn (#12274)

This commit is contained in:
Tamion
2025-03-13 12:41:03 +01:00
committed by GitHub
parent 310f52293b
commit 6ea42025a4
2 changed files with 13 additions and 8 deletions

View File

@@ -931,13 +931,18 @@
}
player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F));
@@ -671,8 +_,16 @@
@@ -671,8 +_,21 @@
public void sendAllPlayerInfo(ServerPlayer player) {
player.inventoryMenu.sendAllDataToRemote();
- player.resetSentInfo();
+ // entityplayer.resetSentInfo();
+ player.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange
+ // Paper start - send all attributes
+ // needs to be done because the ServerPlayer instance is being reused on respawn instead of getting replaced like on vanilla
+ java.util.Collection<net.minecraft.world.entity.ai.attributes.AttributeInstance> syncableAttributes = player.getAttributes().getSyncableAttributes();
+ player.getBukkitEntity().injectScaledMaxHealth(syncableAttributes, true);
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket(player.getId(), syncableAttributes));
+ // Paper end - send all attributes
+ player.refreshEntityData(player); // CraftBukkit - SPIGOT-7218: sync metadata
player.connection.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected));
+ // CraftBukkit start - from GameRules