Topic category: User side tutorials
Hello there, MCreator user! =D In response to this post, which helped me dig up some fascinating information on spawn probabilities in Minecraft mods, I've decided to write an advanced guide about spawning your mob, and more particularly how the 'spawn probability' works. I'll try to make everything as understandable as possible but you'll have to rack your brain a bit to understand everything.
Disclaimer
Spawn probability is not the correct term. If we were talking about spawn probability, we would be talking about a percentage chance, which is not the case.
The proper term for this, which I request that the MCreator staff team changes to upon the next release, is spawn weight. I'll explain what this means below.
How does spawning in Minecraft work?
Minecraft uses a weighted, conditional spawn system to spawn it's mobs. What does all that mean? I'll explain in depth in this section.
For starters, Minecraft always keeps it's world populated with mobs. Nobody has dug up the exact number to my knowledge, but Minecraft ALWAYS keeps a certain amount of mobs alive in the world. If there are not enough mobs in the vicinity of the player, the game will immediately try to spawn more. This explains scenarios such as squid being much more common in the ocean; they are the only mob that can spawn while the player is out in the ocean, and because the game needs to have a certain amount of mobs, they all have to be squid.
You need to keep this in mind. If your custom mob is the only one that can spawn in a certain situation, it doesn't matter how rare it is. They will spawn a LOT. Say you write custom code to make a monster that spawns at day, with a measly spawn weight of 1 (5 times rarer than a witch!). You'd expect this mob to almost never spawn, since it has a spawn weight of 1. But there are no other monsters that can spawn at day, so that is the only mob that the game can spawn, and it doesn't care how low the spawn weight is in that case. Your incredibly rare monster suddenly appears tenfold across the world.
Got that?
As I mentioned, many mobs can only spawn in certain conditions. When trying to spawn a mob, the game will only pick mobs that meet the current criteria for a spawn location it has chosen. Many of these conditions can be controlled in MCreator, by the way. Many examples that influence what mobs can spawn may be:
Time of day
Light level
Biome
Amount of space available (is the mob too big?)
Are we spawning in water or on land?
The block to spawn the mob on (for example, animals prefer to spawn on grass)
A mob's spawning type
Spawning types
You are asked to choose a mob spawning type when creating a mob in MCreator. The game will always have mobs of different spawning types in the world; there will always be a fairly even balance of monsters, animals and so on, even if one type is more likely to spawn than the other.
Monster - This mob prefers to spawn in low light levels or at night. Examples are Zombies, Skeletons, and Spiders. Pretty basic.
Creature - These mobs can spawn at any time, but monsters have much higher spawn weights and usually take over at night. Examples are Chickens, Cows and Pigs. Again, fairly easy to understand.
Water Creature - To my knowledge, Water Creatures behave identically to regular Creatures, but spawn in liquids instead of on blocks. Examples are Squid and Guardians.
Ambient - This is one you need to watch out for. Ambient creatures are identical to regular Creatures, but are simply a different category to make sure that both types of creature will spawn. The problem? Bats are the only ambient creature in vanilla Minecraft. They can also only spawn in the dark. If you set a mob to Ambient, and allow it to spawn in the light, expect it to be ABSOLUTELY EVERYWHERE. This category was supposedly intended by Mojang to be used for creatures with no gameplay effects, such as bats, frogs, etc. and that is all you should use it for. Please, dear god, do not make a hostile mob and place it in Ambient.
Other spawning parameters
Although much simpler than those I just mentioned, I would also like to go over the other spawn parameters available.
Despawn when idle - This is ticked for almost any mob in the game, except for Iron Golems, bosses, and basically whatever you would expect to not disappear after disappearing on a 2 hour mining trip. Turn this on so the world doesn't become overloaded with your custom mobs. Leave it off for bosses and player created mobs, and just generally stuff you don't want to disappear.
Mobs in spawn group - The minimum and maximum values here simply determine how large a group of this mob is allowed to be. Use a larger range for more diverse groups, and vice versa.
Specific biomes - Self explanatory. The mob will only spawn in the biomes you pick here. For the uninitiated, Hell is the Nether and Sky is the End, in case your mob spawns in multiple dimensions.
Can spawn in dungeons? - You know the small dungeon rooms in Minecraft, with chests and a spawner for a spider or skeleton or whatever? This allows your mob to be featured in those spawners. Do this for tough mobs to give your player a hard time ;)
So what spawn weight should I use?
When choosing spawn weight, remember that as mentioned above, the spawn weight is compared to that of other mobs that could also be spawned. If your mob has very few spawn restrictions, you should set a lower weight than you would for a mob that can only spawn at night in a certain biome.
Examples
Some vanilla mob weights were dug up from Minecraft code here.
Witches have a spawn weight of 5.
Cows have a spawn weight of 8.
Endermen, Chickens, Pigs, Squid and Bats have a spawn weight of 10.
Sheep have a spawn weight of 12.
Zombies, Skeletons, Spiders, Creepers and Slimes have a spawn weight of 100.
Of course, even though zombies and such have 100 spawn weight, they cannot spawn at day meaning only the other weights matter. The game decides which mob to spawn simply by adding up all of the weights and picking a random number in there which corresponds to a certain mob and it's weight.
Recommendations
Here I'll go over what I would set the spawn weights to for certain types of mob you might create.
If you're making a new monster, set the spawn weight to 100.
If you want a rarer monster, set the spawn weight to somewhere below 10. Remember that 10 is an Enderman's spawn weight and 5 is a Witch's.
For a world boss of some kind, set the spawn weight to 2, 1 or even a decimal.
For an animal, set the spawn weight to somewhere between 7 and 15, depending on how common it should be.
For a rare animal, use something like 0.2, which balances nicely with other animals.
In simple words, think about the other mobs that could spawn instead of yours, and consider their weights.
I also did some quick rough maths here to give you some ideas for how common a mob would be in percentage. These are only accurate based on the spawn weights we know for vanilla mobs, and of course the more mobs you add the lower their chance of spawning is.
A new monster with 20 spawn weight has a 4.5% chance to spawn whenever the game needs to spawn a monster.
A new monster with 100 spawn weight has a 19% chance to spawn, and will be as common as most common monsters.
A new monster with 5 spawn weight has a 1.1% chance to spawn.
A new monster with 1 spawn weight has a 0.2% chance to spawn, which means 1 in 500 mobs will be your custom one. Great for a world boss!
For animals, you should reduce spawn weight compared to monsters.
A new animal with 20 spawn weight has a 33% chance to spawn whenever the game wants to place an animal. A pretty high chance, since 1 in 3 animals will be your custom one.
A new animal with 10 spawn weight has a 20% chance to spawn, and will be as common as most farm animals.
A new animal with 2 spawn weight has a 4.7% chance to spawn, this would be good for something rather rare. (This is actually more than a monster with 20 spawn weight!)
A new animal with 0.2 spawn weight has a 0.5% chance to spawn. Great for a Zelda-styled legendary bunny or something.
Conclusion
And that's basically all there is to know about spawning mobs in Minecraft. I hope you found this guide enlightened, since I certainly don't want to have wasted an hour for nothing D:. Please let me know in the replies if you have any questions or issues with mob spawning, and of course report any bugs to MCreator's staff team. If you need help you can also always reach me in PMs here, or more quickly by friending me on Discord at Gerbil#2902 .
Have a great day! <3
Wow, this is an outstanding tutorial! Would you be interested in writing on the wiki? If so, you can submit here: https://mcreator.net/page/wiki-contributors
And yes, I will change the term to weight in 1.9.1 :D
Thanks, I really needed this information!
thanks
I was legit gonna go "You better add this to the wiki"
Thanks Klemen! Glad that you all liked the guide, I'm looking forward to doing more indepth research like this for the wiki! ;)
I've wanted to know this information for ages too and never found any answers so decided to do it myself! :P A lot of Googling was involved XD
Ima make a few posts like this once i get home, ive created 20+ txt files full of info i use for my mod, idk why i didnt think to do this sooner lmao (I forgot this forum branch existed)
Odahviing, if you give me the permission, I will make a wiki page out of your forum topic. Is this fine by you?
Odahviing, no need to, just checked the Pylo email and saw your request for wiki contributor :D
:P I'll link to this on the wiki since I think many people would find this guide useful. Once again, thanks everybody for the great feedback! DaleksofSkaro, good luck! =D
I would make a new page called Mob spawning parameters and copy/paste this into the page as it is better to have this on the actual wiki rather thank linking to this forum topic. Wiki is seen more official than forum topic so it is better to make this an actual page.
Thanks, I'm remaking the multi block machine one!
I have made the page here: https://mcreator.net/wiki/mob-spawning-parameters
You can modify it if you wish :)
Ooh, thank you Klemen, I thought about doing that for a second but I got tired and went to take a nap! XD