Spawning 101 - ProjectZulu/JustAnotherSpawner GitHub Wiki

This section outlines the basic principles of spawning, which means it will start with the Vanilla System. As we progress we will add terms and principles used specifically by JAS. Users NEED TO BE aware of the following to successfully understand and use JAS: they include EntityTypes, Passive Spawning, Chunk Spawning, despawning, and persistence. For those that understand these concepts, you may wish to skip to JAS Main .

For those wanting to really understand the spawning system that JAS works with, and gain a really solid understanding of what AND why JAS does what it does, we recommend adding the Minecraft Wiki Spawning Article to your study list. It will provide an additional base for learning and give you more knowledge to work from. It is also just good reading :)

When Minecraft refers to spawning, it refers to placing BOTH players and mobs into the game world in various forms and through many methods. When JAS talks about spawning, it refers SPECIFICALLY to the part of Minecraft responsible for PLACING (called "Spawning") entities WITHOUT interaction. This means no spawners, blocks, mod items, from players or even other entities.

The spawning system works like this:

First, it creates a "spawn list"; which is a list of entities ALLOWED to spawn based on the group the entity belongs to, the biomes it can spawn in and its own spawn "weight" (how likely it will be chosen to spawn over other entities in the same group, etc). Then the spawning system checks the maximum number of allowable entities allowed based the aforementioned requirements and then checks to see how many already exist. Lastly, an attempt is made to spawn the chosen entity, and if a suitable block or set of blocks are found it will be spawned. If failed, the process is repeated the next time the Game Tick matches the group tick count, called a Spawn Cycle.

Creature Types

Also referred to as EntityTypes. The vanilla spawning system has 4 groups every entity belongs to in order to be able to spawn; MONSTER, CREATURE, AMBIENT, and WATERCREATURE. When adding mods it is possible for entities to not belong to any creature category, which would cause the entity to either not spawn or the mod to which it belongs to take over the spawning of the entity which can cause mob spamming (covered in the next chapter). JAS has 2 additional groups, UNDERGROUND and OPENSKY. Users can also create their own groups as well.

####Properties

Spawn Cap

The Spawn cap controls the maximum number of mobs allowed to spawn from any given GROUP. For example, the MONSTER group has a max cap of 70 (which can be changed), which means only 70 mobs from the GROUP monster may spawn. Minecraft does not use a straight forward formula for entity spawning, meaning a spawn cap of 25 for AMBIENT is more of a close proximate. there could be 22 or 28. This is partly due to the way mobs spawn into existence, different tick counts, and other variants covered in other chapters.

What this means in the real world is that using JAS allows any extra entity spawns to be negligible and controllable, so setting MOC sharks to 3 might yield 4. If you happen to also be causing new chunks to be GENERATED then CHUNK SPAWNING will also be occurring and you MAY get the chunk spawns added to your total as these are separate lists for spawning. However, when the DESPAWN CYCLE occurs all LOADED entities will be counted and excess mobs removed as long as they are at a "despawn" age or range. On a multiplayer server, it counts all chunks loaded within a certain distance of all players. Each chunk, however, is only counted once. If multiple players are standing within the same area there are fewer loaded chunks than if the players are standing far apart.

Spawn Rate

The Spawn rate sets how often the spawn cycle is processed for the given group.

Default Values

Categories Spawn Cap Spawn Rate [Every X Ticks] Special Condition
Monster 70 20 Ticks per Second Regular
Creature 10 Every 400 Ticks Regular
Ambient 15 20 Ticks per Second Regular
WaterCreature 5 ? Spawn block: at and below is liquid and above is not normal
Underground 10 1 Ticker per Second Regular && Cannot See Sky
OpenSky 10 1 Ticker per Second Regular && Can See Sky

Regular = Spawn block: below is solid on top and opaque; block at spawn is non liquid or normal; and block above is normal;

Passive Spawning

Passive spawning. Two major parts to passive spawning. First, spawning occurs every so many Game Ticks, which is a measurement of time (.o5 seconds). The number of Game Ticks is determined by the group an entity belongs to which we will cover in detail in a later chapter. Second, Passive Spawning is responsible for the majority of spawning in Minecraft. It is Passive Spawning that is responsible for spawning zombies at night or bats underground.

The flow during a passive spawn cycle is:

  For each **GameTick**
    Exit loop if no EntityTypes are ready to go (X ticks based on CreatureType.CFG)
      Count Entities in World & Determine chunks for spawning; noting number of each EntityType and # of each EntityClass
	For each EntityType
	  If #EntityType < Group Cap
	    For each Spawnable Chunk
		  Select Starting Position for spawning
		  Exit loop if EntityType spawn rules cannot spawn at position
		  For iterationsPerChunk
		    Select position randomly near Start Position
			Exit loop if biome is blacklisted
			Exit loop if within 24 blocks of server spawn or near player
			Select entity to spawn from spawnlistentry for the current Biome and EntityType
			If Entity LivingHandler and SpawnListEntry can spawn at location
			  Spawn Entity in world
			  Trigger post spawn tags
			  Iterate entity counter
			  GoTo next eligible chunk if Number of this entity spawned this loop greater than maxPackSize

