Enderman attacks a player if he's looking at him.

We still need to check if there is a wall between the player and the enderman, but it works.
They don't attack if he has a pumpkin on his head :)
Why not just hardcode the value of cos(0.09), with a comment.