Minecraft wiki entry for Combat, associated text: Hostile endermen will teleport away when the player closes in on them to strike. When this happens in a small underground space, the enderman may teleport into inaccessible caves or to the surface. They will not teleport back to the player unless they move to an area that has enough space for the enderman to teleport back. On the surface, an enderman's tendency to teleport away when the player is close enough to attack can be used to keep an attacking enderman at bay. The player can also change to third-person view by pressing F5 (Fn + F5 on Macs) to make sure the player can't be attacked from behind because of endermen having a tendency of teleporting behind them.