mojira.dev
REALMS-11165

Data not working for Hasitem

/give @s diamond_sword 1 50
The above command will yield a Diamond Sword with minus 50 durability.

/clear @s diamond_sword 50 1
The above command removes a diamond sword with minus 50 durability from the wielder if the wielder has one.

/clear @s[hasitem={item=diamond_sword,data=50}] diamond_sword 50 1
The above command SHOULD remove a diamond sword with minus 50 durability from the wielder if the wielder has one. However it does not because "[hasitem={item=diamond_sword,data=50}]" will return false no matter what.

An example of a practical use for this would be:
/replaceitem entity @a[hasitem={item=iron_sword,data=0,location=slot.weapon.mainhand}] slot.weapon.mainhand 0 diamond_sword 1 0
This would make it so that if a player fully repairs an iron sword, it would transform into a diamond sword. My applications are more complex, but even basic things such as this are undoable with the current Data function not behaving within the hasitem condition

Linked issues

Comments 1

Thank you for your report!
We're tracking this issue in MCPE-151920, so this ticket is being resolved and linked as a duplicate.

If you would like to add a vote and any extra information to the main ticket it would be appreciated.

If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki – 📖 FAQs
-- I am a bot. This action was performed automatically! The ticket was resolved by one of our moderators, and I left this message to give more information to you.

migrated

(Unassigned)

Unconfirmed

Bedrock

Retrieved