1

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
One 2 Many
  • 12,607
  • 6
  • 48
  • 86
  • Could you list the commands that you are using? – Detmondyou Apr 01 '19 at 15:12
  • 1
    Just listed them – CurseOfTime Apr 01 '19 at 15:14
  • Hmmm... I’ll think about it. The commands look fine. – Detmondyou Apr 01 '19 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 01 '19 at 15:40
  • How would I go about doing that? – CurseOfTime Apr 01 '19 at 15:50
  • The chest has a hopper below it. That hopper drops the items into an item filter made to give a comparator output if five (5) items go through. Link the comparator to a repeater, and that to a dropper below the floor that will dispense the good. – Detmondyou Apr 01 '19 at 15:59
  • I have no idea how to use comparators lol – CurseOfTime Apr 01 '19 at 16:05
  • Make the comparator’s back point towards the hopper. The back is the side with two redstone torches. The front is where the signal is coming out from, and the back is where the “detection” unit is. When 5 items go through, have all five go into a hopper separate form the filter. The comparator will be here. – Detmondyou Apr 01 '19 at 20:51

3 Answers3

1

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.

leo848
  • 121
  • 2
0

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.

Penguin
  • 5,134
  • 5
  • 23
  • 54
-1

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:

,Count:#b

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