5

I've seen this answered before, but it was for Java and it utilized the /stats command, which is unavailable to Bedrock players.

I'm creating a Skyblock map with a functioning shop, using /scoreboard to keep track of a player's money.

I want to make it so that a player could sell 64 cobblestone for $16. But, as anyone knows, /clear only has a [maxCount: int] variable, and no [minCount: int], so the command will clear any number of cobblestone from a player's inventory.

Is there a way to test if a player has at least 64 cobblestone, or clear only that amount, or something of the like?

0

1 Answer 1

1

This may need to be a bit improoved and customized for your situation

The command blocks are numbered from 1 to 7, always from left to right and generally in the order they will be used.

enter image description here

At first I created a scoreboard objective called count, it is supposed to keep track of how much dirt the system owes the player and I did not use a command block for it

/scoreboard objectives add count dummy

Command blocks 1 and 2 count how much dirt you have, by removing one dirt at a time and up to 64 dirt:

1:
/clear @p[scores={count=..63}] dirt 0 1

2:
/scoreboard players add @p count 1

Command block 3 will check if you had 64 dirt, 4 will subtract 64 from count if you did and 5 will give you $16 (if your money is based on a scoreboard objective called money)

3:
/testfor @p[scores={count=64..}]

4:
/scoreboard players remove @p count 64

5:
/scoreboard players add @p money 16

And command blocks 6 and 7 will give you your dirt back, in case you did not have enough:

6:
/give @p[scores={count=1..}] dirt 1

7:
/scoreboard players remove @p count 1

The chain command blocks are conditional and do not require redstone The repeating command blocks and the regular command block are not conditional and they require redstone

You will probably have to modify this quite a bit to fit your particular setup, since this will break if there is more than one player who has dirt. This can probably be fixed by changing the target seletors to fit your situation

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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