mojira.dev
MC-62866

JSON Inheritance in Books Differs from /tellraw, /title, and Signs

NOTE: This is not a duplicate of MC-55373, which outlines specifics to inheritance. This report is exclusive to books, in which the outlined specifics to inheritance in the other report are not followed as they should be expected to.


I have confirmed that the following fix does work using 1.8 MCP:

@@unknown

The reason why this happens is because the public void drawScreen(int mouseX, int mouseY, float partialTicks) method of the net.minecraft.client.gui.GuiScreenBook class calls the method String getUnformattedText() of the net.minecraft.util.IChatComponent interface which results in "§lGood bye.". However instead it should call the String getFormattedText() method which would results in "§r§r§l§lGood§r bye.§r" (the correct text).


When using the following:

/give @a minecraft:written_book 1 0 {title:"Test",author:"Test",pages:["[\"\",{\"text\":\"Good\",\"bold\":true},\" bye.\"]"]}

Picture "book inherit" displays the result, in which both "Good" and "bye." are bold, while only "Good" is supposed be bold. Picture "sign inherit" shows the exact same JSON being used, which displays how inheritance should be expected.

This is displayed correctly for signs, /tellraw, and /title, but not for books. If the newline character (\n) is inserted before "bye.", the inheritance occurs as it should be expected to, shown in picture "book inherit 2":

/give @a minecraft:written_book 1 0 {title:"Test",author:"Test",pages:["[\"\",{\"text\":\"Good\",\"bold\":true},\"\\nbye.\"]"]}

This only occurs with formatting options, including: color, bold, italic, strikethrough, underlined, and obfuscated.

Linked issues

Attachments

Comments 6

Confirmed. Does this only pertain to the bold text though?

@qmagnet: appears to only inherit formatting options. clickEvents and hoverEvents are not transferred.

So affects color as well?

Yep.

Confirmed for:

  • 1.8.8 Seems to be a problem of how a book displays the text, the JSON structure is correct

JSON structure of first example

pages:[
	"{
		\"extra\":[
			{
				\"bold\":true,
				\"text\":\"Good\"
			},
			\" bye.\"
		],
		\"text\":\"\"
	}"
]

Note: The order of the elements should not matter, "Good" and " bye" should both inherit from ""

Please link to this comment in the description of the report.

The following is based on decompiled version of Minecraft 1.8 using MCP. All method and class names are the names used in the decompiled version.

The reason why this happens is because the public void drawScreen(int mouseX, int mouseY, float partialTicks) method of the net.minecraft.client.gui.GuiScreenBook class calls the method String getUnformattedText() of the net.minecraft.util.IChatComponent interface which results in "§lGood bye.". However instead it should call the String getFormattedText() method which would result in "§r§r§l§lGood§r bye.§r" (the correct text).

Skylinerw

(Unassigned)

Community Consensus

Minecraft 14w29b, Minecraft 14w30a, Minecraft 14w30b, Minecraft 14w30c, Minecraft 14w31a, ..., Minecraft 16w33a, Minecraft 1.11.2, Minecraft 1.12 Pre-Release 6, Minecraft 18w08b, Minecraft 18w11a

Minecraft 1.13.1

Retrieved