Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Commoble/5139d770862b7ab3d67384a457ab627a to your computer and use it in GitHub Desktop.
Save Commoble/5139d770862b7ab3d67384a457ab627a to your computer and use it in GitHub Desktop.
Observations on entity spawn ticks in minecraft forge 1.15
the world attempts to spawn monsters every tick
the world attempts to spawn animals every 400 ticks
entities classified as MISC are not spawned in world-chunk ticks
int mobCap = nominal cap * tracked chunks / 289D // 289 == 17^2
nominal cap is 70 for monsters, 10 for animals
tracked chunks is the number of chunks tracked by any player (the range appears to be 8)
I'm not sure if this is a square or a circle, but if it's a square, then we have 289 chunks tracked per player (minus overlaps)
if (total Explicitly Persistant Loaded Mobs < mobCap)
attempt to spawn entities
an entity in a world is an Explicitly Persistant Loaded Mob if
it is a MobEntity of the same classification as what we are attempting to spawn
it is in a loaded chunk
it is persistant or preventDespawn is true
persistance is a serialized entity field that starts false for most entities, it becomes true if
entity picks up an item or is equipped with an item by a dispenser
some structures or features that have initial entities make them persistant
entity is a skeleton horse or skeleton created by a skeleton trap
entity is a villager that was formed through the curing of a zombie villager
entity is an elder guardian
entity is a Drowned formed by converting a zombie that was persistant
entity is named by a nametag
entity is a cat and spawns inside a swamp hunt (likely becomes persistant even if summoned or spawn-egged)
entity is a zombie villager formed by a villager being killed by a zombie
a cat entity becomes collared by a player
entity is a slimeling spawned by a persistant slime
entity is created with the nbt tag {"PersistanceRequired": true}
-- if the entity's tag is set after it is created, it may not become persistant until data is read from its tag again
preventDespawn is an entity method that usually returns false
true for raiders during a raid and fish spawned from a bucket
it's worth noting here that most animals don't despawn naturally but are also not Explicitly Persistant
and thus don't count toward the cap, unless I've missed something important
i.e. animals prevent themselves from despawning by overriding canDespawn to return false,
which doesn't seem to count it toward the Explicitly Persistant Loaded Mob cap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment