mojira.dev
MC-118813

Enchantment text adds hardcoded space between enchantment and level

I was using custom enchantment text to telegraph to the player the tier of an item (to allow for it to be translated), when the enchantment text I was using had an extra space between the enchantment name and level (I had enchantment name as empty).

[media]

What I expected to happen:
There not to be an extra space at the start of the enchantment text. (Done by making the enchantment name contain this text.)

[media]

What actually happened:
There was an extra space.

Steps to reproduce

  1. Add the following lines of text into a language file in a resource pack:

    enchantment.sharpness=
    enchantment.level.1=<--Space here
  2. Create a sharpness 1 sword

  3. See that there is a space before the text

What is happening
When enchantment text on an item is added, the text to be shown is computed as enchantment.<enchantment> + a (space) + enchantment.level.<level>.
This is in effect using the text component

{"translate":"enchantment.<enchantment>","extra":[{"text":" "},{"translate":"enchantment.level.<level>"}]}

What would be more consistent would be using %s for insertion of enchantment. This would mean that the effective text component would be

{"translate":"enchantment.withLevel","with":[{"translate":"enchantment.<namespace>.<id>"},{"translate":"enchantment.level.<level>"}]}

And the line "enchantment.withLevel": "%s %s", added to the language files.

Attachments

Comments 3

still an issue in 1.19.3 and 1.19.4 release candidate 3

The description states that potions are also affected (in the last line). This is not/no longer true:

"potion.withAmplifier": "%s %s",
"potion.withDuration": "%s (%s)",

are used. Strength 2 =

{"translate":"potion.withDuration","with":[{"translate":"potion.withAmplifier","with":[{"translate":"effect.minecraft.strength"},{"translate":"potion.potency.1"}]},{"text":"01:30"}]}

Enchantments do still have a hardcoded space though.

Seeing as Levertion has no activity since 2018, I'd like to request ownership of this report.

Affects 1.21.11, I’ve attached a resource pack in case anyone would like to test this in the future 🙂

[media]

Levertion

[Mod] turbo

(Unassigned)

Confirmed

(Unassigned)

Minecraft 1.12, 20w07a, 1.19.3, 1.19.4 Release Candidate 3, 1.19.4, 1.20.1, 1.20.2, 23w43b, 1.20.3 Pre-Release 2, 1.21.11

Retrieved