TIP: Remember, Passive spawning and chunk spawning are essential different engines, and it is PASSIVE SPAWNING OBEYS CAP rules, NOT CHUNK>

Chunk Spawning

Chunk spawning. Is only done the first time a chunk is generated, not to be confused with reloaded. So when you FIRST enter a new area and cause chunks to be generated for the FIRST time, entities are "chunk spawned". When you leave the area and return, causing Minecraft to reload those chunks again, NO "chunk spawning" occurs because the chunk is only reloading not regenerating. Passive spawning still occurs as the game ticks match the tick rates set by the groups the entities belong to which we also cover in detail in other chapters.

As you move back to an area once occupied and the chunks are reloaded, you are also moving away from other chunks causing entities to also despawn. This in turn frees up space on a given spawn list, other mobs can now spawn. As the chunks are RELOADED entities will passive spawn in them and it may appear to be chunk spawning. The importance is that there are two sets of spawning when chunks are loading. The passive spawning is done by limits to the groups the entities belong to, so as entities despawn from being to far away or despawning time limits, other entities will spawn based on free space in a given entity group. Chunk spawning is done separate from this and as a result can cause entity groups to exceed their limits.

When a new chunk is generated, chunk spawning occurs. As stated earlier, this ONLY occurs upon a chunk being generated, not reloaded. In vanilla these only occur for the Creature Spawn Group (though these can occur for any EntityType if configured via JAS CreatureType.CFG). The idea is that Creatures are persistent (never despawn) with a very slow respawn cycle (~20 sec) so to create a world that is not empty some creatures are placed into the world on creation. What is a chunk. A "Chunk" consists of an area 16 blocks wide, 16 blocks long and 128 blocks deep for a total of 32,768 total blocks. This is important when determining mob spawning as mobs and their respective caps are affected by how many chunks are allowed to have spawns. The JAS 101 section explains its affects in greater detail, for now just remember that if you were to allow entities to spawn 8 chunks away, that would be 128 blocks away in every directions (still only 128 blocks deep).

Persistence & Despawning

Most Entities in Minecraft after a certain period of time, have a chance to despawn (cease to exist, poof). This allows for a variety of entities to spawn while not overwhelming the users computer and world with an infinite amount of entities. Spawning Ranges are covered under JAS 101 as they tie directly into one of the many features of JAS. Control.

Persistence

There are a few entities that do not despawn. There are two traditinal ways this is achieved. The first is using an NBTag "persistenceRequried" which can be set via an NBT editor. The second is through the entity itself by the modder via the canDespawn() method. JAS utilizing a tag system to allow users to overwrite the modder specified despawn method.

Despawning

Assuming an Entity is allowed to despawn at all, its ability to do so is based on each age and distance to any player. Essentially, when an entity gets old (age > 600 ticks), and is farther than 32 blocks away, there is a 1 in 800 chance it will despawn. If the entity is within 32 blocks of a player, its age is set to 0. Most of these values can be configured via the WolrdGlobalProperties.cfg found. .minecraft>config>JustAnotherSpawner>WorldSettings>BASIC>DEFAULT.

{
  "FILE_VERSION": "1.0",
  "Min_Despawn_Distance": 32,  <---Min distance before entity is eligible for regular despawn*.
  "Instant_Despawn_Distance": 128,  <---Min distance before entity is eligible for instant despawn*.
  "Min_Despawn_Time": 600 <-----Time entity must be in despawn range before being eligible.
}
*unless entity is tamed or other special reason.

Structure Spawning

Structure spawning is a special form of Passive Spawning that occurs when the location an entity is spawning is a structure. At this special locations the default biome spawnlist is overridden and replaced with the structure spawnlist. Not all world gen features in the world are valid for this type of spawning and must be specifically designed for it. It is considered a SPECIAL SPAWN.

This is normally used to place special entities unique to world or biome at parts of the world that are unique, i.e. Structures. The most obvious example, is in the nether. Nether fortresses have their own monster spawn list independent of the rest of the nether consisting of Blaze, Zombie Pigman, Skeleton, and Magma cubes.

###Contributers

Yeah, the people that make all this possible and a list of names you will see in the forum to get great help from.

CD a.k.a. Crudedragos - The JAS man himself (that means he is the guy that made the mod)

The following have contributed whether they realize it or not (129 pages of forum questions they have answered have been compiled to create the updated wiki and the example and command pages). As I get closer to working the command and example pages there will be more stuff after their names and this sentence will be gone...still working on it

Dulciphi

PitchBright

AnvilPuncher

LunariusH

Zothen