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

Single quotes cannot be used in lore component of text components

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • 1.20.5 Release Candidate 2
    • None
    • win10, jdk 21.0.3
    • Unconfirmed
    • (Unassigned)

      The lore of items has always used single and double quotation marks.
      Use the following command to obtain a stick with lore:

      /give @s stick[minecraft:lore=[' "text" ']] 1

      But in "hoverEvent" of text components, in "show_item", the lore component can only use two layers of double quotes, and cannot use single quotes to wrap double quotes, otherwise it will get a malformed JSON error.

      Use the following command to tellraw text carrying hoverEvent to all players, which can display a grass block with lore:

      /tellraw @a [{"text":"[ITEM]","hoverEvent":{"action":"show_item","contents":{"id":"minecraft:grass_block","count":32,"components":{"minecraft:lore":[" \"text\" "]}}}}]

      It works because we used two layers of double quotes.

      But the following command will result in an error:

      /tellraw @a [{"text":"[ITEM]","hoverEvent":{"action":"show_item","contents":{"id":"minecraft:grass_block","count":32,"components":{"minecraft:lore":[' "text" ']}}}}]

        1. 20240420010909.png
          20240420010909.png
          6 kB
        2. 20240420132802.png
          20240420132802.png
          277 kB
        3. 20240420132840.png
          20240420132840.png
          269 kB

            Unassigned Unassigned
            Mini_Ye Mini_Ye
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: