So me and my friend are creating a Mario-like game in Minecraft Bedrock Edition. We are struggling with trying to come up with code. What we need is so if the player is standing on a red mushroom it breaks the mushroom and gives the player an item. The problem is that we need to have both things happen at the exact same time (without a comparator delay too) so that you can pick up multiple mushrooms in a row without missing any.

We have tried

/execute @a ~~~ detect ~~~ red_mushroom 0 fill ~~~ ~~~ air and then hooking it up to a give command using a comparator. Obviously it works but we cant have a delay between picking up the mushrooms.

We have also tried running two execute commands in repeating, one that gives you an item and one that destroys the mushroom. The problem is it creates a 50/50 of if it works or not.

Could someone help us out with this?

  • Does it need to give you an item, or can it just be the mushroom block's drop? I've got a neat, fast answer using a single command and loot tables, but I'm not sure whether it's valid. – wizzwizz4 Jul 30 at 13:24

There is a simple fix to this:

Have a Repeat command block set to Always Active, with this command:

/execute @a ~~~ detect ~~~ red_mushroom 0 fill ~~~ ~~~ air

There is a house/pentagon-shaped object with dots on it, and it should be on top, and pointing to a chain command block.

The chain command block should have your command that gives the player a mushroom, set to Always Active, and Conditional. The Conditional statement is there for this reason:

If the Repeat command block detects a player on a mushroom, then they will give that player a mushroom. If not, then nothing happens. If the block was Unconditional, then players would have their inventories cluttered with mushrooms. I hope this helps.

Edit: Because we want to detect which player stepped on a mushroom, we need separate pairs of command blocks for each player, like so:

/execute fasterthanlight ~~~ detect ~~~ red_mushroom 0 fill ~~~ ~~~ air /give fasterthanlight red_mushroom 1

For each player, set up a different pair of command blocks with these commands, and replace my username with your targeted player. For example, with two players, Alice and Bob, two pairs of blocks will be used:

/execute Alice ~~~ detect ~~~ red_mushroom 0 fill ~~~ ~~~ air /give Alice red_mushroom 1


/execute Bob ~~~ detect ~~~ red_mushroom 0 fill ~~~ ~~~ air /give Bob red_mushroom 1

| improve this answer | |
  • 1
    Hm, nice answer. This does get a bit verbose, though, but it could work for a minimal number of players. – ExpertCoder14 Jul 30 at 4:09

Here is an answer that works no matter how many players there are.

Place down an always active repeating command chain of 2 blocks.

Commands inside:

  1. Tell everyone with a red_mushroom under them to give themselves an item.

    /execute @a ~ ~ ~ detect ~ ~-1 ~ red_mushroom 0 give @s mushroom
  2. Tell everyone with with a red_mushroom under them to set the block underneath them to air.

    /execute @a ~ ~ ~ detect ~ ~-1 ~ red_mushroom 0 setblock ~ ~-1 ~ air
| improve this answer | |
  • 1
    Can you elaborate on this as well? – fasterthanlight Jul 30 at 2:28
  • I am wondering why this tag method works. – fasterthanlight Jul 30 at 2:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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