So I'm using the testfor command to find near players with a item with a custom name and a specific amount. The issues I'm having is how to search for more than 1 stack of items like 100 items total.

Here is what I've got for the command so far

testfor @p {Inventory:[{id:"minecraft:paper",tag:{display:{Name:"$1"}}}]}

I just don't know how to put "count:100" in there


This solution uses a scoreboard and command stats to determine if a player has a minimum amount of items. It could be used to sell/trade items with players.

First you need to manually create a scoreboard objective:

/scoreboard objectives add ITEMS dummy

This will use four command blocks, all chained. A button on the impulse block so the player can initiate. The first block uses the clear command with a value of 0. It does nothing but allows command stats to determine how many items were affected/looked at. The second block stores how many items were affected in the objective ITEMS. This objective now has total number of the specified item in the players inventory. The third block clears 100 custom named paper from the inventory only if the player has at least 100. The fourth block would then be used to output to the player(give currency/items).


First block is Impulse Unconditional Needs Redstone with command:

clear @p minecraft:paper 0 0 {display:{Name:"$1"}}

Second block is Chain Conditional Always Active with command:

stats block ~1 ~ ~ set AffectedItems @p ITEMS

Third block is Chain Conditional Always Active with command:

clear @p[score_ITEMS_min=100] minecraft:paper 0 100 {display:{Name:"$1"}}

Fourth block is Chain Conditional Always Active. It will contain whatever the player receives for giving up their items. You could add to a currency scoreboard or give them items. Here are a couple of example commands:

scoreboard players add @p Money 10

give @p[score_ITEMS_min=100] minecraft:gold_block 64

All this to see if the player has at least the specified amount before using the clear command. The clear command, when used alone, will succeed if the player has even one of the specified item in their inventory.

This is someone else's idea. I just verified it actually works, and tweaked the commands a little. Here is the page I found the original commands on.

| improve this answer | |
  • I thought of using that but It wouldn't really work for this situation. what im trying to do is create a in game currency which you can get by exchanging iron gold and diamonds for a set number of currency. that part works my only problem is that when i use that currency its limited to 64 when cause the test for command doesnt seem to have what im looking for. I know alot of people use the scoreboard commands but i have no clue where to even start for that. – Chris CALS Sep 30 '17 at 4:41
  • 2
    I strongly recommend scoreboard for currency. Here is a great page on scoreboards. Item based currency is difficult to manage. If your currency is paper named $1, at least in survival, you can rename an entire stack of paper on the anvil for 1 level. You can go with something custom like lore but if a duplication glitch exists, people may duplicate it. I will post edit the answer to include a second solution that uses command stats that will test for 100 and remove 100. – IronAnvil Sep 30 '17 at 4:55
  • This all helped alot, I now can set up my own ingame currency – Chris CALS Sep 30 '17 at 6:13
  • You should probably remove the first part of your answer, because while it sometimes works, most of the time it doesn't. The test only does exact matches, while the clear/stats/scoreboard method always counts the correct number of items. – MBraedley Jan 15 '18 at 0:38
  • @MBraedley That is done. Thank you for the suggestion. I had originally left that first part and just added to the answer but it definitely should have gone. – IronAnvil Jan 15 '18 at 3:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.