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

Enchantment text adds space between enchantment and level

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: Minecraft 1.12, 20w07a
    • Fix Version/s: None
    • Labels:
      None
    • Confirmation Status:
      Confirmed
    • Category:
      (Unassigned)

      Description

      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).

      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.)

      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 (and potion levels). This would mean that the effective text component would be

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

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            montz13 Levertion
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              CHK: