I'm having a weird experience with my spawner mentioned above, so I've been idleing for some time to see what spawns, checking every so often, filled in some so now its 4 high, and here is what spawned (checking at unclocked intervals, also I did change it throughout testing a little)
so the first time I got mabe 6 zombies, and then filled in a new cave I found with dirt.
then I tested again to see if I got more spawns, this time 6 skeles.
then I filled in the botom 2 layers so its only 4 blocks high, and I get 6 creepers.
this is strange to me (satanic and random) and am now testing again, this time with no modifications, guessing 6 spiders, then hopefully 6 slimes (doubt it)
Rollback Post to RevisionRollBack
Quote from wynryprocter »
I dug and fell right into it. Got killed so hard that I died to death.
ok, now I got absolutely nothing, and I forgot to mention my idleing spot was the same each time.
mabe it had to do with the fact that I switched to peacefull for my changes, and underground the saturation limit has been reached for the area, I don't know, any help would be apriciated.
also, how do you make your rank say tree puncher or something else?
Rollback Post to RevisionRollBack
Quote from wynryprocter »
I dug and fell right into it. Got killed so hard that I died to death.
I've tried to confirm this myself, so far with no luck. I got one spider and a creeper to spawn at level 7 light, but as of yet nothing has spawned at 8. Perhaps the likelihood of a mob spawning is influenced by the light level of that square...
This should be trivial. You say redstone torches give off 7. Simply cover a large area with redstone torches (using an editor, I imagine) and see what happens.
Quote from fr0stbyte124 »
2) Difficulty does not affect spawn frequency.
In the CleanRoom map, I would get around 200 mobs present one every difficulty level except for peaceful.
It sounds like you measured saturation (instead of frequency), which isn't really interesting. Maybe I have just been really unlucky when I've played on hard, but I have always gotten a higher rate on normal. Do you have any numbers on this?
Quote from Karoo »
also, how do you make your rank say tree puncher or something else?
Rank depends on number of posts. You have posted too much to be a tree puncher, I'm afraid.
Earlier I got frustrated trying to measure spawn rates and guess what was happening, so I went and decompiled the class files. I don't recommend doing this; everything is complete gibberish. I'm still trying to work out some key bits, but I thought I would share what I've uncovered so far:
Mobs spawn within the 81 chunks surrounding you (up to 4 chunks away in any direction), so ~64 blocks away, give or take depending on where you are in the chunk. Also, if I am reading this right, the minimum spawning distance is 24 blocks using 3D distance. So I was pretty close guessing 70 and 30.
The spawning function is run twice, once for friendly mobs and once for hostile mobs.
Each time the spawning function is run, it tries out each of the 81 chunks. There is a 1 in 10 chance of a spawn being attempted. I have no idea how frequently this function is called, though my guess is 1/sec.
When a spawn is attempted, it first chooses at random which monster class to be, then generates a completely random position within that chunk.
I'm still working on decrypting the next few steps, but this gist is it gets several tries to produce a legal location from pseudo-normal distributed random offsets of that initial location. If it gets a legal position, it spawns the mob unit. The code in this loop gets rather involved, and unfortunately, those legality rules it checks are what we need to know in order to game the system. I'll keep at it.
Also if you were curious, for every spider spawned, there is a 1 in 100 chance that a skeleton will be riding it.
And that's where I am so far. I have yet to find the code where mobs despawn, or the aggro range, but now we have a pretty good idea of how mobs are spawned. Certainly, there are no saturation or spawn rate parameters, and the room size was just coincidence, unless it plays a roll in despawning mobs (unlikely).
*edit*
Gah, I misinterpreted it again. It checks the initial random position for legality, and the first time the position is illegal, it backs out of the spawning function, which explains the variable spawn rate. The normal distributed offsets are for spawning mobs in packs. The pack can be up to 6 large if every position is legal.
Mob spawning is probably disabled once the mob count reaches 200, though I have yet to find this code.
My new theory is that CleanRoom worked so well because something in the legality checks moves the location to the nearest solid block. Since there is only one layer of solid block and nearly all of them are 100% legal, the spawn rates are through the roof. Hopefully there will be a way to exploit this without having to make 144x144 hole in the ground.
I've been working on a mob spawner/killer for a couple of days and finally got some success this morning! This thread has filled in a few gaps in my knowledge though - thanks.
Mobs spawn within the 81 chunks surrounding you (up to 4 chunks away in any direction), so ~64 blocks away, give or take depending on where you are in the chunk. Also, if I am reading this right, the minimum spawning distance is 24 blocks using 3D distance.
I'm not sure if I'm reading this correctly.
Does this mean that a mob can only spawn (on a horizontal space, in one direction) between 24 and 64 blocks away from you? This actually leaves a fairly limited space. Thinking in all directions of horizontal (ignoring 3d/vertical) that means that there is a circle of a diameter of 128 blocks around you in which mobs can spawn with another circle in the middle of this with a diameter of 48 blocks in which they cannot spawn.
So the perfect set up would be a square (for simplicity - too hard to figure out the circles) that is 128x128 with a 48x48 killer/collector in the center with you standing in the center of that collector. To further perfect it you would need to ensure that there was no spawnable locations 64 blocks above and below the 128x128 square.
--added--
Ok, I just went in game to get an idea of what 128x128 and 48x48 actually looks like...lol. I didn't realize how huge that is. My current mob spawn area is around 30x30 and seems huge...but that explains why when I stand on the ledge on the edge of the area to watch the mobs no new ones spawn except at the very far edge (30-24 leaves a strip only a few blocks wide on the far side for them to spawn).
--added again--
Instead of going huge an alternative would be a smaller spawn area but make sure nothing can spawn in the 128x128x128 area except in your spawn area. It seems like this should have the same effect as all mobs would still have to spawn in your area.
Fascinating thread. Makes me wish I had the programming know-how to look into this stuff myself.
What I'd like to know is how many of these rules can be broken by mob spawners. We know they can violate the minimum-distance-from-the-player requirements, but can they spawn mobs outside of the maximum?
I swear I had two mobs spawn in a 1x1 space today.
I have a cave I dug into a mountain with a series of mine shafts that hasn't had a monster spawn inside in two days, so I'm certain it was fine. This morning, I built a 3x3 tower leading up to a sky base with a 1x1 ladder shaft in the center. A couple of hours later, I caught a skeleton in my foyer; I figured maybe I left a door open. Then, when I was fiddling with a furnace next to the tower shaft, my wall exploded. Either a creeper on the outside of my walls decided to explode, or one spawned in my shaft, fell behind me, and exploded.
Now I only build 1x2 shafts and make sure they're lit. More annoying, but I pretty much lost my best base so far due to that explosion. :sad.gif:
If you mean will a mob be in spawning range if the vertical gap is 128 blocks, then the answer is yes, though it will be outside of the render distance. If you mean can a mob spawn in midair, then the answer is no.
Next is finding out a few things about how distance is calculated.
Some grid-based games use whats called "Manhattan Distance" which is the approximation (DX + DY), while most will use the Pythagorean SQRT(DX*DX+DY*DY). But there are also some obscure methods, like just taking MAX(DX, DY) or a slightly more complicated 0.5*MIN(DX, DY) + MAX(DX, DY)
Note that Civ/Civ2/Civ3/Civ4 used that last one for distance calculations (although its usually just expressed as "a diagonal is considered 1.5 units long")
The approximation is usually used because of time constraints, as SQRT() is an expensive thing to calculate, but some have novel properties that make them attractive for grid-based games.
Also of concern is the Z distance. If its the Pythagorean method, is Z included ala SQRT(DX*DX+DY*DY+DZ*DZ)? This would be important for those designing kill-by-falling traps.
I found a semi open space near my base and marked of a 128x128 area with a 48x48 area marked off in the center...crazy huge.
I ran some numbers - to build an area 128x128 that is 5 blocks high plus a roof (total of 6 blocks high), and assuming the floor is already in place, you would need 2,540 blocks to build the walls and 16,384 block to build the roof for a total of 18,924 blocks just to build the walls and ceiling of the enclosure.
That would be for a square though. If we knew how diagonals were measured we could cut the corners off of the enclosure and save quite a bit of time and materials.
I'm also thinking that's a good idea. Since mobs spawn >30 blocks from you, they will not engage you, meaning the only mobs that will jump in your trap are the handful who wandered over close enough to notice you. The best way to get them to go in the traps is to run over and bait them, which means you can't do this while afk unless you have a minecart system.
I may not know exactly what you are testing... but i dont have to worry about baiting them in my underground trap. While mining, I found a big open area cave that seemed to have a LOT of monsters spawning when i found it. 3-4 creepers/skeletons/spiders each... and they seemed to respawn quickly as i was fighting/lighting the cave up.
Anyway, i decided to make that a mob harvester area. I selected an open area in the middle, and built a 13x15 trap. I left all the branch passages that fed into that room open, and i made the paths to my harvester easy to navigate. Then i removed all torches, so it was pitch black, and idled in the middle of my harvester. Immediately mobs spawned and entered the trap. After a night spent in the trap (around 11 hours) i collected 6 stacks each of gunpowder, feathers, and arrows.
Say, what are you using to count the mobs, anyway? I certainly hope not by hand...
Also, another question: since the only hostile mobs that will show up on peaceful are slimes, will more slimes spawn on peaceful than on other difficulties to make up for the lack of mobs?
I just made a test spawn chamber on a regular world. It's 90x90 and has 32 water traps in it, and an automated cart running the entire thing. Unfortunately, the spawning room only seems to house about a dozen mobs at any given time. It's has a pretty decent drop rate, but not even close to what I predicted, and certainly not cost effective for its size. For some reason, they never even spawn on one half of the chamber.
Whatever the difference is between the CleanRoom and normal maps, it is significant. I have no idea how to proceed from here.
Is the test map a landscape comprised entirely of blocks from 0-128 high, except for your 90x90 pit? If so, I believe you've discovered a bug in Notch's code. I think you mentioned the weirdness earlier, but were uncertain if it was correct or not. Anyway, my theory is:
Each time the try-to-find-a-valid-spot-in-this-chunk loop runs around, it picks a random block in that chunk and tests to see if it's unoccupied. If that test fails, it simply gives up and jumps out of *all* the spawning code, even if more chunks remain that haven't been looked at. Assuming you have chunks that are completely filled from bedrock to sky, the spawning code always jumps out, leaving chunks untouched. I think. It's extremely weird code, since the test is really irrelevant because that randomly chosen block is never even used, so there's no point in checking if it's occupied.
My interpretation of the spawning function (most of which you probably already know):
Grab the surrounding 81 chunks.
For each chunk:
Pick a random block in that chunk.
Is this block filled? If so, give up and exit out of the entire thing, we're not spawning anything. [Bug?]
Is this block <unknown> (a test of whether it contains water? If it's on fire? Not sure.)? If so, give up completely. [Bug?]
Pick 6 random blocks near that earlier random block. For each of these blocks:
Is there room to spawn (2 height)? Is there floor directly beneath? Is the block <unknown> (some different test. Not sure of what.)? Is it not too <something about distance away>? Is it not too close to the player? If it's all good, allocate a new random mob in memory, then run that mob's [what I've dubbed the] canISpawnHere() function. If it returns true, then spawn the mob.
So in short: attempts to place a mob are completely at random (exempting a few basic tests), but if the attempt succeeds depends upon the mob's canISpawnHere() function.
Also, there *is* a cap of 200 enemy mobs being allowed to exist at once. Once it hits that, the function doesn't attempt to create new mobs. (Check for what creates the class containing all the spawning nuttiness - it creates it with a parameter of 200).
It's too bad canISpawnHere() is so hard to decipher.
Oh, and to catch everything you actually need a 144x144 area, since it's 9 chunks by 9 chunks that is looked at.
So you've tried disassembling the code too, huh? Awesome! I thought I was alone in my misery.
I don't think the bailing out condition was unintentional. Rather, this keeps too many mobs from spawning all at once, like they do on CleanRoom.
My test spawning chamber is just an underground room. I put it in a location completely devoid of natural caves. If my interpretation of the code is correct, this actually hindered my efforts.
Also, have you been able to figure out what calls c() in ia.class? I've been looking but without labels the thing just turns into a maze.
So you've tried disassembling the code too, huh? Awesome! I thought I was alone in my misery.
I don't think the bailing out condition was unintentional. Rather, this keeps too many mobs from spawning all at once, like they do on CleanRoom.
My test spawning chamber is just an underground room. I put it in a location completely devoid of natural caves. If my interpretation of the code is correct, this actually hindered my efforts.
Also, have you been able to figure out what calls c() in ia.class? I've been looking but without labels the thing just turns into a maze.
Minecraft.run() calls i(), which calls this.b.c(). this.b is of type hq (the superclass of ia), so if someone stores an ia in there it'll call ia.c(). That appears to be the only place in the entire codebase that is capable of calling ia.c().
Oh, and inside of ia.c(), the call to 'this.a.A.c()' seems to run the music loop. It took me a little while to decipher that.
Just now I tried to find out how often ia.c() is called, but I wasn't able to. The *line* that calls ia.c() is passed over every frame, it seems, but the condition in the if() statement looks like it stops ia.c() from actually being called... but I don't know if that's once per second, once per 20 seconds, etc. It's probably easiest to just play a game and see how often waves of monsters spawn, since it'll be obvious if ia.c() is called infrequently, since you'll see a pile of mobs appearing each time. And if you don't see waves... then hey, it's probably called every frame.
So here are some spawn conditions for enemy mobs that I've managed to figure out. As before, it's entirely possible that this information is incorrect.
-Light levels:
Take a random number from 0 to 7 (inclusive). Is the current tile brighter than this? If so, NO SPAWN FOR YOU.
So yes, the darker the cavern, the better. Mobs will spawn in a light of 7, but only 1/8th as frequently as they will in light of 0. (In a light of 6, they'll spawn 2/8ths as frequently, etc.)
-There's also a very bothersome line in dq.a():
if (this.ag.a(by.a, i, j, k) > this.aQ.nextInt(32)) return false;
that leads to a very complex chain of functions which loops back on itself/recurses after 7 calls. There's a lot of coordinate manipulation in there, so perhaps 'larger caves = more spawns' might be true. It's hard for me to tell.
-All enemy mobs have the same spawn conditions, except for slimes. Unfortunately, the slimes' conditions are very difficult to decipher, apart from: 'must be <size>', 'must be below level 16', and '1 in 10 chance of spawning'. Nothing in there about light levels that I can see.
PS: Friendly mobs require a minimum amount of light to spawn, and they stop being spawned once the population hits 15.
First off, thanks for the research into this. Second, this answers alot of confusion I was having in this thread... viewtopic.php?f=35&t=42273
I was getting mob spawns in my house for no apparent reason, thinking because I had lights it should be safe. I did not realize, however, that half brightness (or 7) can trigger a spawn. This may be the answer to my utter confusion on how to deal with my house. While there are torches every 5 blocks inside along the walls, in the middle of the room there is no such thing... leading to a few "moderate" brightness spots that could be creating the spawns.
I was about to give up on my map thinking I had bugged out the game thinking that I did something wrong. I looked over my floors and found a few areas that I'm guessing is 7 brightness (8 blocks diagonally from nearest torch) and are perhaps spawning the monsters when im outside my house, since I a am no longer too close to prevent the spawn. I would go out and do work on the house or gathering to come back and find crawling around :/
EDIT: A few strategically placed torches and no more spawns (so far). I guess having torches high up on walls does not really help if the game only considers the brightness of floor tiles on spawn or no spawn. Time to re-torch my house then. This thread helped immensely for solving my problem at least ^^
As far as I can tell the first line checks that the chunk exists. If it doesn't, it returns 0, which essentially means a free pass. I have no idea how this can possibly be right.
The second line polls some data from the chunk, but it's one of the 4-bit areas. This means it is either BlockLight, SkyLight, or Data. Data would be hard to justify, which leaves one of the light levels. Even then, with the Rand(32), it's highly inclusive. No idea what the point is, but I think we can safely say it's not critical.
I have a mob farm. It works great and on the other world I decided to build the same. I've built it above the clouds to reduce unwanted space where mobs can spawn. Here is how it looks:
But for some reason I get VERY few spawns in it. What could be the reason? Is it to high? To much air around it? Was reducing unwanted "spawnable" space actually not a good idea?
so the first time I got mabe 6 zombies, and then filled in a new cave I found with dirt.
then I tested again to see if I got more spawns, this time 6 skeles.
then I filled in the botom 2 layers so its only 4 blocks high, and I get 6 creepers.
this is strange to me (satanic and random) and am now testing again, this time with no modifications, guessing 6 spiders, then hopefully 6 slimes (doubt it)
mabe it had to do with the fact that I switched to peacefull for my changes, and underground the saturation limit has been reached for the area, I don't know, any help would be apriciated.
also, how do you make your rank say tree puncher or something else?
This should be trivial. You say redstone torches give off 7. Simply cover a large area with redstone torches (using an editor, I imagine) and see what happens.
It sounds like you measured saturation (instead of frequency), which isn't really interesting. Maybe I have just been really unlucky when I've played on hard, but I have always gotten a higher rate on normal. Do you have any numbers on this?
Rank depends on number of posts. You have posted too much to be a tree puncher, I'm afraid.
[opblock] [Sheep] [opblock]
[opblock] [opblock] [opblock] Fire: A complete guide to not burning down your house
Mobs spawn within the 81 chunks surrounding you (up to 4 chunks away in any direction), so ~64 blocks away, give or take depending on where you are in the chunk. Also, if I am reading this right, the minimum spawning distance is 24 blocks using 3D distance. So I was pretty close guessing 70 and 30.
The spawning function is run twice, once for friendly mobs and once for hostile mobs.
Each time the spawning function is run, it tries out each of the 81 chunks. There is a 1 in 10 chance of a spawn being attempted. I have no idea how frequently this function is called, though my guess is 1/sec.
When a spawn is attempted, it first chooses at random which monster class to be, then generates a completely random position within that chunk.
I'm still working on decrypting the next few steps, but this gist is it gets several tries to produce a legal location from pseudo-normal distributed random offsets of that initial location. If it gets a legal position, it spawns the mob unit. The code in this loop gets rather involved, and unfortunately, those legality rules it checks are what we need to know in order to game the system. I'll keep at it.
Also if you were curious, for every spider spawned, there is a 1 in 100 chance that a skeleton will be riding it.
And that's where I am so far. I have yet to find the code where mobs despawn, or the aggro range, but now we have a pretty good idea of how mobs are spawned. Certainly, there are no saturation or spawn rate parameters, and the room size was just coincidence, unless it plays a roll in despawning mobs (unlikely).
*edit*
Gah, I misinterpreted it again. It checks the initial random position for legality, and the first time the position is illegal, it backs out of the spawning function, which explains the variable spawn rate. The normal distributed offsets are for spawning mobs in packs. The pack can be up to 6 large if every position is legal.
Mob spawning is probably disabled once the mob count reaches 200, though I have yet to find this code.
My new theory is that CleanRoom worked so well because something in the legality checks moves the location to the nearest solid block. Since there is only one layer of solid block and nearly all of them are 100% legal, the spawn rates are through the roof. Hopefully there will be a way to exploit this without having to make 144x144 hole in the ground.
I'm not sure if I'm reading this correctly.
Does this mean that a mob can only spawn (on a horizontal space, in one direction) between 24 and 64 blocks away from you? This actually leaves a fairly limited space. Thinking in all directions of horizontal (ignoring 3d/vertical) that means that there is a circle of a diameter of 128 blocks around you in which mobs can spawn with another circle in the middle of this with a diameter of 48 blocks in which they cannot spawn.
So the perfect set up would be a square (for simplicity - too hard to figure out the circles) that is 128x128 with a 48x48 killer/collector in the center with you standing in the center of that collector. To further perfect it you would need to ensure that there was no spawnable locations 64 blocks above and below the 128x128 square.
--added--
Ok, I just went in game to get an idea of what 128x128 and 48x48 actually looks like...lol. I didn't realize how huge that is. My current mob spawn area is around 30x30 and seems huge...but that explains why when I stand on the ledge on the edge of the area to watch the mobs no new ones spawn except at the very far edge (30-24 leaves a strip only a few blocks wide on the far side for them to spawn).
--added again--
Instead of going huge an alternative would be a smaller spawn area but make sure nothing can spawn in the 128x128x128 area except in your spawn area. It seems like this should have the same effect as all mobs would still have to spawn in your area.
What I'd like to know is how many of these rules can be broken by mob spawners. We know they can violate the minimum-distance-from-the-player requirements, but can they spawn mobs outside of the maximum?
I have a cave I dug into a mountain with a series of mine shafts that hasn't had a monster spawn inside in two days, so I'm certain it was fine. This morning, I built a 3x3 tower leading up to a sky base with a 1x1 ladder shaft in the center. A couple of hours later, I caught a skeleton in my foyer; I figured maybe I left a door open. Then, when I was fiddling with a furnace next to the tower shaft, my wall exploded. Either a creeper on the outside of my walls decided to explode, or one spawned in my shaft, fell behind me, and exploded.
Now I only build 1x2 shafts and make sure they're lit. More annoying, but I pretty much lost my best base so far due to that explosion. :sad.gif:
Some grid-based games use whats called "Manhattan Distance" which is the approximation (DX + DY), while most will use the Pythagorean SQRT(DX*DX+DY*DY). But there are also some obscure methods, like just taking MAX(DX, DY) or a slightly more complicated 0.5*MIN(DX, DY) + MAX(DX, DY)
Note that Civ/Civ2/Civ3/Civ4 used that last one for distance calculations (although its usually just expressed as "a diagonal is considered 1.5 units long")
The approximation is usually used because of time constraints, as SQRT() is an expensive thing to calculate, but some have novel properties that make them attractive for grid-based games.
Also of concern is the Z distance. If its the Pythagorean method, is Z included ala SQRT(DX*DX+DY*DY+DZ*DZ)? This would be important for those designing kill-by-falling traps.
I ran some numbers - to build an area 128x128 that is 5 blocks high plus a roof (total of 6 blocks high), and assuming the floor is already in place, you would need 2,540 blocks to build the walls and 16,384 block to build the roof for a total of 18,924 blocks just to build the walls and ceiling of the enclosure.
That would be for a square though. If we knew how diagonals were measured we could cut the corners off of the enclosure and save quite a bit of time and materials.
I may not know exactly what you are testing... but i dont have to worry about baiting them in my underground trap. While mining, I found a big open area cave that seemed to have a LOT of monsters spawning when i found it. 3-4 creepers/skeletons/spiders each... and they seemed to respawn quickly as i was fighting/lighting the cave up.
Anyway, i decided to make that a mob harvester area. I selected an open area in the middle, and built a 13x15 trap. I left all the branch passages that fed into that room open, and i made the paths to my harvester easy to navigate. Then i removed all torches, so it was pitch black, and idled in the middle of my harvester. Immediately mobs spawned and entered the trap. After a night spent in the trap (around 11 hours) i collected 6 stacks each of gunpowder, feathers, and arrows.
Also, another question: since the only hostile mobs that will show up on peaceful are slimes, will more slimes spawn on peaceful than on other difficulties to make up for the lack of mobs?
Is the test map a landscape comprised entirely of blocks from 0-128 high, except for your 90x90 pit? If so, I believe you've discovered a bug in Notch's code. I think you mentioned the weirdness earlier, but were uncertain if it was correct or not. Anyway, my theory is:
Each time the try-to-find-a-valid-spot-in-this-chunk loop runs around, it picks a random block in that chunk and tests to see if it's unoccupied. If that test fails, it simply gives up and jumps out of *all* the spawning code, even if more chunks remain that haven't been looked at. Assuming you have chunks that are completely filled from bedrock to sky, the spawning code always jumps out, leaving chunks untouched. I think. It's extremely weird code, since the test is really irrelevant because that randomly chosen block is never even used, so there's no point in checking if it's occupied.
My interpretation of the spawning function (most of which you probably already know):
So in short: attempts to place a mob are completely at random (exempting a few basic tests), but if the attempt succeeds depends upon the mob's canISpawnHere() function.
Also, there *is* a cap of 200 enemy mobs being allowed to exist at once. Once it hits that, the function doesn't attempt to create new mobs. (Check for what creates the class containing all the spawning nuttiness - it creates it with a parameter of 200).
It's too bad canISpawnHere() is so hard to decipher.
Oh, and to catch everything you actually need a 144x144 area, since it's 9 chunks by 9 chunks that is looked at.
I don't think the bailing out condition was unintentional. Rather, this keeps too many mobs from spawning all at once, like they do on CleanRoom.
My test spawning chamber is just an underground room. I put it in a location completely devoid of natural caves. If my interpretation of the code is correct, this actually hindered my efforts.
Also, have you been able to figure out what calls c() in ia.class? I've been looking but without labels the thing just turns into a maze.
Minecraft.run() calls i(), which calls this.b.c(). this.b is of type hq (the superclass of ia), so if someone stores an ia in there it'll call ia.c(). That appears to be the only place in the entire codebase that is capable of calling ia.c().
Oh, and inside of ia.c(), the call to 'this.a.A.c()' seems to run the music loop. It took me a little while to decipher that.
Just now I tried to find out how often ia.c() is called, but I wasn't able to. The *line* that calls ia.c() is passed over every frame, it seems, but the condition in the if() statement looks like it stops ia.c() from actually being called... but I don't know if that's once per second, once per 20 seconds, etc. It's probably easiest to just play a game and see how often waves of monsters spawn, since it'll be obvious if ia.c() is called infrequently, since you'll see a pile of mobs appearing each time. And if you don't see waves... then hey, it's probably called every frame.
-Light levels:
Take a random number from 0 to 7 (inclusive). Is the current tile brighter than this? If so, NO SPAWN FOR YOU.
So yes, the darker the cavern, the better. Mobs will spawn in a light of 7, but only 1/8th as frequently as they will in light of 0. (In a light of 6, they'll spawn 2/8ths as frequently, etc.)
-There's also a very bothersome line in dq.a():
that leads to a very complex chain of functions which loops back on itself/recurses after 7 calls. There's a lot of coordinate manipulation in there, so perhaps 'larger caves = more spawns' might be true. It's hard for me to tell.
-All enemy mobs have the same spawn conditions, except for slimes. Unfortunately, the slimes' conditions are very difficult to decipher, apart from: 'must be <size>', 'must be below level 16', and '1 in 10 chance of spawning'. Nothing in there about light levels that I can see.
PS: Friendly mobs require a minimum amount of light to spawn, and they stop being spawned once the population hits 15.
I was getting mob spawns in my house for no apparent reason, thinking because I had lights it should be safe. I did not realize, however, that half brightness (or 7) can trigger a spawn. This may be the answer to my utter confusion on how to deal with my house. While there are torches every 5 blocks inside along the walls, in the middle of the room there is no such thing... leading to a few "moderate" brightness spots that could be creating the spawns.
I was about to give up on my map thinking I had bugged out the game thinking that I did something wrong. I looked over my floors and found a few areas that I'm guessing is 7 brightness (8 blocks diagonally from nearest torch) and are perhaps spawning the monsters when im outside my house, since I a am no longer too close to prevent the spawn. I would go out and do work on the house or gathering to come back and find crawling around :/
EDIT: A few strategically placed torches and no more spawns (so far). I guess having torches high up on walls does not really help if the game only considers the brightness of floor tiles on spawn or no spawn. Time to re-torch my house then. This thread helped immensely for solving my problem at least ^^
That is a wierd function. Inside, there are two lines
As far as I can tell the first line checks that the chunk exists. If it doesn't, it returns 0, which essentially means a free pass. I have no idea how this can possibly be right.
The second line polls some data from the chunk, but it's one of the 4-bit areas. This means it is either BlockLight, SkyLight, or Data. Data would be hard to justify, which leaves one of the light levels. Even then, with the Rand(32), it's highly inclusive. No idea what the point is, but I think we can safely say it's not critical.
But for some reason I get VERY few spawns in it. What could be the reason? Is it to high? To much air around it? Was reducing unwanted "spawnable" space actually not a good idea?