Mob AI

Each type of mob in Minecraft has a certain AI (Artificial Intelligence) system with different behaviors and mechanics. Passive mobs will flee in random directions after being hurt, while hostile mobs will face and chase/attack the Player as soon as they come close. Neutral mobs will remain neutral until a player or mob attacks it, at which point the neutral mob will turn hostile toward and attack the entity that hit it.

All Mobs
All mobs randomly walk around. When they come to a 1 high wall, they jump. They avoid falling 4 or more blocks (falling 4 or more blocks means taking fall damage). They all float in water except for slimes, magma cubes, and iron golems, which sink.

Farm Animals
Farming Animals: chickens, cows, pigs, and sheep, are attracted to light, grass, or wheat carried by The Player. If two animals of the same species, within five minutes of a feeding, are fed wheat, they will walk towards each other into a "kiss" to spawn a baby species of the fed animal. If an animal is damaged, it will sprint in a random directions. All animals wander in a random direction for a short amount of time, then changes its direction. Along with other mobs, animals avoid lava and areas greater than one block downwards, and will jump over blocks in their direction that are no greater than one block. Farming Animals will wander into water if in their path and will always swim upwards to the top of the fluid, even if a block is blocking air.

Villager
When first introduced, Villagers had a similar AI system to other Passive mobs like Farming animals, and remained in their houses unless the wooden door is opened and allowed to walk outside. After a series of twelfth-week snapshots, Villagers have gained a more complex AI system.

As of version 1.2.3, adult villagers will 'socialize'. This is modeled by a pair of villagers moving to face one another at a distance of about a meter, as if they were talking. Sometimes larger groups will form in a similar way. Child villagers 'socialize' in the same way as the adults, and will also sprint around the village, seemingly playing tag. All villagers will attempt to enter houses when it is raining or at night, and will also flee from zombies. Note that identifying a 'house' is a challenge for a computer AI, and this may give rise to unexpected villager behaviour.

Villagers will neither attack nor flee if the player attacks them, but if their village is large enough to have spawned an Iron Golem it may arrive to protect them. Villagers will also interact with the golem: when they see one, they stop and stare at it. The golem may in turn offer them a rose as a symbol of friendship. Because the children are shy, when an Iron Golem offers them a rose, they will approach slowly and run away as soon as they have the rose.

House
Villagers try to live in 'houses', and they use the number of available houses as a cue for whether or not to breed. To a villager, a house is a door which has at least 1 building block (usually wood) at the same height within 10 blocks of the 'inside' of it. An acceptable 'house' for a villager does not require any form of lighting nor a roof. This means a building can have as high of a roof as possible or no roof at all, and can be completely dark, as long as the opposite wall to the door is within 10 blocks. Also, the floor material of the house is not relevant, and can be 1 block lower or higher than the door upon entering (As long as the door frame accommodates head space for a higher floor).

It is possible to build very many seemingly reasonable house-like structures that the Minecraft AI cannot recognize as houses, and it's also possible to build structures which do count as 'houses' despite being parred down to the very minimum.

Note that because a 'house' needs a door, and zombies in Hard mode can destroy doors, after a zombie attack even the surviving villagers may stop recognizing their former residences as houses and become lost when they wander off into the wilderness. Although, if the complete structure of a 'house' is destroyed except the door, previous residents will still congregate on the 'inside' of the lone door, but newly spawned villagers will not recognize the lone door as a house.

Other important notes: A villager cannot find a house unless the door of the house (regardless of structure) is within 15 blocks. While actively occupying a 'house' (as to escape rain or such), villagers will stay within 3 blocks of the door and will not wander throughout the structure. Villagers will try to squeeze as many of themselves as possible into a single 'house' if it is the nearest to them.

Hostile
Before 1.0, hostile mobs such as zombies ignored everything except their target, once they had been aggravated by the player or another entity, leaving them vulnerable to environmental dangers such as lava pits and sudden cliffs. The mobs would charge blindly forward instead of attempting to avoid said hazards. This allowed for the creation of simple pitfall traps.

Zombie
Zombies attack by moving relatively slowly towards a player or a villager, and will damage them on contact. They do not try to avoid being hit, and will continue to pursue the player even when being counter-attacked. If they encounter a door they will bang loudly on it, but they can only actually break through a wooden door on the Hard difficulty setting or in hardcore mode. They cannot break through iron doors. In hard mode, their habit of attacking doors makes them a significant threat to villagers, as after a few days of attacks they can destroy every door in a village, leaving the villagers 'homeless' and highly vulnerable. (See the Villager AI description for further details.)

