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 block high wall, they jump. <!--y avoid falling 4 or more blocks (to avoid taking fall damage). <!--y all float in water (except for iron golems, which sink).

Farm animals
Farm animals are attracted to certain items held by the player. Wheat is used for cows, mooshrooms, and sheep; carrots for pigs and rabbits; and seeds for chickens. If two animals of the same species are fed that item within five minutes of each other, they will walk towards each other into a "kiss" to spawn a baby animal of the same species. Upon taking damage, an animal will sprint in random directions. Animals avoid lava and drops of more than one block. Farm animals may wander into water in their path, and will always swim upwards.

Pig being ridden by a player
If the player is holding a carrot on a stick, the pig moves in the direction that the player faces. <!-- pig gradually speeds up until it moves at 5 blocks per second. It will stop responding to the player if it touches water. <!-- pig will slightly speed up when the player right-clicks.

Villager
Adult villagers will 'socialize'. This is modeled by a pair of villagers moving to face one another or the player at a distance of about a meter, as if they were talking. Sometimes larger groups will form in this way. Villager children '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 behavior.

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 sometimes stop and stare at the golem. <!-- golem may in turn offer them a poppy. When an iron golem offers children a poppy, they will approach slowly and run away as soon as they have the poppy.

Villagers will breed depending on the number of "houses" available.

Bat
Bats are the only passive mob in Minecraft that fly, and the only flying mob in the Overworld. Bats spawn in caves, where the light level is 10 or less (higher than for hostile mobs, which is 7 or less) and hang upside-down during the day. At night or when approached by the player, bats will take off and fly around randomly. All bats will attempt to enter a cave when daylight approaches, even though they are not affected by daylight.

Squid
Squid spawn and swim in water. If not in water, they don't move at all. <!--ir tentacles always move, even if they're not in water. If they are not in water they will suffocate and die within a few seconds.

Ocelot
Ocelots sprint away from a player if the player is close, unless the player is still. When a player holds raw fish, the ocelot slowly moves closer. Ocelots can hunt chickens.

Tamed cat
A tamed cats will follow its owner, and if near its owner, it will wander within 8 blocks. Tamed cats that are standing will teleport to its owner if more than 16 blocks away. Unlike wolves, cats don't attack. Tamed cats will often sit on chests, preventing players from using them. Tamed cats also "scare" creepers away, however they do not attack them.

Wolf
Wolves are neutral mobs that spawn in forest and taiga biomes. Wolves live in packs of up to ten, and will naturally attack sheep and skeletons. <!--y will wander around in the pack and ignore you, but if you attack one, all wolves in the vicinity will turn hostile. <!--y will shake when getting out of water. Wolves only despawn when hostile.

Tamed wolf
A tamed wolf will follow its owner, and if near its owner, it will wander within 8 blocks. Tamed wolves that are standing will teleport to their owner if more than 16 blocks away. Wolves will attack any mob or player (with the exception of creepers) that its owner attacks. It will also attack any mob or player that attacks its owner. Currently in PE, tamed wolves will attack creepers, causing the creeper to detonate.

Enderman
Endermen are neutral mobs that spawn in the End and the Overworld. <!--y will pick up blocks and carry them around, eventually replacing them somewhere else. This block handling is random; i.e. it will not purposely tear down your wall, but may "accidentally" breach your defenses. <!--y are passive at first, but turn hostile if you put the crosshairs on its head or torso. Unlike wolves and zombie pigmen, endermen near it will stay neutral. It teleports upon taking damage (unless you look at its legs), sometimes when attacking, or if it is hit with a projectile. In daylight, endermen will become peaceful and will teleport away if approached by a player.

Zombie Pigman
Zombie pigmen are undead neutral mobs that roam around the Nether in packs of 4.

Cave Spider
Cave spiders behave the same as spiders, except that they can fit through smaller spaces, and they poison their target in normal or hard difficulty.

Creeper
Creepers will silently approach any player they see, attempting to get within a one-block range by path-finding around obstacles in their way. When a player is within one block, they will emit a sibilant hiss and ignite a 1.5-second fuse. If the player leaves this one-block range within 1.5 seconds, the creeper will abort its countdown and resume its attempts to reach the player. But if the player is still within several blocks of the creeper (distance increases with difficulty) when the fuse runs out, the Creeper detonates, destroying blocks in the area as well as significantly damaging the player.

Unlike most mobs, creepers remain a persistent threat during the day, since they neither burn nor become passive in the sunlight.

Creepers will run away from ocelots, but will continue to chase the player.

Slime
Unlike other mobs, Slimes don't target players; they just move toward the closest one. When no player is within 16 blocks, they hop in one direction and turn occasionally. Slimes will not avoid fire, deep falls, or other things that hurt them, making them easy to trap and kill. Slimes can swim.

Ghast
Ghasts can seek out players from 100 blocks away. Once they come within range with a line of sight, they shoot fireballs, which have ⅓ 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. This is since ghasts don't have a search mode.

Spider Jockey
<!-- spider controls how both mobs move. Other than that, both mobs act normal.

Blaze
Blazes fly when aggressive, and sink when passive. About every 10 seconds, they will catch fire, then shoot 3 fireballs at their target in quick succession. <!--y tend to strafe right (your left if you're facing them) when attacking. Blazes are damaged by water and snowballs, as well as rain.

Ender Dragon
<!-- Ender Dragon flys around the End, occasionally swooping down and charging at the player. It can regenerate health by flying near one of the multiple ender crystals in the End. <!-- Ender Dragon only takes $1/4$ damage unless hit in the head. <!-- Ender Dragon will fly away from the player if they look at it, except when it charges them.

Wither
When spawned by the player, it will be invulnerable for about 10 seconds, then it will create a huge explosion. It hovers 4 blocks above their target. <!-- three heads (projectiles) will attack the player and all mobs that are not undead, and each head can attack a different mob. However, movement is only controlled by the middle head. <!-- wither regenerates health at about two health (one heart) per second when damaged. <!-- wither will break blocks around them upon taking damage. When the wither reaches half health, it will stop flying, will be immune to arrows and will start regenerating hp.

History
Künstliche Intelligenz 生物AI