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

A collection matcher's `contains` field passes unconditionally for nonempty collections

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • 1.20.6
    • None
    • Unconfirmed
    • (Unassigned)

      Run this to get a bundle containing dirt:

      /give @s minecraft:bundle[minecraft:bundle_contents=[{id:"minecraft:dirt"}]]
      

      Hold the bundle in your main hand, and enter this to check if the bundle contains a diamond:

      /execute if items entity @s weapon.mainhand *[minecraft:bundle_contents~{items:{contains:[{item:"minecraft:diamond"}]}}]
      

      Clearly, the bundle did not contain a diamond, and yet this outputs "Test passed, count: 1".

      I tested this on minecraft:bundle_contents and minecraft:container. The only case I could find where this bug doesn't apply is when the collection being matched is empty.

            Unassigned Unassigned
            GrantGryczan Grant Gryczan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: