mojira.dev
MC-258251

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

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.

Comments 4

I'll note that this is not just a technical quirk. It is used and thus affects a lot of packs.

Confirmed for snapshot 23w13a.

@unknown, if you're still experiencing this issue (or a similar one), please file a new bug report.

It's intended since 1.19.4; it was listed as a changelog entry.

AmberW

boq

Confirmed

Platform

Very Important

Resource Packs, Text

1.19.3 Release Candidate 1

1.19.3 Release Candidate 2

Retrieved