I’m on Minecraft PE and I’ve been trying to make a shop that takes diamonds and gives items. I have 2 command blocks set up, the first on impulse and the second on conditional chain, so the second block (the one that gives the item) only executes if the first block (the one that takes the diamonds) is successful. The problem I have is that I try to take 5 diamonds, but the block will work even with 1 diamond and still gives the items. How do I fix this?

/clear @p diamond 0 5
/give @p apple 1
  • Could you list the commands that you are using?
    – Detmondyou
    Apr 1, 2019 at 15:12
  • 1
    Just listed them Apr 1, 2019 at 15:14
  • Hmmm... I’ll think about it. The commands look fine.
    – Detmondyou
    Apr 1, 2019 at 15:19
  • Wouldn’t it also be simpler to have to player drop off the items in a chest? An item filets could then determine if the right amount was put in or not.
    – Detmondyou
    Apr 1, 2019 at 15:40
  • How would I go about doing that? Apr 1, 2019 at 15:50

3 Answers 3


If you want a secure shop system, you should not use command blocks but rather build a redstone contraption like silentwhisperer's one. You can entrap it with bedrock, barrier blocks or blocks on deny blocks to make in unbreakable in survival.


You can have multiple command blocks continuously clear the item 1 at a time, if one of them fails they do not have enough. Downside: If player does not have enough they do not get refunded, just their money stolen.


Before you clear the diamonds add another command block that checks if user has them.

Here is how to do that on Java Edition (Syntax for mcpe should be the same) (From answer at Check if player has item, if so remove it by Jumpshift)

In Minecraft 1.8+ we have the /testfor command, you can use this to scan the players Inventory slots (all of them, or specific) for items:

example: diamond

/testfor @p {Inventory:[{id:"minecraft:diamond"}]}

to test for an exact amount of the required item include:


  • Please check next time. The user is asking for Bedrock edition where command NBT does not exist.
    – Penguin
    Oct 15, 2020 at 1:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .