How do I find out if a player is walking into an armor stand-Minecraft
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:
- Find our Armor Stand entity
- Detect a player right near it (optionally specifying a facing position)
- 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