Skip to content
mc-protocol
Esc
↑↓navigate↵open⌘Jpreview
On this page

Set Health

Play 0x68, server → client.

play · 0x68 · clientbound (server → client)

Sets the player’s health, food level and saturation. The server sends it when any of them change. A health of 0 or less makes the client show the death screen.

Sent by the server, read by the client. Listen for it with client.on("SetHealth", (data) => …) on the receiving side.

Fields

Field Type Notes
health Float
food VarInt
foodSaturation Float

Send it

await client.sendPacket("SetHealth", { health: 20, food: 20, foodSaturation: 5 });

// Kill the player: health 0 shows the death screen.
await client.sendPacket("SetHealth", { health: 0, food: 20, foodSaturation: 0 });

health runs from 0 to 20 for ten hearts; food from 0 to 20. The client plays the hurt animation when health drops. Values above 20 need the max_health attribute via UpdateAttributes.

Field aliases listed under Notes are accepted as alternative keys when writing.

Source: src/Core/Versions/776/Packets/play/clientbound/SetHealth.ts

Was this page helpful?