Skip to content

@minecraft/server


@minecraft/server / TextPrimitive

Class: TextPrimitive ​

Defined in: @minecraft/server/index.d.ts:20706

A primitive shape class that represents a text label in the world with a background.

Extends ​

Constructors ​

Constructor ​

new TextPrimitive(location, text): TextPrimitive

Defined in: @minecraft/server/index.d.ts:20753

Parameters ​

location ​

Vector3 | DimensionLocation

text ​

string | RawMessage

Returns ​

TextPrimitive

Overrides ​

PrimitiveShape.constructor

Properties ​

attachedTo? ​

optional attachedTo?: Entity

Defined in: @minecraft/server/index.d.ts:18559

Remarks ​

The entity this shape is attached to. When set, this shape will copy the root location of the attached entity and the shape's position will be used as an offset.

Inherited from ​

PrimitiveShape.attachedTo


backfaceVisible ​

backfaceVisible: boolean

Defined in: @minecraft/server/index.d.ts:20714

Remarks ​

If set to true, the text primitive will render the back-face of the background. Defaults to true but will always be false if 'useRotation' is set to false.


backgroundColorOverride? ​

optional backgroundColorOverride?: RGBA

Defined in: @minecraft/server/index.d.ts:20721

Remarks ​

The color of the background plate of the text. If set to undefined, it will use the default color.


color ​

color: RGBA

Defined in: @minecraft/server/index.d.ts:18565

Remarks ​

The color of the shape.

Inherited from ​

PrimitiveShape.color


depthTest ​

depthTest: boolean

Defined in: @minecraft/server/index.d.ts:20729

Remarks ​

If set to true, the text will be hidden behind blocks or entities. By default this is set to false (will always render).


dimension ​

readonly dimension: Dimension

Defined in: @minecraft/server/index.d.ts:18572

Remarks ​

The dimension the shape is visible within. If the dimension is undefined, it will display in all dimensions.

Inherited from ​

PrimitiveShape.dimension


hasDuration ​

readonly hasDuration: boolean

Defined in: @minecraft/server/index.d.ts:18579

Remarks ​

Returns true if the shape has a limited time span before being removed.

Inherited from ​

PrimitiveShape.hasDuration


location ​

readonly location: Vector3

Defined in: @minecraft/server/index.d.ts:18585

Remarks ​

The location of the shape.

Inherited from ​

PrimitiveShape.location


maximumRenderDistance? ​

optional maximumRenderDistance?: number

Defined in: @minecraft/server/index.d.ts:18595

Remarks ​

If defined, this distance will be used to determine how far away this primitive will be rendered for each client. By default the distance will match the client's render distance setting.

Minimum Value: 0

Inherited from ​

PrimitiveShape.maximumRenderDistance


rotation ​

rotation: Vector3

Defined in: @minecraft/server/index.d.ts:18602

Remarks ​

The rotation of the shape (Euler angles - [Pitch, Yaw, Roll]).

Inherited from ​

PrimitiveShape.rotation


scale ​

scale: number

Defined in: @minecraft/server/index.d.ts:18609

Remarks ​

The scale of the shape.

Bounds: [-1000, 1000]

Inherited from ​

PrimitiveShape.scale


text ​

readonly text: string | RawMessage

Defined in: @minecraft/server/index.d.ts:20737

Remarks ​

Get the text of the debug text shape. Returns the RawText of the debug text if setText was called with a RawMessage or a RawText object, otherwise returns a string.


textBackfaceVisible ​

textBackfaceVisible: boolean

Defined in: @minecraft/server/index.d.ts:20745

Remarks ​

If set to true, the text primitive will render the back-face of the text. Defaults to true but will always be false if 'useRotation' is set to false.


timeLeft? ​

optional timeLeft?: number

Defined in: @minecraft/server/index.d.ts:18617

Remarks ​

The time left (in seconds) until this shape is automatically removed. Returns undefined if the shape does not have a limited life-span.

Inherited from ​

PrimitiveShape.timeLeft


totalTimeLeft? ​

readonly optional totalTimeLeft?: number

Defined in: @minecraft/server/index.d.ts:18625

Remarks ​

The total initial time-span (in seconds) until this shape is automatically removed. Returns undefined if the shape does not have a limited life-span.

Inherited from ​

PrimitiveShape.totalTimeLeft


useRotation ​

useRotation: boolean

Defined in: @minecraft/server/index.d.ts:20752

Remarks ​

If set to true, the text will not face the camera and instead will use the rotation from the shape.


visibleTo ​

visibleTo: Player[]

Defined in: @minecraft/server/index.d.ts:18632

Remarks ​

The list of players that this shape will be visible to. If left empty, the shape will be visible to all players.

Inherited from ​

PrimitiveShape.visibleTo

Methods ​

remove() ​

remove(): void

Defined in: @minecraft/server/index.d.ts:18639

Returns ​

void

Remarks ​

Removes this shape from the world. The shape can be re-added via the PrimitiveShapesManager's addText method.

Inherited from ​

PrimitiveShape.remove


setLocation() ​

setLocation(location): void

Defined in: @minecraft/server/index.d.ts:18646

Parameters ​

location ​

Vector3 | DimensionLocation

Returns ​

void

Remarks ​

Set the location and dimension of the shape. If the dimension is undefined, it will display in all dimensions.

Inherited from ​

PrimitiveShape.setLocation


setText() ​

setText(text): void

Defined in: @minecraft/server/index.d.ts:20764

Parameters ​

text ​

string | RawMessage

Returns ​

void

Remarks ​

Sets the text to display.

Throws ​

This function can throw errors.

minecraftcommon.ArgumentOutOfBoundsError

RawMessageError