mojira.dev
MC-229882

Predicate still passes for certain stacks even after dropping them

The bug

If you drop an item, the predicate will still say you are holding that item, even if there is nothing in your hand. Opening your inventory and clicking on the slot where the item used to be will update it and the using the predicate will result in the correct outcome.

Did not happen in 1.16.5

How to reproduce

  1. Create a predicate as follows:

    {
      "condition": "minecraft:entity_properties",
      "entity": "this",
      "predicate": {
        "equipment": {
          "mainhand": {
            "nbt": "{Cap:1b}"
          }
        }
      }
    }
  2. Give yourself a shield with the tag Cap:1b, 

    /give @s shield{Cap:1b}
  3. Drop the item

  4. Test the predicate

    execute if predicate ...
  5. ❌ It will result in "Test Passed"

  6. Go into your inventory and click on your empty selected item slot, then testing the predicate again will result in "Test Failed"

Linked issues

Attachments

Comments 9

Hi I'm back. Sorry, I misunderstood the issue. As in MC-226525 you do indeed need to update your item key to items, but the problem with dropping sounds more similar to MC-229983. Since I was told this is still an issue, I'll reopen it now and change the title. Sorry about that.

It's still an issue in 1.17.1. The mentioned bug don't seem to be exactly related.
Adding items does fix the issue, but you might want to test regardless of the exact item id, and adding the following part still does cause the same issue :

"items": [
          "minecraft:golden_sword","minecraft:air"
        ]

Is there any reasoning behind why this is marked as working as intended? This bug is still present as of 1.18.1, and I don't see any developer comment other than Adrian marking it.

I'd like to request a review for this. The predicate still passing while the item no longer is in the inventory is nonsensical, and the expected behavior would be to only pass if it exists. The fact that clicking on the slot or relogging changes the result makes this look like a desync too.

I'm sorry but why has this been marked as resolved and "works as intended", when it clearly isn't? A predicate that checks for an item in the mainhand with a specific NBT tag can not be considered "working as intended" if it passes when there's no item at all in the player hand.

I'm asking for this to be reopened.

Can confirm in 1.20.3

Does not occur in 1.21.1. It seems it was fixed somewhere between 1.20.4 and 1.21.1

Also here are the commands for recent versions.

/give @s shield[custom_data={Cap:1b}]
/execute if predicate {condition:entity_properties,entity:this,predicate:{equipment:{mainhand:{predicates:{custom_data:{Cap:1b}}}}}}

It makes sense that this would've been fixed in 1.20.5 when they introduced item components

Miles Spink

(Unassigned)

Confirmed

Commands, Data Packs

1.17, 1.17.1 Pre-release 1, 1.17.1, 1.19.4, 1.20 Pre-release 5, 23w51b

Retrieved