mojira.dev
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

Linked issues

Attachments

Comments 8

Can a mod please update the affected versions to 1.12? Thank you.

Can confirm for MC 1.12.1, the advancement part should be updated though. The new working command is:

/advancement grant @p only minecraft:nether/return_to_sender

Confirmed for 1.13-pre6

Confirmed for 1.13.1-pre1

Confirmed for 1.14 and 1.14.1-pre2.

I've attached two screenshots of this, based on the last screenshot example in https://bugs.mojang.com/browse/MC-48904 (found that issue before this one).

/tellraw @p [{"text":"["},{"text":"Tip","color":"green"},{"text":"] Follow us on "},{"text":"Twitter","color":"aqua"},{"text":" at: "},{"text":"www.twitter.com/SurvivalCraftMS","color":"dark_aqua"},{"text":" for the latest updates to our server!"}]

This is fixed in 1.16-pre4.

Tested against 1.15.2 and can confirm this is no longer an issue in 1.16.2.

Cannot reproduce either in 1.16.2

marcono1234

(Unassigned)

Confirmed

(Unassigned)

/tellraw, chat, formatting, text, text-component, wrap

Minecraft 1.11.2, Minecraft 17w06a, Minecraft 1.12, Minecraft 1.12.1, Minecraft 1.12.2, ..., Minecraft 1.13.1-pre1, Minecraft 1.14, Minecraft 1.14.1 Pre-Release 2, 1.15.2, 20w08a

Retrieved