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

    Class ItemBookComponentBeta

    When present on an item, this item is a book item. Can access and modify the contents of the book and sign it.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    author?: string

    The name of the author of the book if it is signed, otherwise undefined.

    This property can throw when used.

    InvalidItemStackError

    contents: string[]

    The contents of pages in the book that are in string format. Entries not in string format will be undefined.

    This property can throw when used.

    InvalidItemStackError

    isSigned: boolean

    Determines whether the book has been signed or not.

    This property can throw when used.

    InvalidItemStackError

    isValid: boolean

    Returns whether the component is valid. A component is considered valid if its owner is valid, in addition to any addition to any additional validation required by the component.

    pageCount: number

    The amount of pages the book has.

    This property can throw when used.

    InvalidItemStackError

    rawContents: RawMessage[]

    The contents of pages in the book that are in RawMessage format. Entries not in RawMessage format will be undefined.

    This property can throw when used.

    InvalidItemStackError

    title?: string

    The title of the book if it is signed, otherwise undefined.

    This property can throw when used.

    InvalidItemStackError

    typeId: string

    Identifier of the component.

    componentId: "minecraft:book" = 'minecraft:book'

    Methods

    • Parameters

      • pageIndex: number

        The index of the page.

      Returns string

      The content of the page if a valid index is provided and it is in string format, otherwise returns undefined.

      Gets the string format content of a page for a given index.

      This function can throw errors.

      InvalidItemStackError

    • Parameters

      • pageIndex: number

        The index of the page.

      Returns RawMessage

      The content of the page if a valid index is provided and it is in RawMessage format, otherwise returns undefined.

      Gets the RawMessage format content of a page for a given index.

      This function can throw errors.

      InvalidItemStackError

    • Parameters

      • pageIndex: number

        The index of the page.

      • content: string | RawMessage | (string | RawMessage)[]

        The content to set for the page. Can be a single string or RawMessage or an array of strings and/or RawMessages

      Returns void

      Inserts a page at a given index. Empty pages will be created if the index is greater than the current book size. Pages have a maximum limit of 256 characters for strings as well as the JSON representation of a RawMessage. Books have a maximum limit of 50 pages.

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

      This function can throw errors.

      BookError

      BookPageContentError

      InvalidItemStackError

    • Parameters

      • pageIndex: number

        The index of the page.

      Returns void

      Removes a page at a given index. Existing pages following this page will be moved backward to fill the empty space.

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

      This function can throw errors.

      InvalidItemStackError

    • Parameters

      Returns void

      Sets the contents of the book's pages. Pre-existing pages will be cleared. Pages have a maximum limit of 256 characters for strings as well as the JSON representation of a RawMessage. Books have a maximum limit of 50 pages.

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

      This function can throw errors.

      BookError

      BookPageContentError

      InvalidItemStackError

    • Parameters

      • pageIndex: number

        The index of the page.

      • content: string | RawMessage | (string | RawMessage)[]

        The content to set for the page. Can be a single string or RawMessage or an array of strings and/or RawMessages

      Returns void

      Sets or creates the content of a specific page. Empty pages will be created if the index is greater than the current book size. Pages have a maximum limit of 256 characters for strings as well as the JSON representation of a RawMessage. Books have a maximum limit of 50 pages.

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

      This function can throw errors.

      BookError

      BookPageContentError

      InvalidItemStackError

    • Parameters

      • title: string

        The title to give the book.

      • author: string

        The name of the book's author.

      Returns void

      Signs a book giving it a title and author name. Once signed players can no longer directly edit the book. Titles have a maximum character limit of 16.

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

      This function can throw errors.

      BookError

      InvalidEntityError

      InvalidItemStackError