I was wondering if someone could help me with my problem. What I am having is that I want to make some way if a player walks into an armor stand structure then they will /TP to a certain location. I know this has been done is several instances e.g.

, http://www.theredengineer.com/micro-house.html, and http://www.theredengineer.com/nano-house.html. If you have a better way to search these commands then I do then please help me! Thanks!


EDIT: See the comment to this answer by @Skylinerw for shortening the full command, and if it is possible for what you want to do.

Without any mods or server plugins, the only option is Command Blocks.

One way to do it is by chaining two "execute" statements to a "tp" statement, which can easily be accomplished if you don't want any fancy "facing this way" requirement.

Syntax for the execute statement that we are looking for:

execute <entity> <x> <y> <z> <command>

Because of how the execute command works, and how it can be chained (meaning the command being another execute command), the last entity/entities targeted are the ones acted upon by the final command.

So our flow is this:

  1. Find our Armor Stand entity
  2. Detect a player right near it (optionally specifying a facing position)
  3. Teleport the player to the destination

If you are planning like the tents that TheRedEngineer made (the teleport from location also being a teleport to location), you need to make sure you prevent the player who teleported from quickly teleporting back and forth without being able to move away from it (since he used which way a player faced, it prevented that from happening).

So now we have this, still not complete, layout (with line breaks added for easier reading):

execute <armor stand> ~ ~ ~
execute @a[r=1] ~ ~ ~
tp @p <x> <y> <z> [<yaw> <pitch>]

If you are familiar with targeting entities by name or scoreboard objective, you would place that one you wish to use to target your armor stand (don't forget to set it up!).

The first execute statement (if you specify the check correctly) would target the armor stand and make sure the next command is executed relative to where the armor stand is while the second execute statement finds all players within a 1 block radius (assuming you want a small area that they can teleport from, of course) (this is the minimum value we can use due to not having access to fractional numbers or the relative coordinate specifier (~); zero 0 would make the test pretty much impossible to target anyone). Since we specified all players (@a) in that little area, we are then executing the command on behalf of all of them (hence why jumping to the nearest player @p specifier).

I could give you a flat-out result, but not knowing your situation, and there are already examples on here as well as the Minecraft Forum for how to target entities by scoreboard objectives and names, I'll unfortunately have to leave that for you to find.

Source for execute and tp commands as well as target specifiers at: http://minecraft.gamepedia.com/Commands

  • 1
    "someone please verify for me" - That is correct, but in this case you don't need two /execute commands. The /tp command has a selector, so you can just use that in place of the second /execute (i.e. /execute <armor stand> ~ ~ ~ /tp @a[r=1] <x> <y> <z> [<yaw> <pitch>]). If the nested command being used doesn't have a selector (such as /setblock), then two /execute commands are indeed necessary.
    – Skylinerw
    Dec 31 '16 at 0:27

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.