Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-114648

Section sign with invalid formatting character afterwards can exceed chat window boundaries


    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w13b, Minecraft 17w14a, Minecraft 1.12, Minecraft 1.12.1, 20w07a
    • Confirmed
    • (Unassigned)

      Section sign with invalid formatting character afterwards can exceed chat window boundaries

      *** It does NOT work by using the \u00A7 JSON escape character! Please use method below. ***

      I am a decent command blocker, and I do use section signs whenever I can't use JSON text and would like/need color. I mainly do this in applications such as custom item names, scoreboard team prefixes, etc. To do so, I use the Server Console to give me a Command Block with section signs, because the Server Command prompt allows section signs.

      However, running an excessive amount of section signs with no valid formatting character after them can lead to some weird glitches; such as this one exceeding maximum chat window boundaries. If you would like any more information, feel free to comment below!

      Launcher and server output
      [@] § § § § § etc.

      How to reproduce

      Run this in a command block then use (default right click) the created sign above.
      /setblock ~ ~1 ~ standing_sign default replace {Text1:"{\"text\":\"Click\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/say \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7 \\u00A7\"}}",Text2:"[\"\"]",Text3:"[\"\"]",Text4:"[\"\"]"}

      As noted above, do NOT use JSON escape codes; they must be sent as section signs (not escape codes) to the client. Instead, use the sign above (as the \u00A7 is actually converted into a section sign and sent as a section sign to the client, instead of \u00A7).

      Code analysis by @Marcono1234

      It looks like the method FontRenderer.getCharWidth(char) is causing problems because it returns -1 for the section sign. But I am not sure if this is even worth fixing since as far as I know the goal is to switch everything to text components at some point.

      The "r"s come from the "§r" which is appended to every text component, however "§§r" is then processed as invalid formatting resetting style and "r".

      20w07a repro steps:

      Run this command in a command block and right-click the resulting sign. You will get 2 empty chat lines. Repeat the same experiment with one 'a' less, and you'll get one chat line full of 'a's, followed by a single section sign:

      /setblock ~ ~1 ~ jungle_sign{Text1:"{\"text\":\"Click\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/say aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\u00A7\"}}",Text2:"[\"\"]",Text3:"[\"\"]",Text4:"[\"\"]"}

            Unassigned Unassigned
            TheMuffinPony TheMuffinPony
            3 Vote for this issue
            5 Start watching this issue