One thing to note about mobs "looking" through glass - they can't actually see through glass, the AI method that makes mobs look at you completely ignores obstructions (by contrast, the ones that control attacking or targeting a player do consider line of sight, with the exception of spiders, and any other similar entities, as well as zombies targeting villagers, and mobs in pursuit of a target. Even then, at least as of 1.6.4, the "EntityAITarget" class makes most of them forget about you within 3 seconds).
Whether or not they actually see the player is another matter, they will not actively chase a player if you're behind a window, if they did they would detonate at the point of being close to them as their detonation is tied to their ability to pathfind to players, but Creepers can display some odd behaviour at times. When you put your crosshairs over their face when you're at the other side of a window, as evidenced on my test world on creative, they will look straight at the player, and then seemingly only look away when they move elsewhere. They do it on all other worlds I've tried it on too.
It's almost as if the monster in the game is attempting a pathfind, but it cannot due to solid blocks being in between.
There was a period of time, I can't recall if it was Alpha or Beta, when creepers a- could see you through walls and b- wouldn't reset their detonation timer when line of sight was broken. Resulted in the situation where you'd have a creeper waiting outside your front door, close the door just in time, go around to the back door, open the back door and instant BLAM because it had followed around the outside of your house as you moved through the interior. That's fun for a gritty oldschool survival game but I'm not sure that the majority of players would enjoy it these days. Similarly I'd rather not have creepers hurling themselves through my windows at night! It's bad enough not being able to enjoy pretty wooden doors in hard mode unless you fence off your front yard (or put said doors on sideways, but then you can't use pressure plates to open them).
@ Princess Garnet: My guess is that spiders crawling up into corner tops and sitting there is a line of sight issue. I'm pretty sure that general mob AI directs them to go all the way up to the top of something once they've started climbing it (see zombies/Testificates/etc getting stuck at the top of vines/ladders), but if there's an overhang or roof, the spider can't reach the top. And then it won't attack the player because it's wedged in closely enough to become "blind" by being slightly clipped into the block.
Might be somewhat off topic, but on the subject of pathfinding and sight of mobs, what causes spiders to sometimes crawl up towards a corner and then just seemingly stay there? I'm not sure if this happens in "older" versions though but it's something I've wondered recently.
This definitely happens in older versions, especially with cave spiders; I've cleared out a cave spider spawner only to look up and see a bunch of cave spiders in a 1x1 space in the ceiling (most often; what likely happens is that they do try to jump down but they immediately collide with the other side of the hole so they end up going back up). This is less of an issue for corners or a wall-ceiling (they will still climb the wall and get stuck below the ceiling until you pass below them, if there are several spiders they will occasionally knock each other down, except for cave spiders in a 1x1 space, which merge together).
That said, it may be more pronounced in newer versions (easier to get stuck, even when the player attacks them); their AI was updated in 1.8 as part of a general AI overhaul, removing the "original" AI code that some mobs still used (I recall hearing about a lot of issues with spiders and endermen, including spiders losing the ability to see through walls for a time; these mobs presumably still used the old AI until then because of their non-standard behavior, otherwise, the biggest difference between the two is that the newer AI enables pathfinding around obstacles):
Other mobs which use the newer AI system also exhibit some strange behavior, for example, witches completely ignore you while wandering around; maybe in the case of spiders the "climb wall" function is now an AI "task" instead of part of the general mob AI (the "old AI", which was still used by all mobs to some extent in 1.6.4, e.g. handling basic movement and collisions) and it incorrectly overrides other tasks:
Or even creepers not moving during their countdown, both of which I fixed (the code does suggest creepers not moving was intended but the witch behavior is considered to be a bug):
Note that EntityAIArrowAttack and EntityAIWander have the same "priority" (2), I changed EntityAIWander to 3, and the other two below it to 4.
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIArrowAttack(this, 1.0D, 60, 10.0F));
this.tasks.addTask(2, new EntityAIWander(this, 1.0D));
this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(3, new EntityAILookIdle(this));
I removed the lines with "setMutexbits" and "clearPathEntity"; which cause this AI function to override others based on their "mutex bits" (for "mutually exclusive") and makes them stop moving by removing their path (this causes them to completely forget about you, e.g. if a creeper is about to explode and you go behind a corner it will just stay there despite a clear path around it).
public EntityAICreeperSwell(EntityCreeper par1EntityCreeper)
this.swellingCreeper = par1EntityCreeper;
public void startExecuting()
this.creeperAttackTarget = this.swellingCreeper.getAttackTarget();