Most described details in that thread are not changed. Here are some clarification and update for alpha 1.2.6 and beta 1.1_02.
mobs spawn in packs of up to 12
4 per chunk at a time, maybe less, no more.
2) Mobs can spawn on man-made materials.
Mobs only spawn on opaque blocks, don't spawn in liquid. Non-blocks, plants and liquid are obviously not opaque. But these are also not opaque:
leaves (only when graphics are fancy), glass, stone slab, monster spawner, wooden/cobblestone stairs, soil(60), snow, ice, cactus, fence.
3)Spawn activity only exists in a 144x144 area around you and not within 24m of you.
17x17 chunks area around all players are marked as eligible for spawning. These chunks are stored in a HashMap which doesn't guarantee traversal order.
7)There is a cap of 200 hostile mobs and 15 friendly mobs at any given time.
cap <= maxNumberOfCreatureType * numberOfEligibleSpawningChunks / 256
monster type is 100, animal type is 20. so 112 monsters and 22 animals for single player.
3) Roll a random number. 1:10 chance proceed to 4), otherwise skip chunk and go back to 2).
1:50 chance
6) If L1 is inside a rock or other solid area, bail out of the spawn function completely. Ignore the remaining chunks.
Only ignore this one chunk and process the remaining chunks
7) If L1 is legal it will be the location of a mob pack, pick 6 locations roughly normally distributed around L1, L(i)
12 locations. But there is also a local limit checking that should be added to the original algorithm:
14) ...
14-a) If there are already localLimit mobs spawned in this chunk, ignore remaining L(i). localLimit = 4 for any Living entities, or 1 for Ghast.
15) ...
Here is some "despawning" algorithms for why some mobs disappear after spawning:
[*:1ju0hdfd]Proximity check of living entities happens once every tick. If any living entities are more than 128 meters away (Euclidean distance) from any players, they are set as dead.
[*:1ju0hdfd]Idling check of living entities happens stochastically once every 40 seconds only for whom have been idle for more than 30 seconds. During this check, if anyone are more than 32 meters away (Euclidean distance) from any players, they are set as dead. If they are within 32 meters to some player during the check or they are taking damage anytime, their idle timers are set to zero. Monsters (except Ghasts and Slimes) idle 2 times faster than other living entities when light level >= 12.
[*:1ju0hdfd]Chunk unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.
You're welcome to ask me if you find any inconsistency.
Edit: leaves are opaque when graphics is set to fast.
Edit: 12/30/2010
Edit: 12/30/2010
Edit: 1/14/2011 changed the title. Notch has modified the spawning algorithm. So I may look into it after MCP is updated to lastest version. I don't have time to read the source now before it's de-obfuscated.
Opaque? Leaves? Monsters are still spawning atop my trees, on the leaves.
Rollback Post to RevisionRollBack
BETA
"When we release a pure bugfix update, people get VERY upset ("NOTHING CHANGED!").. Adding features gives us much happier users. But I do realize that it's only happier users in the short term." - Notch
7) If L1 is legal it will be the location of a mob pack, pick 6 locations roughly normally distributed around L1, L(i)
12 locations
I don't have my notes out, but I'm pretty sure it's now 4 sets of 3. L(i) gets randomly offset from the previous move, then returns to L1 for the next set to keep the pack from spreading too far out.
Or maybe it was 3 sets of 4, now that I think of it. Either way, 12 total.
17x17 chunks area around all players are marked as eligible for spawning. These chunks are stored in a HashMap which doesn't guarantee traversal order.
I've tested this multiple times, and NO mobs have been able to spawn in the outer 208 chunks, even when mobs aren't allowed to spawn in the inner 81 chunks.
3)Spawn activity only exists in a 144x144 area around you and not within 24m of you.
17x17 chunks area around all players are marked as eligible for spawning. These chunks are stored in a HashMap which doesn't guarantee traversal order.
Maybe I'm not clear on all the details yet about how the game works, but this seems like quite a big increase in size.
Am I missing something or wouldn't a nearly 4 times larger spawning area make the game quite a lot easier, at least if you don't move around a lot?
And are you also saying below this that the monster cap is actually lower now? 112 instead of 200? or am I wrong?
So fewer monsters in a much larger area then.
I've no code to back it up, but my observations (in Clean Room, and using transparent textures) have been that mobs can despawn within the spawning radius, if they're far enough from the player. These were not just passing out of draw range, as I could see other mobs out beyond the ones that disappeared.
EDIT: forgot the point of that! If more distant mobs are randomly removed, eventually they build up closer to the player.
7) If L1 is legal it will be the location of a mob pack, pick 6 locations roughly normally distributed around L1, L(i)
12 locations
Seems inconsistent?
EDIT: Or does it pick 12 possible locations but only use 4?
This is an update to the original algorithm. Now there will be 12 locations for "Individual Spawn Loops". And I thought there is a local spawning limit checking in the original algorithm between (14) and (15)? Anyway, it should be:
14) If mob class was Spider, roll a random number. 1:100 chance also spawn a skeleton and have it mount the spider.
14-a) If there are already localLimit mobs spawned in this chunk, ignore remaining L(i). localLimit = 4 for any Living entities, or 1 for Ghast.
15) Get next L(i) and go back to 8).
I think this can make mobs more possible to spawn on irregular terrains.
I've tested this multiple times, and NO mobs have been able to spawn in the outer 208 chunks, even when mobs aren't allowed to spawn in the inner 81 chunks.
You raised an interesting issue. This thread is about how mobs are spawned, not how they are "despawned". However, as you've asked, I can answer this for you:
[*:2599n1zy]Proximity check of living entities happens once every tick. If any living entities are more than 128 meters away (Euclidean distance) from any players, they are set as dead.
[*:2599n1zy]Idling check of living entities happens stochastically once every 40 seconds only for whom have been idle for more than 30 seconds. During this check, if anyone are more than 32 meters away (Euclidean distance) from any players, they are set as dead. If they are within 32 meters to some player during the check or they are taking damage anytime, their idle timers are set to zero. Monsters (except Ghasts and Slimes) idle 2 times faster than other living entities when light level >= 12.
[*:2599n1zy]Chunk Unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.
If you find it incomprehensible why mobs are spawned and killed, you have just learned what is Notch Logic.
You raised an interesting issue. This thread is about how mobs are spawned, not how they are "despawned". However, as you've asked, I can answer this for you:
[*:2tsxtpz2]Proximity check of living entities happens once every tick. If any living entities are more than 128 meters away (Euclidean distance) from any players, they are set as dead.
[*:2tsxtpz2]Idling check of living entities happens stochastically once every 40 seconds only for whom have been idle for more than 30 seconds. During this check, if anyone are more than 32 meters away (Euclidean distance) from any players, they are set as dead. If they are within 32 meters to some player during the check or they are taking damage anytime, their idle timers are set to zero. Monsters (except Ghasts and Slimes) idle 2 times faster than other living entities when light level >= 12.
[*:2tsxtpz2]Chunk Unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.
If you find it incomprehensible why mobs are spawned and killed, you have just learned what is Notch Logic.
32 meters!?
I'm reading "Euclidean distance" as meaning real-world measurement in 3 dimensions, like the 24 meter radius no-spawn bubble. Right? So there's only an 8 meter zone out there at 24-32 where mobs both can spawn and can't despawn? Interesting... but probably not something I can use right now.
[*:2vf6v11r]Chunk Unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.
I'm fairly certain that on chunk unload, the mobs are frozen exactly as they are, just like items -- all timers freeze, including despawn timers. (Anecdotal evidence: I was watching creepers and other mobs prowl around a desert biome at night; I then portalled over to my main base [which definitely would unload the desert], spent the rest of the night and most of the day there, and then portalled back to the desert just before evening. The creepers were still there, and there were zombies running around on fire.)
You raised an interesting issue. This thread is about how mobs are spawned, not how they are "despawned". However, as you've asked, I can answer this for you:
[*:2j4evn7o]Proximity check of living entities happens once every tick. If any living entities are more than 128 meters away (Euclidean distance) from any players, they are set as dead.
[*:2j4evn7o]Idling check of living entities happens stochastically once every 40 seconds only for whom have been idle for more than 30 seconds. During this check, if anyone are more than 32 meters away (Euclidean distance) from any players, they are set as dead. If they are within 32 meters to some player during the check or they are taking damage anytime, their idle timers are set to zero. Monsters (except Ghasts and Slimes) idle 2 times faster than other living entities when light level >= 12.
[*:2j4evn7o]Chunk Unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.
If you find it incomprehensible why mobs are spawned and killed, you have just learned what is Notch Logic.
So you're saying mobs can spawn in those outer chunks, but are despawned immediately after? Raising the question then, if they are only existing for one tick, are they really "spawning" or are they just temporarily occupying places in the mob limit?
Most described details in that thread are not changed. Here are some clarification and update for alpha 1.2.6 and beta 1.1_02.
4 per chunk at a time, maybe less, no more.
Mobs only spawn on opaque blocks, don't spawn in liquid. Non-blocks, plants and liquid are obviously not opaque. But these are also not opaque:
leaves (only when graphics are fancy), glass, stone slab, monster spawner, wooden/cobblestone stairs, soil(60), snow, ice, cactus, fence.
17x17 chunks area around all players are marked as eligible for spawning. These chunks are stored in a HashMap which doesn't guarantee traversal order.
cap <= maxNumberOfCreatureType * numberOfEligibleSpawningChunks / 256
monster type is 100, animal type is 20. so 112 monsters and 22 animals for single player.
1:50 chance
Only ignore this one chunk and process the remaining chunks
12 locations. But there is also a local limit checking that should be added to the original algorithm:
Here is some "despawning" algorithms for why some mobs disappear after spawning:
[*:1ju0hdfd]Proximity check of living entities happens once every tick. If any living entities are more than 128 meters away (Euclidean distance) from any players, they are set as dead.
[*:1ju0hdfd]Idling check of living entities happens stochastically once every 40 seconds only for whom have been idle for more than 30 seconds. During this check, if anyone are more than 32 meters away (Euclidean distance) from any players, they are set as dead. If they are within 32 meters to some player during the check or they are taking damage anytime, their idle timers are set to zero. Monsters (except Ghasts and Slimes) idle 2 times faster than other living entities when light level >= 12.
[*:1ju0hdfd]Chunk unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.
You're welcome to ask me if you find any inconsistency.
Edit: leaves are opaque when graphics is set to fast.
Edit: 12/30/2010
Edit: 12/30/2010
Edit: 1/14/2011 changed the title. Notch has modified the spawning algorithm. So I may look into it after MCP is updated to lastest version. I don't have time to read the source now before it's de-obfuscated.
"When we release a pure bugfix update, people get VERY upset ("NOTHING CHANGED!").. Adding features gives us much happier users. But I do realize that it's only happier users in the short term." - Notch
I tested it on a cleanroom like flat leaves map. No mob spawned. beta 1.1_02.
Block opacity is an element of game logic which won't be changed by user setting.
*edit- btw i've seen them spawn on leaves, i play on fast
Halfsteps now have an offical name: stone slab.
You are right. Leaves are turned to opaque when graphics is set to fast. I ignored this when dumping data.
Edit: only the opacity of this block is changed.
I hope you can keep this up to date, and get it fully organized to completely replace the old thread.
Double stone slab = on top of a
I don't have my notes out, but I'm pretty sure it's now 4 sets of 3. L(i) gets randomly offset from the previous move, then returns to L1 for the next set to keep the pack from spreading too far out.
Or maybe it was 3 sets of 4, now that I think of it. Either way, 12 total.
I've tested this multiple times, and NO mobs have been able to spawn in the outer 208 chunks, even when mobs aren't allowed to spawn in the inner 81 chunks.
I've no code to back it up, but my observations (in Clean Room, and using transparent textures) have been that mobs can despawn within the spawning radius, if they're far enough from the player. These were not just passing out of draw range, as I could see other mobs out beyond the ones that disappeared.
EDIT: forgot the point of that! If more distant mobs are randomly removed, eventually they build up closer to the player.
Yes, but double stone slabs are not stone slabs.
This is an update to the original algorithm. Now there will be 12 locations for "Individual Spawn Loops". And I thought there is a local spawning limit checking in the original algorithm between (14) and (15)? Anyway, it should be:
I think this can make mobs more possible to spawn on irregular terrains.
You raised an interesting issue. This thread is about how mobs are spawned, not how they are "despawned". However, as you've asked, I can answer this for you:
[*:2599n1zy]Proximity check of living entities happens once every tick. If any living entities are more than 128 meters away (Euclidean distance) from any players, they are set as dead.
[*:2599n1zy]Idling check of living entities happens stochastically once every 40 seconds only for whom have been idle for more than 30 seconds. During this check, if anyone are more than 32 meters away (Euclidean distance) from any players, they are set as dead. If they are within 32 meters to some player during the check or they are taking damage anytime, their idle timers are set to zero. Monsters (except Ghasts and Slimes) idle 2 times faster than other living entities when light level >= 12.
[*:2599n1zy]Chunk Unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.
If you find it incomprehensible why mobs are spawned and killed, you have just learned what is Notch Logic.
32 meters!?
I'm reading "Euclidean distance" as meaning real-world measurement in 3 dimensions, like the 24 meter radius no-spawn bubble. Right? So there's only an 8 meter zone out there at 24-32 where mobs both can spawn and can't despawn? Interesting... but probably not something I can use right now.
I'm fairly certain that on chunk unload, the mobs are frozen exactly as they are, just like items -- all timers freeze, including despawn timers. (Anecdotal evidence: I was watching creepers and other mobs prowl around a desert biome at night; I then portalled over to my main base [which definitely would unload the desert], spent the rest of the night and most of the day there, and then portalled back to the desert just before evening. The creepers were still there, and there were zombies running around on fire.)
No. Monster Spawners have their own independent algorithm from this.
So you're saying mobs can spawn in those outer chunks, but are despawned immediately after? Raising the question then, if they are only existing for one tick, are they really "spawning" or are they just temporarily occupying places in the mob limit?