Class BlockSignComponentBeta

Represents a block that can display text on it.

Hierarchy

Constructors

Properties

block: Block

Remarks

Block instance that this component pertains to.

isWaxed: boolean

Remarks

Whether or not players can edit the sign. This happens if a sign has had a honeycomb used on it or setWaxed was called on the sign.

Throws

This property can throw when used.

typeId: string

Remarks

Identifier of the component.

componentId: "minecraft:sign" = 'minecraft:sign'

Remarks

Identifier of this component. Should always be minecraft:sign.

Methods

  • Parameters

    • Optional side: SignSide

      The side of the sign to read the message from. If not provided, this will return the message from the front side of the sign.

    Returns undefined | RawText

    Remarks

    Returns the RawText of the sign if setText was called with a RawMessage or a RawText object, otherwise returns undefined.

    Throws

    This function can throw errors.

  • Parameters

    • Optional side: SignSide

      The side of the sign to read the message from. If not provided, this will return the message from the front side of the sign.

    Returns undefined | string

    Remarks

    Returns the text of the sign if setText was called with a string, otherwise returns undefined.

    Throws

    This function can throw errors.

  • Parameters

    • Optional side: SignSide

      The side of the sign to read the dye from. If not provided, this will return the dye on the front side of the sign.

    Returns undefined | DyeColor

    Remarks

    Gets the dye that is on the text or undefined if the sign has not been dyed.

    Throws

    This function can throw errors.

  • Parameters

    • message: string | RawText | RawMessage

      The message to set on the sign. If set to a string, then call getText to read that string. If set to a RawMessage, then calling getRawText will return a RawText. If set to a RawText, then calling getRawText will return the same object that was passed in.

    • Optional side: SignSide

      The side of the sign the message will be set on. If not provided, the message will be set on the front side of the sign.

    Returns void

    Remarks

    Sets the text of the sign component.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

    Example

    SetRawMessage.ts

    const helloWorldMessage: RawMessage = { text: 'Hello World' };
    sign.setText(helloWorldMessage);

    // Sign text will be saved as a RawText
    const result: RawText = sign.getRawText();
    JSON.stringify(result); // { rawtext: [{ text: 'Hello World' }] };

    Example

    SetRawText.ts

    const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] };
    sign.setText(helloWorldText);

    // There will be no data transformation unlike calling setText with a RawMessage
    const result: RawText = sign.getRawText();
    JSON.stringify(result); // { rawtext: [{ text: 'Hello World' }] };

    Example

    SetString.ts

    // Set sign to say 'Hello'
    sign.setText('Hello');
    sign.getText(); // 'Hello'
  • Parameters

    • Optional color: DyeColor

      The dye color to apply to the sign or undefined to clear the dye on the sign.

    • Optional side: SignSide

      The side of the sign the color will be set on. If not provided, the color will be set on the front side of the sign.

    Returns void

    Remarks

    Sets the dye color of the text.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.

  • Returns void

    Remarks

    Makes it so players cannot edit this sign.

    This function can't be called in read-only mode.

    Throws

    This function can throw errors.