how to testfor a player that selected an item?
//ads -- adsterra.com -- native banner
?>
How to use the scoreboard command to testfor for a player that selected a snowball, namely "Blast" in Minecraft 1.9?
Best Answer
The SelectedItem compound holds a copy of the player's currently-held item (minus the Slot tag). All item data that is not the root id, Damage, Count, or Slot, must be placed within a single tag compound.
/scoreboard players set @a OBJ 0
/scoreboard players set @a OBJ 1 {SelectedItem:{id:"minecraft:snowball",tag:{display:{Name:"Blast"}}}}
/say Players holding the item: @a[score_OBJ_min=1]
As of 1.9 you will want to use "tags" instead of scores when labeling the player, which is more efficient and does not require an objective:
/scoreboard players tag @a[tag=holding] remove holding
/scoreboard players tag @a add holding {SelectedItem:{id:"minecraft:snowball",tag:{display:{Name:"Blast"}}}}
/say Players holding the item: @a[tag=holding]
Pictures about "how to testfor a player that selected an item?"



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: Andrea Piacquadio, Matthias Groeneveld, Rich Ortiz, Artem Podrez
