3

How to test for multiple items in Inventory

Destroyer917's Avatar Destroyer9175/25/19 9:19 am
6/19/2019 3:15 pm
unnamedDE's Avatar unnamedDE
Hello , i was wondering how one would detect if a player has for instance three or more Dirt blocks in their inventory ?
Posted by Destroyer917's Avatar
Destroyer917
Level 1 : New Miner
0

Create an account or sign in to comment.

7

2
05/25/2019 4:39 pmhistory
Level 52 : Grandmaster Cowboy
CrazyCowMM
CrazyCowMM's Avatar
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
05/25/2019 3:09 pm
Level 10 : Journeyman Miner
anonpmc2054575
anonpmc2054575's Avatar
[deleted]
1
06/19/2019 3:15 pm
Level 49 : Master Technomancer
unnamedDE
unnamedDE's Avatar
You can use:
/execute as @a score result score @s <SCOREBOARD> run clear @s <ITEM> 0to store the amount of <ITEM> to the scoreboard <SCOREBOARD> without removing any items
2
05/25/2019 4:32 pmhistory
Level 52 : Grandmaster Cowboy
CrazyCowMM
CrazyCowMM's Avatar
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
05/25/2019 6:53 pm
Level 10 : Journeyman Miner
anonpmc2054575
anonpmc2054575's Avatar
[deleted]
1
05/25/2019 1:18 pm
Level 67 : High Grandmaster Botanist
Hashs
Hashs's Avatar
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
05/25/2019 1:12 pm
Level 54 : Grandmaster Scapegoat
FishyBusiness
FishyBusiness's Avatar
I dont think its possible to know unless they tell you :P
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome