mojira.dev
MCPE-228609

failed to get content of 'minecraft:book' component via SAPI

When the content of page contains text that may be regarded as an object (e.g. number only or {“name”:”string”}), the script won’t regard it as a string content but a rawMessage content (returns {})


Steps to reproduce

  1. Basically a writable book, a pack that is capable to use ItemBookComponent.contents/ItemBookComponent.rawContents API

  2. Input 1 in page 1 of the book. Input {“rawtext”:[{“text”:”1”}]} in page 2.

  3. Place the book in the first slot of hotbar. So that you may use player.getComponent(“minecraft:inventory”).container.getItem(0).getComponent(“minecraft:book”).contents OR use the pack down below.

Observed result

contents is [undefined,undefined], rawContents is [{},{text:”1”}]

Expected result

contents is [1,undefined], rawContents is [undefined,{text:”1”}]

Attachments

Comments 5

Your report does not have enough information to reproduce the issue.

Please include the following information to help us understand your problem:

Steps to Reproduce:
1. (Explain what needs to be done for the issue to happen)
2.
3.

Observed Results:
(Briefly describe what happens)

Expected Results:
(Briefly describe what should happen)

Refer to the Bug Tracker Guidelines for more information about how to write helpful bug reports. Bug reports with insufficient information may be closed as Incomplete.

This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

How to use the pack

  1. use “Debug”

    image-20260328-153753.png
  2. click “Editor Mode”

    image-20260328-153845.png
  3. click “Item”

    image-20260328-153927.png
  4. choose “Inventory” in the dropdown list, input “0” in the textfield, then submit

    image-20260328-154208.png
  5. the value of the slider named after “Write” refers to the number of page you want to check, then submit

    image-20260328-154458.png
  6. the first textfield is the content detected in this page. Please note, when getRawContent() returns {}, it is shown as {“rawtext”:[{}]} in the textField

    image-20260328-154737.png

the key code in line 678:

.textField({translate: "portfolioScreen.page", with: [String(pageNum)]}, {translate: "type:JSON"}, {defaultValue: book.getPageContent(pageNum-1)??`{"rawtext":[${JSON.stringify(book.getRawPageContent(pageNum-1)??{})}]}`})
[media]

mingwangdada

(Unassigned)

Unconfirmed

Multiple

1.21.130, 1.21.111, 26.3, 26.10, 26.11

Retrieved