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
is duplicated by 1
relates to 3
Attachments
Comments 10
Incorrect duplicate link
Confirmed for:
15w34d Paste for example this text:
§6TestTestTestTestTestTestTest
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.
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\\\"]}\"}}"}
Might relate to MC-62866