Script API - v1.19.80
    Preparing search index...

    Represents a block that can display text on it.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    block: Block

    Block instance that this component pertains to.

    typeId: string
    componentId: "minecraft:sign" = 'minecraft:sign'

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

    Methods

    • Beta

      Returns undefined | RawText

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

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

      This function can throw errors.

    • Beta

      Returns undefined | string

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

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

      This function can throw errors.

    • Beta

      Returns undefined | DyeColor

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

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

      This function can throw errors.

    • Beta

      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.

      Returns void

      Sets the text of the sign component.

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

      This function can throw errors.

      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' }] };
      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' }] };
      // Set sign to say 'Hello'
      sign.setText('Hello');
      sign.getText(); // 'Hello'
    • Beta

      Parameters

      • Optionalcolor: DyeColor

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

      Returns void

      Sets the dye color of the text.

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

      This function can throw errors.