How to test for minimum amount of items in inventory and execute a command if true

How to test for minimum amount of items in inventory and execute a command if true - Photo of Clear Glass Measuring Cup Lot

I am using the AmazingKit plugin on my Minecraft server to make inventory kits for players. In a command block I have the following command:

/tellraw @p ["",{"text":"Iron","clickEvent":{"action":"run_command","value":"_____"}},{"text":" / "},{"text":"Gold","clickEvent":{"action":"run_command","value":"_____"}}]

Which prints the following result: Iron / Gold.

When a player clicks on Iron, what command should I write where the empty space is _____ in order to check if the player has at least (>=) 20 iron ingots in his inventory and if he/she does, remove 20 iron ingots and execute /kit Basic. If the player has less than 20 iron ingots in inventory, the command won't be executed. Instead, Insufficient amount of iron ingots will be printed out.

Same applies when a player clicks on "Gold".

I'm on 1.14 version






Pictures about "How to test for minimum amount of items in inventory and execute a command if true"

How to test for minimum amount of items in inventory and execute a command if true - Two Clear Glass Jars Beside Several Flasks
How to test for minimum amount of items in inventory and execute a command if true - Student Cheating During an Exam
How to test for minimum amount of items in inventory and execute a command if true - Student Getting A+ Mark in Her Exam



How do you test inventory items?

You can use the /invsee <name> command to achieve this. You can also modify a users inventory using this command.

What is the command to check inventory?

How to Enter the Command
  • Test if Players are within 10 blocks. In this example, we will test to see if there are any players within a 10 block radius with the following command: /testfor @a[r=10] ...
  • Test if Mooshrooms are within 50 blocks. ...
  • Test if Nearest Player is at Level 20 experience.




  • 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: Rodolfo Clix, Pixabay, RODNAE Productions, RODNAE Productions