Skip to Content
Minecraft Modding with Forge
book

Minecraft Modding with Forge

by Aditya Gupta, Arun Gupta
April 2015
Intermediate content levelIntermediate
200 pages
4h 17m
English
O'Reilly Media, Inc.
Content preview from Minecraft Modding with Forge

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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Minecraft Modding with Forge

Minecraft Modding with Forge

Aditya Gupta, Arun Gupta

Publisher Resources

ISBN: 9781491918883Errata Page