Minecraft wiki entry for Combat, associated text: The player can wear a carved pumpkin as the head armor piece in order to stop endermen from turning hostile when the player look at them. If they hit an enderman with any kind of sword while doing this, the enderman will not teleport away from them, allowing the player to kill it safely.