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

Paintings with non-existent variant entity tag are falsely labeled as random variant

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 23w06a, 23w07a, 1.19.4 Release Candidate 3, 1.19.4, 23w14a, 1.20.1, 1.20.2 Pre-release 1, 24w06a, 1.20.5
    • None
    • Confirmed
    • Creative
    • Items, Text
    • Low
    • Platform

      When creating a painting with an entity tag that specifies a painting variant that does not exist, the tooltip in the creative inventory will list it as a random variant. However, the painting variant that is actually placed is the 1x1 Kebab default painting variant.

      /give @s painting[entity_data={variant:a,id:painting}]
      

      Code analysis

      Using Yarn mappings for 23w06a:

      The code path for getting a painting's tooltip in the DecorationItem#appendTooltip method calls the PaintingEntity#readVariantFromNbt method, which returns an empty optional when the identifier in the NBT is not present in the painting variant registry. If the optional is empty, then the tooltip will include the random variant line.

      However, the DecorationItem#useOnBlock method uses the code path for reading the EntityTag compound. This merges the newly-created entity's NBT with the EntityTag compound, then loads that compound into the entity involving the PaintingEntity#readCustomDataFromNbt method. This method also uses the PaintingEntity#readVariantFromNbt method, but chains the optional so that it falls back to the Kebab painting variant instead. As a result, the placed painting will always have the Kebab painting variant if the identifier cannot be parsed or the identifier is missing from the painting variant registry.

      The change required would be simple: the tooltip code path should match the entity loading code path in defaulting the painting variant to Kebab. Alternatively, the entity loading code path could choose a random variant instead of defaulting the painting variant, but this could break existing paintings with broken NBT.

            Unassigned Unassigned
            haykam haykam
            Votes:
            7 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: