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 Plant

The next unique kind of block you might want to add to your mod is a plant. Plants are metadata blocks, but they require quite a lot of special code.

Coding the Basics

To add a plant, you need to combine most of the information you know up to this point. However, just like any other block, you add it to your mod class with code similar to this:

public static Block samPlant;

Add the following code in the preInit method:

samPlant = new BlockSamPlant();GameRegistry.registerBlock(samPlant, "SamPlant");

Additionally, the start of the BlockSamPlant class is similar to the standard blocks as well. You need to add a constructor, add a super with the Material, set the unlocalized name, and so forth. After ...

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