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, horse, mooshroom, pig, sheep, villager, 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 7 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 either: 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 or: swamp biome, layer 51 through 69, light level 7 or less ghast: pass a 1 in 20 random test squid: must not collide with any other entities must be in layer 46-62 giant: light level 7 or less light level 8 or more (since these conditions can't be true simultaneously, giant spawners don't work) 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
這份偽代碼基於 Minecraft 1.7.10 反編譯出的源檔案:
if (there is a player within the range of activatingRangeFromPlayer) { if (spawner delay == -1) { reset spawner delay } if (spawner delay > 0) { decrement spawner delay by 1 cancel this spawn } loop for the number of entities we should spawn { if (the number of entityTypeName in a 2*spawnRange+1 centered cube > maxNearbyEntities) { reset spawner delay exit loop } X = Spawner.x + random(spawnRange*2)-spawnRange; Y = Spawner.y + random(3)-1; Z = Spawner.z + random(spawnRange*2)-spawnRange; if (entity can spawn at (X,Y,Z)) { Spawn entityTypeName at (X,Y,Z) Play Sound Effect Spawn Particles } } if (at least one entity was spawned) { reset spawner delay }}Default values: activatingRangeFromPlayer = 16 spawner delay = 20 maxNearbyEntities = 6 spawn range = 4 entityTypeName = PigOutcomes (default): A player must be within a 16 block centered sphere There must not be more than 6 pigs within a 9x9x9 centered cube The pig must be able to spawn at the chosen location (must not be inside a block, meet lighting conditions etc.) If all mobs fail to spawn, it will try again on the very next tick.