TransWikia.com

Minecraft /clear command clearing inexistent blocks

Arqade Asked by CurseOfTime on December 3, 2020

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

2 Answers

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

Answered by Bogdan Stefanescu on December 3, 2020

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.

Answered by Penguin on December 3, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP