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

Adding Code to SamEventHandler

Now to make sure this code is actually used, you must add it to the SamEventHandler class. This plant generates on grass and, therefore, several things are required for it to work. First, it only generates in the overworld. Second, it only generates around the ground level because that’s the only place with grass.

The code to add generation for classes like WorldGenSamPlant is very similar to what’s inside of the addOreSpawn method from the previous hour. There is a random x, y, and z and a line that calls the generate method in WorldGenSamPlant. All of this code can be added in a for loop to make the plant more common. The code required should look similar to this:

int posX = x + ...

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