Minecraft mid-command delay for 1.15.2

minecraft-commandsminecraft-java-edition

How do you put a delay in the middle of command?

I'm making a TNT run (without TNT) and my issue is, when you start TNT run and you start jumping, sometimes a command block will register the block under you and delete it, and sometimes it will happen even before you will jump again, so you will fall to another layer/void instantly without making a mistake.
Here is the command that I'm using:

/execute as @a[distance=..100] at @a[distance=..100] if block ~ ~-0.5 ~ cyan_terracotta run setblock ~ ~-0.5 ~ air 

(command block is "unconditional" and mode is "repeat (purple)")

All I want is just a delay; for example, half a second between "command block realised there is cyan_terracotta under player" and "setting block air under player" to let the player jump before falling down the layer.

Best Answer

You can't do it in one command, as far as I know. However, you can use a scoreboard objective to count the ticks that a player has been on cyan_terracotta for.

First create a dummy scoreboard objective: (I've called it obj here)

/scoreboard objectives add obj dummy

Then reset scores for players who aren't standing on cyan terracotta:

/execute as @a at @s unless block ~ ~-1 ~ cyan_terracotta run scoreboard players reset @s obj

Now increment the score for players who are on cyan terracotta:

/execute as @a at @s if block ~ ~-1 ~ cyan_terracotta run scoreboard players add @s obj 1

Then run your command at each player when it has been half a second:

0.5 seconds * 20 ticks per second
10 ticks
/execute as @a at @s if score @s obj matches 10.. run setblock ~ ~-1 ~ air