Minecraft Java Edition – How to Remove a Certain Amount of Items from Someone’s Inventory

minecraft-commandsminecraft-java-edition

In a map I am making, to enter a certain place someone must have 3 iron ingots to enter. I've tried using the /clear command, but if they have more than 3 they lose it all. Any ideas on how to fix this?

Best Answer

You should be able to achieve it with clear by adding a maxCount

clear [player] [item] [data] [maxCount] [dataTag]

So it should be

/clear @p minecraft:iron_ingot -1 3