Creating the Armor

Now it’s time to create the armor items.

The Mod File Code

Just like with any other item, you need to create the object, initialize it, and finally register it. Listing 8.1 shows all of the armor code required in the mod file. The Item objects are also ordered like the arrays used for the ArmorMaterial.

LISTING 8.1 Armor Code

//armorpublic static Item samhelmet;public static Item samchest;public static Item samleggings;public static Item samboots;ArmorMaterial samarmor = EnumHelper.addArmorMaterial("samarmor", 20, new int[] { 3, 7, 6, 3 }, 10);

Listing 8.2 shows the code that is required to be added in the preInit method.

LISTING 8.2 preInit Armor Code

//armor ...

Get Minecraft™ Mod Development in 24 Hours, Sams Teach Yourself now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.