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

It works and they don't attack if he has a pumpkin on his head :)
Why?