Testfor an item in player's hand

Testfor an item in player's hand - Encyclopedia placed near wooden decorative hand shaped pen holder

How can I test for a player with scoreboard holding a skull with damage 2s in his active slot with a name? I tried SelectedItem instead of Inventory, but it didn't work. I do it in 1.9. Here is a command:

/testfor @a[score_Medusashead_min=1,score_Medusashead=1] {SelectedItem:[{id:minecraft:skull,Damage:2s,tag:{display:{Name:"Medusa's head"}}Count:1b}]}


Best Answer

First of all, SelectedItem's value is an object, not an array. That means that you should remove the square brackets around the SelectedItem tag's value. The next thing to do is to add a comma before Count:1b. Your final command should then be:

/testfor @a[score_Medusashead_min=1,score_Medusashead=1] {SelectedItem:{id:minecraft:skull,Damage:2s,tag:{display:{Name:"Medusa's head"}},Count:1b}}



Pictures about "Testfor an item in player's hand"

Testfor an item in player's hand - Crop unrecognizable person showing set of markers at work
Testfor an item in player's hand - Hand Holding Item with Clouds in Background
Testfor an item in player's hand - Crop person with retro camera





Minecraft Bedrock - Test For Items In Inventory (Mobile/Xbox/PS4/Windows 10/Switch)




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Rachel Claire, Karolina Grabowska, Disha Sheta, Erik Mclean