Mob spawning mechanics

Discussion in 'Discussion' started by Soulskilledu, Sep 19, 2012.

Become a member to no longer see this ad. :)

  1. Offline

    Soulskilledu Redstone Fanatic

    Moderator
    Warning Points:
    0
    Mob spawning mechanics: Part one
    Spawners: Part two
    Guide to building mob traps: Part three

    I'm going to be putting this in chunks to save it.



    When all of the information is stated, I will put everything that you need to know in Green.

    Could a moderator sticky this so people will know how to get this information?

    Part one: Mob spawning mechanics

    Hostile mobs have a spawning cycle once every game tick (1/20th of a second), while passive mobs can only spawn once every 400 ticks. Because of this skeletons, zombies, spiders, etc, can spawn at any time.

    Mobs can spawn in a 240x240 block around the player. But when there are multiple players, mobs can spawn within this distance of any of them(therefore, all over your island). However, if you move 128 blocks away from a mob it will despawn, so the mob spawning area is completely limited to a sphere with a radius of 128 blocks, centered at each player.

    Because of this you need to have the trap within 110 blocks of you or so. But it needs to be within 240 blocks of you. This is fairly easy to achieve as long as you don't leave your island right? No.

    The number of mobs able to spawn is directionally proportianate to the number of chunks where they can spawn. To calculate the cap, the spawning area is expanded by one chunk in every direction, so that it is 17x17 chunks in size, and then the total number of chunks is plugged into the following formula:

    Constant * chunks / 256 = Maximum cap

    Hostile = 70
    Passive = 15
    Water = 5



    Therefore if you have one mob spawner and the rest of your island is lit up, then I figured it would be about 6 chunks where they could actually spawn.

    70 * 6 / 256 = 16.15

    This means that the mob cap on your island would be about 16.
    Now, I have a massive castle, and I made everything completely dark, and there were about 15-20 mobs on each floor.
    My whole island is approx 12 chunks or so, so...

    70 * 13 /256 = 32.30

    This doesn't add up does it?

    Well in multiplayer, chunks that are in range of multiple players are only counted once. So the more spread out the players are, the more chunks will be covered and therefore the higher the maximum mob caps will be.

    The mob cap is checked once at the beginning of each spawning cycle. If the number of mobs in a category is over its cap, the entire spawning cycle for that category of mob is skipped.

    For each spawning cycle, a single attempt is made to spawn a pack of mobs in each eligible chunk. A random location in the chunk is chosen to be the center point of the pack, but for the pack to spawn at all, the center block must be water for water mobs and air for all other mobs. Note that in the previous case, it must be an air block. Any other block, even a non-colliding(sign, redstone, etc) one, will prevent the entire pack of mobs from spawning.

    If the pack location follows the previous guidelines, 12 attempts are made to spawn up to 4 mobs (8 for Wolves, 1 for Ghasts) within a 41x1x41 area centered at that block (that's a 41x41 square that is one block high). Mobs will spawn with the lowest part of their body inside this area. For each spawn attempt, a block within the area is chosen at random. Though the pack area extends 21 blocks out from the center, the random location is heavily skewed toward the center of the pack. Approximately 85% of spawns will be within 5 blocks of the pack center, and 99% within 10 blocks of the center.


    All mobs within a pack are the same species. The species for the entire pack is chosen randomly from those eligible to spawn at the location of the first spawn attempt in the pack:
    In the Overworld, this depends on the biome:
    Most biomes can spawn sheep, pigs, chickens, cows, spiders, zombies, skeletons, creepers, Endermen, slimes (in certain chunks), and Squid.
    Forest and taiga biomes can also spawn Wolves.
    Jungle biomes can also spawn Ocelots.
    Desert, beach, river, and ocean biomes cannot spawn animals; only hostile mobs and Squid.
    Mushroom biomes can spawn only Mooshrooms.
    Cave spiders spawn only from their specific Mob Spawners, which are found in Abandoned Mine Shafts among many cobwebs.
    Silverfish spawn from special stone, cobblestone, and stone brick blocks found in strongholds, and their specific spawners also found there.
    Blazes spawn from their specific spawners in Nether Fortresses and can also spawn elsewhere in the structures.
    The Nether itself can spawn only Ghasts, Zombie Pigmen,and Magma Cubes.
    The End can spawn only Endermen.
    The Ender Dragon spawns naturally in The End; but only one, ever; and not as part of the general mob spawning process.

    [IMG]
    Now for each individual spawn attempt will only succeed if all of the following conditions are met:
    There must be no players and no player spawn points within a 24 block distance (spherical) of the spawning block
    If it's a squid, then...
    the spawning block must contain liquid (water or lava)
    the spawning block must be between level 45 and 62, inclusive
    the spawning mob must not be obstructed by other mobs
    If it's not a squid, then...
    the spawning block itself must be non-opaque and non-liquid
    the block directly below it must be opaque
    the block directly above it must be non-opaque
    the spawning mob must not be obstructed by blocks, other mobs, or water
    If it's an animal, then...
    the block directly below the spawning block must be grass
    the light level of the spawning block must be 9 or brighter
    if it's an ocelot, then...
    the spawning block must be above level 62
    the block directly below the spawning block must be grass or leaves
    there is a 1/3 chance the spawn will fail
    If it's a hostile mob in the overworld, then...
    the light level of the spawning block must be 7 or darker, and more light increases the chance that the spawn will fail
    sunlight falling on the spawning block further increases the chance that the spawn will fail, by up to 50%
    If it's a slime, then...
    the spawning block must be in a chunk eligible to spawn slimes (see the Slime page for details)
    the spawning block must be below level 40
    for medium and large slimes, the difficulty must not be set to peaceful
    Note: this condition is redundant as it is skipped completely on peaceful
    there is an additional 90% chance the spawn will fail, thus slimes only spawn 1/10th as often as other mobs, all other things being equal
    If it's a Ghast, then there is a 95% chance the spawn will fail, thus ghasts only spawn 1/20th as often as other mobs
    If all of these conditions are met then the mob is spawned. The pack is complete when 4 mobs have spawned (or 8 wolves, or 1 ghast), or 12 attempts have been made, whichever comes first. The only exception to these rules is the Enderdragon.
  2. Offline

    Soulskilledu Redstone Fanatic

    Moderator
    Warning Points:
    0
    Part Two: Spawners

    A spawner will spawn mobs in the surrounding area of the player, provided suitable spawning locations. Spawning conditions vary from mob to mob, Overworld monsters can only spawn in a light level of 7 or below, while animals must spawn with a light level 9 or above. However, the spawner can spawn mobs in mid-air.
    You must be within 16 blocks of the spawner for it to be active. While it is active, it will spawn mobs within an 8 × 3 × 8 block area (8 wide and 3 high and 8 long), centered on the corner of the spawner. Mobs can spawn anywhere in this range that is suitable, even if the immediate vicinity of the spawner block itself is not suitable. The horizontal distribution is nonlinear, with positions near the spawner more likely than ones farther away.
    The block will attempt to spawn 4 mobs at randomly chosen points within the spawning area, then wait anywhere from 200 to 799 ticks (10 to 39.95 seconds) before spawning again. Except for spawning on a solid block, all of the usual requirements for spawning must be met, so the spawner will create less than 4 mobs. If the block fails to spawn any mobs because it did not choose any suitable locations, it will repeat this process every tick until it succeeds. Only when it manages to spawn at least one mob will it start waiting for the next cycle. If, at the time of spawning, 6 or more monsters of the block's type are present within a 17 × 9 × 17 area (17 wide and 9 high and 17 long), centered on the spawner block, the spawner "poofs" without creating any monsters and then waits for the next cycle. However, if there are more of the mob outside of the specified range, then the monster spawner will continue spawning mobs indefinitely.
    Note that while mobs are spawned at an integer y coordinate, the x and z coordinates are not aligned to blocks(They could spawn on slabs, signs, fences, ect). Mobs will spawn with their legs at either the same level as the spawner block, one block above it, or one block below it, but horizontally, a mob can spawn with its center point anywhere within the 8 × 8 range. Since the mob itself takes up some horizontal space, this must be applied into the range spawner to get the dimensions of the area they can occupy.
  3. Offline

    Soulskilledu Redstone Fanatic

    Moderator
    Warning Points:
    0
    This part is copied directly from the source.
    every spawn cycle (every randInt(200,799) ticks when a player is within
    17 blocks of the spawner),
    loop 4 times {
    if there are 6 or more of the mob type in the 17x9x17 area around the spawner,
    skip this spawn cycle
    calculate spawnerX = X coordinate of center of spawner - 0.5
    calculate spawnerY = Y coordinate of center of spawner - 0.5
    calculate spawnerZ = Z coordinate of center of spawner - 0.5
    calculate x coordinate of mob = spawnerX + (randDouble() - randDouble()) * 4,
    randDouble being a random number between 0 and 1
    calculate y coordinate of mob = spawnerY + a random integer between -1 and 1
    calculate z coordinate of mob = spawnerZ + (randDouble() - randDouble()) * 4,
    randDouble being a random number between 0 and 1
    if all of the conditions specific to the mob type are met, spawn the mob {
    chicken, cow, mooshroom, pig, sheep, wolf:
    block below spawning block is grass
    spawning block has a light level of 9 or higher

    ocelot:
    pass a 2/3 random test
    block below spawning block is grass or leaves
    on layer 63 or higher

    creeper, enderman, skeleton, spider, cave spider, zombie:
    light level 8 or less

    blaze:
    light level 11 or less

    silverfish:
    light level 11 or less, or on Stone blocks
    no players within 5 blocks

    slime:
    difficulty is not set to peaceful or slime size is small
    spawn block y coordinate is less than 40
    the chunk containing the spawn block is a slime chunk (1 in 10 chance)
    pass a 1 in 10 random test

    ghast:
    pass a 1 in 20 random test

    squid:
    must not collide with any other entities
    must be in layer 46-62

    all except squid and slimes:
    must not collide with any blocks or other entities
    must not collide with water or lava
    }
    }
    if all 4 mobs failed to spawn, repeat on the next tick
  4. Offline

    Soulskilledu Redstone Fanatic

    Moderator
    Warning Points:
    0
    Part Three: Guide to building mob traps
  5. Offline

    Soulskilledu Redstone Fanatic

    Moderator
    Warning Points:
    0
  6. Offline

    Soulskilledu Redstone Fanatic

    Moderator
    Warning Points:
    0
    Mob traps include a few main parts.

    1. Spawning Area
    2. Transportation To One Area
    3. Weakening/killing Point

    Sorry for taking so long to to finish this post.

    I've been a bit busy.
  7. Offline

    DA455

    Warning Points:
    0
    This is an interesting thread on mob spawning :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D
  8. Offline

    snooze107

    Warning Points:
    0
    Couldn't even read it's so long.

    You forgot /spawnmob though I think.

Become a member to no longer see this ad. :)