Set Objective
Play 0x6A, server → client.
play · 0x6A · clientbound (server → client)
Creates, removes, or updates a scoreboard objective. action 0 creates, 1 removes, 2 updates display text, render type and default number format. The server sends it when objectives change; the client stores objectives for use in SetScore and SetDisplayObjective.
Sent by the server, read by the client. Listen for it with client.on("SetObjective", (data) => …) on the receiving side.
Fields
| Field | Type | Notes |
|---|---|---|
name |
String | Objective name, up to 16 characters. |
action |
Byte | 0 create, 1 remove, 2 update. |
displayText |
NBT | Only when action is 0 or 2. Text component. |
type |
VarInt | Only when action is 0 or 2. 0 integer, 1 hearts. also subscriptionType |
number_format |
VarInt | Only when action is 0 or 2. Optional: omit for the default format; 0 blank, 1 styled, 2 fixed. |
styling |
NBT | Only when action is 0 or 2 and number_format is 1 (style compound) or 2 (text component). Omitted otherwise. |
Send it
await client.sendPacket("SetObjective", {
name: /* String */,
action: /* Byte */,
displayText: /* NBT */,
type: /* VarInt */,
number_format: /* VarInt */,
styling: /* NBT */,
});
Field aliases listed under Notes are accepted as alternative keys when writing.
Source: src/Core/Versions/776/Packets/play/clientbound/SetObjective.ts