Nametags
constNametags:object
Defined in: client/api.d.ts:5391
The local player’s view of the nametags above players: whether they draw at all, whether they carry a health bar, and whether their own is shown.
Type Declaration
Section titled “Type Declaration”clearLabel()
Section titled “clearLabel()”clearLabel(
entityId):void
Removes an entity’s label before its duration elapses.
Parameters
Section titled “Parameters”entityId
Section titled “entityId”number
Network id of the entity whose label to remove.
Returns
Section titled “Returns”void
clearLabels()
Section titled “clearLabels()”clearLabels():
void
Removes every label this player is drawing.
Returns
Section titled “Returns”void
isHealthVisible()
Section titled “isHealthVisible()”isHealthVisible():
boolean
Checks whether this player draws health bars on nametags.
Returns
Section titled “Returns”boolean
True unless they were hidden locally.
isSelfVisible()
Section titled “isSelfVisible()”isSelfVisible():
boolean
Checks whether this player draws their own nametag.
Returns
Section titled “Returns”boolean
False unless it was turned on locally.
isVisible()
Section titled “isVisible()”isVisible():
boolean
Checks whether this player draws nametags.
Returns
Section titled “Returns”boolean
True unless they were hidden locally.
setHealthVisible()
Section titled “setHealthVisible()”setHealthVisible(
visible):void
Shows or hides the health bar on all nametags for this player only, leaving the names alone.
Parameters
Section titled “Parameters”visible
Section titled “visible”boolean
True to draw the health bar under each name, false to hide it.
Returns
Section titled “Returns”void
setLabel()
Section titled “setLabel()”setLabel(
entityId,text,durationMs?,color?):void
Hangs a transient line on that entity’s nametag, above its name – speech, an emote, a status. It follows the body, fades with distance and hides behind cover exactly as the name does. Local to this player: the line is not replicated, and a nametag hidden with Nametags.setVisible draws neither. Player.setNametagText is the server-side counterpart for a lasting name.
Parameters
Section titled “Parameters”entityId
Section titled “entityId”number
Network id of the entity to label (server-side player.id).
string
Label text; ‘\n’ splits lines. Empty clears the label.
durationMs?
Section titled “durationMs?”number
How long to hold it (default 6000). <= 0 holds until cleared.
color?
Section titled “color?”number
Packed 0xAARRGGBB; 0 (default) uses the nametag’s own colour.
Returns
Section titled “Returns”void
setSelfVisible()
Section titled “setSelfVisible()”setSelfVisible(
visible):void
Shows or hides this player’s own nametag, drawn as others see it, with any label set on their own id.
Parameters
Section titled “Parameters”visible
Section titled “visible”boolean
True to draw this player’s own nametag, false (default) to leave it off.
Returns
Section titled “Returns”void
setVisible()
Section titled “setVisible()”setVisible(
visible):void
Shows or hides all nametags for this player only. A player hidden with Player.setNametagVisible stays hidden either way.
Parameters
Section titled “Parameters”visible
Section titled “visible”boolean
True to draw nametags, false to hide every one of them.
Returns
Section titled “Returns”void