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

The custom_data component sub-predicate can succeed for items with no custom_data component

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.21.3
    • None
    • Community Consensus
    • (Unassigned)

      The custom_data component sub-predicate succeeds if the sub-predicate value is an empty object (or string containing an empty SNBT compound), even if the item itself doesn't have any custom_data component present. This doesn't make any sense and is inconsistent with all other sub-predicates.

      Steps to Reproduce

      1. Hold any item that does not have a custom_data component (e.g. any item from the creative inventory or the world) in your main hand.
      2. Use a predicate or if items to test this sub-predicate against the item you are holding
        /execute if items entity @s weapon *[custom_data~{}]

        or

        /execute if predicate {condition:"minecraft:entity_properties",entity:"this",predicate:{equipment:{mainhand:{predicates:{"minecraft:custom_data":{}}}}}}

      Observed Results

      The sub-predicate always succeeds, even if the item does not have the custom_data component at all.

      Expected Result

      The sub-predicate only succeeds if the custom_data component is present, as there should be no NBT compound to compare against if there is no component, and to be more in-line with other component sub-predicates.

      i.e. *[custom_data~{}] should behave identically to *[custom_data]

            Unassigned Unassigned
            Deoxyribonucleic Evans DorkOrc
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              CHK: