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
Create a predicate as follows:
{ "condition": "minecraft:entity_properties", "entity": "this", "predicate": { "equipment": { "mainhand": { "nbt": "{Cap:1b}" } } } }
Give yourself a shield with the tag Cap:1b,
/give @s shield{Cap:1b}
Drop the item
Test the predicate
execute if predicate ...
❌ It will result in "Test Passed"
Go into your inventory and click on your empty selected item slot, then testing the predicate again will result in "Test Failed"
Linked issues
is duplicated by 2
relates to 1
Attachments
Comments 9
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.
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}}}}}}
See MC-226525