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

Slots (like %s) in translations no longer ignore missing elements in "with"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.19.3 Release Candidate 1
    • None
    • Confirmed
    • Resource Packs, Text
    • Very Important
    • Platform

      In 22w46a and earlier, this command just displays Hello:

      /tellraw @a {"translate":"%s%4363$s","with":["Hello"]}
      

      In 1.19.3-pre1 and later (including rc1) it displays the raw string %s%4363$s instead. This is a breaking change that was not announced or mentioned anywhere.

      The previous behavior was to treat slots with missing corresponding elements inside "with" as if they have an empty string. Instead, nothing is slotted in at all, not even the "Hello", and it just displays the raw string instead.

      Only translations where there are corresponding elements inside "with" for all slots are unaffected, like this one:

      /tellraw @a {"translate":"%s%1$s","with":["Hello"]}
      

      (Displays HelloHello)

      How to reproduce

      1. Run the following command
        /tellraw @a {"translate":"%s%4363$s","with":["Hello"]}
        
      2. Notice that %s%4363$s is printed to chat. Expected is that it would print Hello.

      Code Analysis

      This is caused by a change in the TranslatableContents class in 1.19.3-pre1. The decomposeTemplate method previously checked the replacement index against the length of "with" before calling getArgument and accepting the return value into the result.
      Now getArgument is always called and throws an exception instead when it performs the same check. The exception gets caught within decompose, which then returns the raw translation string instead of the decomposed one.

            boq [Mojang] Bartosz Bok
            AmberW Amber
            Votes:
            32 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: