Mojira Archive
MC-114125

Text wrapping is not working correctly with text consisting of multiple text components

The bug

Text wrapping is not working correctly with text which consists of multiple text components. An "in-game" example where this bug can be seen are achievements. The method net.minecraft.stats.StatBase.createChatComponent() builds the text component by inserting the achievement name in between two text components containing the bracket.

The problem is that the brackets are wrapped independently from the achievement name.

Note: There seems to be a different bug with this which causes words to not be wrapped correctly if they are the first word of a text component and the text in the text component before it nearly took up all the space (see reproduction example "First words not wrapped correctly").

Expected behavior

The expected behavior is probably that the method net.minecraft.client.gui.GuiUtilRenderComponents.splitText(ITextComponent, int, FontRenderer, boolean, boolean) first joins all text components to one string and then starts splitting it.

How to reproduce

Achievement

  1. Set the chat width in the "Chat Settings" to 81px
  2. Give yourself the following achievement
    /advancement grant @p only minecraft:nether/return_to_sender
    

    → You should see that the opening bracket is not wrapped with the achievement name

Custom text components

  1. Set the chat width in the "Chat Settings" to 40px
  2. Use the following command
    /tellraw @p ["some te","xt"]
    

    → You will see that despite there being no space between "te" and "xt", "xt" was still wrapped in the next line while "te" was not

First words not wrapped correctly

  1. Set the chat width in the "Chat Settings" to 40px
  2. Use the following command
    /tellraw @p ["some ","text test"]
    

    → You will see that "text" is not wrapped correctly even though it would fit in the next line