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 Basic Item

It’s time to start creating your own item. To get started, you start in your mod file. Just below the two String variables and just above the init method, create a new method called preInit. The parameter for this method must be FMLPreInitializationEvent. Don’t forget to add the @EventHandler annotation above the method, or your item won’t work without showing any errors. Once you have done that, the file should look like Listing 4.1.

LISTING 4.1 Mod File with preInit Method

package com.wuppy.samsmod;import net.minecraft.enchantment.Enchantment;import net.minecraft.init.Blocks;import net.minecraft.init.Items;import net.minecraft.item.ItemStack;import net.minecraft.util.WeightedRandomChestContent; ...

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