Do Mobs Despawn in Minecraft 1.8? [duplicate]

I understand monsters only spawn in a 9 x 9 grid of chunks centered on the player, and I assume they stay around while they remain within that distance of you. But do they despawn as soon as you move away from them? Or do they remain? If so what (if anything) causes them to despawn? Are the rules any different for passive mobs?

Will running far away from an area and then coming right back clear it of monsters?


Solution 1:

My answer is no longer correct, even though, at the time of posting, it was. Look to some of the other answers (particularly the bounty winner) for more up to date information.


Most important rule: when a chunk is unloaded, so are the mobs (and all other items) on it, although passive mobs won't be removed.

There is also a limit on the number of mobs that can be loaded at one time: 200 hostile and 15 neutral mobs (I don't know if there's a limit on passive mobs). Also, hostile mobs are removed if they leave the 9x9 chunks that they're allowed to spawn in.

Running away will usually allow you to stay out of the reach of hostile mobs, since a chunk needs to be loaded a certain amount of time before mobs will start to spawn, but the chunks immediately behind you could have the max allowable mobs, making it dangerous at best to turn around.

Take a look at the wiki for more information.

Solution 2:

From the EntityAnimal class in EntityAnimal.java:

protected boolean canDespawn()
{
    return false;
}

This should apply to all passive mobs. (I checked, they all extend the EntityAnimal class.)

Wolves however are interesting:

protected boolean canDespawn()
{
    return !isWolfTamed();
}

So this means that tamed wolves do not despawn, while wild wolves do despawn.

It seems that slimes and squid will also despawn. Both classes contain this method:

protected void updateEntityActionState()
<snipped>
    despawnEntity();
<snipped>

I didn't see any other references to despawning.

Solution 3:

As of Minecraft 1.8, these are the two main despawning rules:

  • If a mob has not been within 32 blocks1 of a player for more than 30 seconds, it has a 1 in 800 chance every tick of despawning (about 1 in 40 every second)
  • If there are no players within a 128 block radius2 of a mob, it will instantly despawn

Exceptions:

  • Mobs with nametags will never despawn, except...
  • Mobs which have picked up items (i.e. were not spawned with that item) will never despawn, except...
  • When the gamemode is set to peaceful, all hostile mobs will despawn (including those with nametags, or those who have picked up items)
  • Passive mobs will never despawn (except chickens originally spawned as chicken jockeys, which will follow zombie despawning rules)

For those who like diagrams, this image will help: (From the Minecraft Wiki)

Diagram of which the information is outlined in dotpoints

Footnotes:

1Not sure whether this is a sphere or a cylinder It is confirmed to be an Euclidean sphere (like the the instant despawn zone). Testing apparatus:

The zombie despawned after about 2 mins when I stood more than 32 blocks below it

2 An Euclidean sphere with a radius of 128 blocks

More Notes:

  • If there are more mobs than allowed by their mob cap, no special despawning rules are followed. Mob spawning is simply suspended until they despawn naturally. Source (looking for a better citation)

Solution 4:

EDIT: The forum post is apparently gone in one of curse's migrations of the minecraft forums. Until I can find a good suitable replacement the Wiki page is the best I can come up with which can be found here.

Information most notably claims there is a 60 block radius around the player that hostile mobs can spawn in, but there is a 24 block buffer zone centered around the player that hostile mobs will not spawn within..

A quick answer to some of your questions from my own observations:

  1. Yes, they will despawn if you move far enough away.

  2. I am not sure of the exact rules, but I would bet the 60 block range is one of them. I have had things fairly close to me (Within the 24 block range) just despawn at times for apparently no reason (most notably with creepers believe it or not).

  3. They are a bit different in the areas they can spawn within to begin with (grass and well lit) as well as the range and count of them. It also appears that they follow the same general guidelines for despawning, based on their spawn rules.. The forum post mentioned above can get you the details there (their distances and the like).

  4. Yes, if you run far enough, what was there will despawn. However, it is just as likely that the area will respawn, if it is night, as you are running towards it because of the 'donut' spawn area I mentioned above (closer than 60 blocks, farther than 24 blocks).

Anywho, enjoy the link, helped me out quite a bit!