Minecraft 1.9, Minecraft 16w39c, Minecraft 1.11, Minecraft 1.13.1
When writing in a book & quill and a word jumps to the next line on the last letter, it will jump back when the space bar is struck. However, in the signed book, that word will be on the next line and if the text on the page is over 13 lines long, a line of text will be lost. I have illustrated this in the screenshots below.
P.S.: Yes, I know this has been reported before but that report was written off as a duplicate to another issue that was not related.
MC-78858 was not a duplicate of MC-31113.
Based on 1.11 decompiled using MCP 9.35 rc1
Automatic linebreak for valid text lengths while editing
The last word appears in the new line because the method net.minecraft.client.gui.GuiScreenBook.drawScreen(int, int, float) just appends the cursor (flashing _) to the text which increases the length. One possible approach to fix this might be to use the method net.minecraft.client.gui.GuiUtilRenderComponents.splitText(ITextComponent, int, FontRenderer, boolean, boolean) and then test if the cursor character can be appended to the last ITextComponent item and if not a new ITextComponentItem has to be added (this would probably solve the second bug as well).
Automatic linebreak while editing differs from signed version
The reason here is similar to the one for
MC-83469 and is caused by the two different rendering methods.
net.minecraft.client.gui.GuiUtilRenderComponents.splitText(ITextComponent, int, FontRenderer, boolean, boolean) splits a string before the character which causes the string to exceed a given rendering width, whereas net.minecraft.client.gui.FontRenderer.drawSplitString(String, int, int, int, int) splits it after the character which exceeded the given width. (Please correct me here if I am wrong).
- relates to
MC-83469 Formatting in book and quill is different after signing