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

Creating a SamEventHandler

To create an EventHandler for your mod, you add a variable like this to the mod class:

SamEventHandler handler = new SamEventHandler();

Because the class SamEventHandler hasn’t been made yet, this contains an error. You fix this soon when you create the class. However, before that is done, it would be useful to register this class as a class that handles world generation. To do that, add the following line of code to the preInit method:

GameRegistry.registerWorldGenerator(handler, 0);

This method registers the event handler as a world generator. The first parameter is the handler variable, which was just created. The second parameter is the importance of the ...

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