Minecraft – I need help with /execute

minecraft-commandsminecraft-java-edition

I am trying to use the /execute and detect air below the player and set the block to a barrier block and the destroy it one second later. in doing this I am trying to make a double jump mechanism but a the moment the commands are in separate blocks using comparators and repeaters this is fine on single player but not multiplayer friendly. I did some research and I got this:

/execute @e[type=Player] ~ ~ ~ detect ~ ~-2 ~ air 1 fill ~-2 ~-1 ~-2 ~1 ~-1 ~1 barrier destroy 0

But, this doesn't work and it comes up with

[11:52:19] Failed to execute 'detect' as mr_assley19

If anyone could come up with any alternatives or how to fix the command that I've tried, then that would be great!

Best Answer

To fix the command:

  • @e[type=Player] can just be @a
  • There is no air with a data value of 1, so the detect will never succeed; it should be 0
  • The data value in /fill should come before the old block handling mode

So your command should be:

execute @a ~ ~ ~ detect ~ ~-2 ~ air 0 fill ~-2 ~-1 ~-2 ~1 ~-1 ~1 barrier 0 destroy

I'm not sure if this really does what you want it to though. There is no way to execute two separate commands in a command block, nor is there any way to have a delay in a single block.