I'm making a map, and I want to have a command block or a command block set in the middle of the map that detects when a player picks up 5 diamonds and then replaces those diamonds with a bow and arrow. I've found the command
/execute if data entity @a {Inventory:[{id:"minecraft:diamond",Count:5b}]}
But the only way I've gotten that to work with anything is to do a /give @p command
, but because I want this command to be working with multiple people on the map it won't work, How can I take this output and use it to both clear the diamonds and give 2 items?
Best Answer
You are very close. More magic from
/execute
can split each player's handling to themselves. Using scoreboard tags, we can then target the players individually.Then, just run the following in order:
Note that in order to work, all 5 diamonds must be stacked in one slot, not spread out through the inventory. If you want to detect 5 diamonds spread out anywhere in the inventory, replace the
/execute
command with the following two: