Chapter 8. New Item

Now that you have made a new block, it is time to move on to a new item.

Items can do many things. Most items are used for crafting, smelting, and brewing. Some items light fire (e.g., flint and steel, or fire charges), while others can be eaten (e.g., cookies and potatoes). Some items, such as bows or snowballs, do something when you right-click with them. A lot of items don’t do much, such as magma cream or iron ingots.

The item created in this chapter will be an ingot. At first, the item will not do anything, but the later parts of the chapter will offer some variations of this item. The first one will make it spawn an enderman on right-click. The second one will make it a food item. The last one will make it drop when you break an Enderium Block.

Creating the Item Class

A new item does not require as much code as a new block, but there are more ways to customize it. First of all, you will need a new class for the item, just as with the block. Call it EnderIngot.

Just as with the new block, replace the generated code with the code in Example 8-1.

Example 8-1. New item final code
package org.devoxx4kids.forge.mods;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class EnderIngot extends Item {

	public EnderIngot() {
		super(); 1
		this.setUnlocalizedName("enderIngot"); 
		this.setCreativeTab(CreativeTabs.tabMaterials

Get Minecraft Modding with Forge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.