Basic Item Introductory
Welcome to the basic item introduction. Normal items are composed of two class files. The first obviously being a @Mod file and the other being the Item Class. For this tutorial it is expected that you know about @Mod files. If you do not we have documentation here.
The first part of making an Item is to set up a declaration. For a Item it will look a like this.
public static Item yourItem;
The next thing we will need to do is make some properties for our Item. This code will go into the FMLInitializationEvent. Some things to note about the code is that the first part is the same as what you declared above. the YourItem is a class file to hold many properties of your Item. The number 500 is the ID value. The setIconCoord is used to help determine what sprite to use from a sprite sheet. Finally the creative tab Is used to set what tab the Item goes under. NOTE: at this point in the tutorial ItemYourItem will have an error. We are going to create that in a bit. Below is an example of how our item properties will look.
yourItem = (new ItemYourItem(500)).setIconCoord(7, 3);
Now we will need to register a name for our item. This Line of code goes into the FMLInitializationEvent Just like the code above. This line of code requires two things. The first thing is the item and the second thing is name for the Item.
LanguageRegistry.addName(yourItem, "The name for your Item");
We have created the first half of our item, Now we will need to make the ItemYourItem.java, The contents of this class will hold much information. I have provided a basic example of an Item class for you to use.
package your.stuff.here;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class ItemYourItem extends Item {
public ItemYourItem(int id) {
super(id);
//This is a constructor
maxStackSize = 64; //this tells how many of an item can be in one stack
setCreativeTab(CreativeTabs.tabMisc); //this sets the creative tab the item is in
setItemName("yourItem"); //this is a name for your item. this is not the display name
}
}
The first part of making an Item is to set up a declaration. For a Item it will look a like this.
public static Item yourItem;
The next thing we will need to do is make some properties for our Item. This code will go into the FMLInitializationEvent. Some things to note about the code is that the first part is the same as what you declared above. the YourItem is a class file to hold many properties of your Item. The number 500 is the ID value. The setIconCoord is used to help determine what sprite to use from a sprite sheet. Finally the creative tab Is used to set what tab the Item goes under. NOTE: at this point in the tutorial ItemYourItem will have an error. We are going to create that in a bit. Below is an example of how our item properties will look.
yourItem = (new ItemYourItem(500)).setIconCoord(7, 3);
Now we will need to register a name for our item. This Line of code goes into the FMLInitializationEvent Just like the code above. This line of code requires two things. The first thing is the item and the second thing is name for the Item.
LanguageRegistry.addName(yourItem, "The name for your Item");
We have created the first half of our item, Now we will need to make the ItemYourItem.java, The contents of this class will hold much information. I have provided a basic example of an Item class for you to use.
package your.stuff.here;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class ItemYourItem extends Item {
public ItemYourItem(int id) {
super(id);
//This is a constructor
maxStackSize = 64; //this tells how many of an item can be in one stack
setCreativeTab(CreativeTabs.tabMisc); //this sets the creative tab the item is in
setItemName("yourItem"); //this is a name for your item. this is not the display name
}
}