O'Reilly logo

Minecraft™ Mod Development in 24 Hours, Sams Teach Yourself by Jimmy Koene

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making the Mob Spawn

There are two ways to make a mob spawn. There are spawn eggs, which enable you to spawn a mob with an item, and there are natural spawns, which make sure that, for example, cows walk on grassy areas.

Adding a Mob Egg

It is smart to give every single mob you have a spawn egg. Doing this makes it much easier to test. In some cases, it also helps the user. The best part about mob eggs, however, is that it only requires a little bit of code and it doesn’t use any new items. The new spawn eggs are added to the vanilla mob egg.

To add your mob to a spawn egg, add the following code to the mod class:

static int startEntityId = 300;@SuppressWarnings("unchecked")public static void registerEntityEgg(Class<? ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required