3
How to test for multiple items in Inventory
Hello , i was wondering how one would detect if a player has for instance three or more Dirt blocks in their inventory ?
Create an account or sign in to comment.
7
2
You could use a combination of execute store and data get to get the count of dirt blocks in their inventory and save that to a score so that you can simply check if they have a score of 3. This only works in 1.14 but you can do /execute as @a store result score @s SCOREBOARD_NAME run data get entity @s Inventory[{id:"minecraft:dirt"}].Count 1 to set the players score to the number of blocks of dirt they have and then do /execute as @a[scores={SCOREBOARD_NAME=3}] run ... to do your command
1
[deleted]
1
You can use:
/execute as @a score result score @s <SCOREBOARD> run clear @s <ITEM> 0
to store the amount of <ITEM> to the scoreboard <SCOREBOARD> without removing any items2
I might still use /clear because you can specify items you want to clear. So you could clear only three dirt blocks from their inventory. Execute can't do any inventory checking sadly
1
[deleted]
1
You can use the /clear command to test, and combine with /execute store in order to test how many blocks were removed and return them.
1
I dont think its possible to know unless they tell you :P