When they run over the "start" pressure plates have a scoreboard objective set
/scoreboard players set @p <objective name> 1
And have a clock running all the time doing this command
/execute @p[score_<objective name>_min=1] ~ ~-1 ~ setblock ~ ~ ~ air
The execute @p[score__min=1] means "Do this command relative to @p with a score of one in that objective"
And the setblock sets the block under the player to air.
Hopefully this answers your question.
/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:stonebrick 1 /tp @p @e{type=Villager]
When ANY player steps on mossy stonebrick (minecraft:stonebirck 1) it teleports the nearest player to the command block to the villager regardless if he step on the mossy cobble.
The /execute
command modifies the sender of the command to that of its target. Any subsequent selectors in commands being run are going to use the executor as the sender.
This comes into play with sender bias, which forces a target selector to target the entity that ran the command. The command you've presented already uses it. The executing player will be the one to be teleported, so long as they are alive.
The @a
selector is the only target selector capable of targeting dead players. If a player dies while on top of stonebrick, they will teleport the nearest living player to them rather than themselves, because @p
cannot target dead players.
The fix for that in particular is to use the @a
selector while reducing the count (via c
parameter) to 1, which also enforces a sender bias. The command itself is still functional as you need it without having to have changed anything else.
/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:stonebrick 1 /tp @a[c=1] @e[type=Villager,c=1]
/execute
is used to change the sender and origin of commands to run. /tp
is being run through the player, not by the command block. @p
will be in reference to the executing player's location, and due to sender bias, @p
will always target that player so long as that player is alive. Your command was originally working fine apart from the dead targeting flaw.
Best Answer
Try the following to replace all command blocks in a hundred block radius from you:
Do this a few times all over the map.