mojira.dev
MC-83469

Formatting in book and quill is different after signing

The bug

If you continue typing past the end of a line, (and the text wraps) the next line will still have the formatting from the previous line (this is normal), but when you sign the book, the formatting codes won't affect the new line anymore, and the text will look different.

Paste for example this text: §6TestTestTestTestTestTestTest

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 10

Might relate to MC-62866

Incorrect duplicate link

Confirmed for:

  • 15w34d Paste for example this text: §6TestTestTestTestTestTestTest

Confirmed for

  • 15w50a

Can you please reopen the report

[Mod] redstonehelper

Whoops 😃

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 while editing the text the public void drawSplitString(String str, int x, int y, int wrapWidth, int textColor) method of the net.minecraft.client.gui.FontRenderer class. This method respects the formatting character ("§"). However when the when the book is signed a net.minecraft.util.ChatComponentText.ChatComponentText is created containing the text. This means the chat component itself does not know anything about the formatted text it contains.
When the signed book is rendered, the public static List func_178908_a(IChatComponent p_178908_0_, int p_178908_1_, FontRenderer p_178908_2_, boolean p_178908_3_, boolean p_178908_4_) method of the net.minecraft.client.gui.GuiUtilRenderComponents class is used. This class only respects the style settings the chat component has.

To fix this the public void drawSplitString(String str, int x, int y, int wrapWidth, int textColor) method could be used all the time, or the text of the unsigned book needs to be properly parsed and converted to a net.minecraft.util.ChatComponentText.ChatComponentText.

Is this still an issue in the latest snapshot 16w44a? If so please update the affected versions.

This is an automated comment on any open or reopened issue with out-of-date affected versions.

Looks like it was fixed in 18w43a.

Adrian Östergård

Is this still an issue in 20w17a or later?

I cannot reproduce this in 20w17a anymore. Pasting the formatting character (§) is no longer possible (see MC-138046), however even with upgraded books from older versions or by using workarounds like the one below, the formatting applies to wrapped lines as well when the book is signed.

/setblock ~ ~ ~ oak_sign{Text1:"{\"text\":\"Click me\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/give @p writable_book{pages:[\\\"\\u00a76TestTestTestTestTestTestTest\\\"]}\"}}"}

12Me21

(Unassigned)

Confirmed

(Unassigned)

Minecraft 1.8.8, Minecraft 15w50a, Minecraft 16w39c, Minecraft 1.12.2, Minecraft 18w03b, Minecraft 1.13, Minecraft 18w30b, Minecraft 1.13.1

Retrieved