0

Me and my friends are making an advanced parkour map and it is filled with redstone.
One of the repeater circles has 4 command blocks with the following command:

/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:stonebrick 1 /tp @p @e{type=Villager]

When ANY player steps on mossy stonebrick (minecraft:stonebrick 1) it teleports the nearest player to the command block to the villager regardless if he step on the mossy cobble. So we edited the command to:

/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:stonebrick 1 /tp @a @e{type=Villager]

Which is what is now. It's temporarily but works like it's supposed to, but now I have to re-teleport the villager whenever I'm working on a new addition, which is annoying. Not to mention on how far another the other person has to go if he is testing out the parkour map.

That brought me to an idea: Find the person responsible and teleport only him. I know this is possible because I found a parkour map that does this (unfortunately I cannot find the responsible command block for this).

TLDR: How do I execute a command that detects if anyone steps on mossy stone bricks and teleport the responsible player?

(P.S. The map that this kill the responsible player [I need to teleport]: http://www.yourminecraft.com/lava-and-slime-parkour-map)

  • the "/" on the secondary command is unnecessary, but im not sure if it affects its function – Chemical Comrade Nov 29 '16 at 6:32
2
/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.

  • This would be the command for 1.13+: /execute as @a at @s if block ~ ~-1 ~ minecraft:mossy_stone_bricks run tp @e[type=minecraft:villager,sort=nearest,limit=1] – user232393 Sep 10 at 20:57

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.