home Forumsplay_arrow Help play_arrow Java Edition

3

How to test for multiple items in Inventory

3 emeralds7 replies88 views
created 05/25/2019 9:19 am by Destroyer917
last reply 06/19/2019 3:15 pm
Hello , i was wondering how one would detect if a player has for instance three or more Dirt blocks in their inventory ?
Posted by avatar
Destroyer917
Level 1 : New Miner
0

comment Login or register to post a reply.

7 replies

2
05/25/2019 4:39 pmhistory
Level 41 : Master Cowboy
CrazyCowMM
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 Pig
PsychoticDaze
If this is something your lookig for server side. Trying getting essentials that way you can just use /invsee if your looking to do this in a vanilla command try looking into /execute commands? But don't use /clear then store, that will just piss players off especially if the command goes wrong because then they might lose items!
1
06/19/2019 3:15 pm
Level 16 : Journeyman Button Pusher
unnamedDE
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 41 : Master Cowboy
CrazyCowMM
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 Pig
PsychoticDaze
Yeah I guess that would make sense. I don't really mess with Vanilla commands. I would say just test it alot before using it publicly cause that could be bad to lose someones stuff.
1
05/25/2019 1:18 pm
Level 43 : Master Archer
Hashs
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 25 : Expert Fish
TheOfficialDerp
I dont think its possible to know unless they tell you :P

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome