Before I say anything, I would like to say that I do not have much experience with commands.

Is there a way to use /execute to detect if a player is located at an entity? I tried execute if entity @p at @e[type=minecraft:armor_stand,limit=1] run say Successful, but it always returns successful. Any ideas?

2 Answers 2


Let's first see why yours doesnt work and work from there. Your command can be separated in basically 4 parts:

  • execute Execute command, followed by 2 subcommands
  • if entity @p If entity @p exists (if any entity is targeted by the selector, @p in this case)
  • at @e[type=minecraft:armor_stand,limit=1] Execute at these locations (all entities' location targeted by @e[...])
  • run say Successful run something with all previous "configurations"

Your command will run at all armorstands, limited to 1, only if there is a player online.

We can run as every player and at their location, only if there is an entity close enough. Note here that if the if fails after the as, only that one entity target by the as will stop execution. This would translate to:

  • execute Normal execute start
  • as @a Execute as every player (So the next subcommands will run for each entity target by the as, every player in this case)
  • at @s, @s refers to self, whatever that is executing the commands, but in this case it is overwritten by as @a. So until this point, we will run as every player, at their own location.
  • if entity @e[type=minecraft:armor_stand,limit=1,distance=..1] Will only execute if there is an entity who fufills the description (Must be an armorstand, at max 1 block distance)
  • run ... Note that at this point, @s will refer to the entity that passed successfuly in all test, aka a player who is up to one block of distance from an armorstand. You can do something like say @s and it should say the player's name.

In full:

execute as @a at @s if entity @e[type=minecraft:armor_stand,limit=1,distance=..1] run say @s

Use target selector arguments to select only entities within a 0 block radius / 0 blocks away from the player.

[distance=0] will select entities in the same block as the armor_stand.

[distance=..5] will select entities up to 5 blocks away from the armor_stand.

(For Bedrock Edition use r and rm selectors.


  • 2
    distance=0 will select entities with the exact same coordinates, rather than the same block.
    – BunnyMerz
    Sep 10, 2022 at 20:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .