Skip to content

Commit ddcb358

Browse files
committed
Fix respawning connecting to a server when dead.
1 parent d03506a commit ddcb358

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/utilities/connection/packetHandler.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,14 @@ export const packetHandler =
210210
.catch(handleError(addMessage, respawnError))
211211
} else if (packet.id === packetIds.CLIENTBOUND_UPDATE_HEALTH(version)) {
212212
const newHealth = packet.data.readFloatBE(0)
213-
if (healthRef.current != null && healthRef.current > newHealth) {
213+
// If you connect to a server when dead, you simply see your health as zero.
214+
if (healthRef.current === null && newHealth <= 0) {
215+
addMessage(deathRespawnMessage)
216+
const clientStatusId = packetIds.SERVERBOUND_CLIENT_STATUS(version) ?? 0
217+
connection // Client Status
218+
.writePacket(clientStatusId, writeVarInt(0))
219+
.catch(handleError(addMessage, respawnError))
220+
} else if (healthRef.current !== null && newHealth < healthRef.current) {
214221
const info = healthMessage
215222
.replace('%prev', healthRef.current.toString())
216223
.replace('%new', newHealth.toString())

0 commit comments

Comments
 (0)