Before 1.2
Zombies made no attempt to avoid cliffs or other obstacles, and would simply try to jump over anything in their path.

1.2 AI overhaul
Zombies make some attempt to seek out the cover of nearby trees or caves, or enter bodies of water to protect themselves from burning up during the day. They also try to avoid damaging falls where possible.

Skeleton
Skeletons will circle the player with a constant radius while attacking in an attempt to evade attacks.

Before 1.2


The presence of a skeleton is identifiable by the soft rattling sound of its bones. It will walk and jump around aimlessly until it spots the player. At that point, it will start firing arrows in the player's direction with moderate accuracy, aiming at head level when it is at full health and at torso level when injured. When approaching a target, a skeleton will move to its left just before it fires an arrow. It will also run, making itself more difficult to hit. However, these tendencies often get skeletons stuck in small alcoves and lava.

Their arrows travel in a straight line after Beta 1.8, however, prior to Beta 1.8 their arrows used to travel to in a wide arc, which would sometimes causes the arrows to get stuck in the ceiling. If skeletons are in a 2 block high area, they could almost never hit you unless they were very close, or if their health was low, and they were shooting from their torso.

1.2 AI overhaul
Skeletons received a similar AI update to the Zombie AI update. As with zombies, skeletons also attempt to seek out the cover of nearby trees or caves, or enter bodies of water to protect themselves from burning up during the day. Skeletons will also flank the player out of their hiding spot should the player try to hide from the skeleton. For example, a skeleton spots the player and the player attempts to hide around a corner of a wall. The skeleton will seek out the player and attack once they found them. Similar to creepers, skeletons now avoid falls if they can.

Spider
Spiders run at the same speed as the player, and attack by leaping at you. If encountered in light levels of 9 or higher, they don't try to attack you unless you attack them. However, a spider that spots you in a light level less than 9 and then ventures into a a light level 9 or higher will remain hostile. Spiders can climb and see through walls. This will often leave them pushing against the ceiling of an adjacent cavern in a vain attempt to reach the player if spawned nearby underground. Since they're 2 blocks wide, they can't fit through doorways, though this wont stop them from trying.

Cave spider
In addition to what is mentioned in the "spider" section, cave spiders are smaller, and they poison their target, but only in normal mode or harder.

Creeper
Creepers prepare to explode when they are one block away from their target. As long as the target is still in a one block range, creepers will detonate after exactly 1.5 seconds. Before 1.2, they would circle to your left. Starting in snapshot 12w05a, they got the same updates that zombies and skeletons got. Creepers don't burn in sunlight. They will try to pathfind around blocks in their path to get to the player.

It is their pathfinding that gave creepers their reputation. As they are always trying to get as near the player as possible, they will often appear to hide and seem to ambush the player. They also don't have many weaknesses, making them harder to slay than your typical zombie.

Creepers will flee from ocelots and cats. This is very useful, as tamed cats will follow the player and thus protect them from creepers.

Slime
Unlike other mobs, slimes don't target players, they just move toward the closest one, even if shot by a skeleton or if the player is through a wall. When no player is within 16 blocks, they hop in one direction and run into walls then turn. Because they don't target a particular player, they won't attack you if you attack them in creative.

Ghast
Ghasts can seek out players from 100 blocks away. Once they come within range and can see you, they shoot fireballs, which have 1/3 the explosive force as a Creeper, and light surrounding blocks on fire. Unlike other hostile mobs, Ghasts will not attempt to draw close to the player once aggravated, but will instead hover about 24 blocks from the player, firing repeatedly at them. They do not become aggressive under any circumstances in creative mode, but it has been confirmed that this is a bug. This bug happens because ghasts don't have a search mode.

Spider Jockey
The spider controls how both mobs move. The spider acts like a normal spider, and the skeleton acts like a normal skeleton, except its movement is determined by the spider it rides upon. The skeleton's arrows will sometimes damage the spider jockey itself. This can be encouraged by digging a 1 block wide hole 3 blocks straight down and simply standing in it; the spider will sit over top of the hole and the skeleton will fire straight down in an attempt to hit the player, but will only end up hitting its mount. Occasionally, the skeleton will get off the spider. This will also happen if you log out and back in.

Blaze
Blazes fly if they see you. About every 10 seconds, they will catch fire, then shoot 3 fireballs at you in quick succession. The fireballs will set the ground alight wherever they land. They tend to strafe right (your left if you're facing them) when attacking. Blazes are damaged by water and snowballs, as well as rain/snow if spawned in the Overworld. If blazes can't see you, they don't fly. You can see them walking along the ground and jumping up 1 block high inclines when they're not attacking you.