52
Hello My fellow InterWebians todays
Lets Make A Mod! consists of making your first item now to make an item
First as always open your mod in eclipse
Now we have our mod open heres what we are going to do first your going to want to make a variable as always so in your public static section (the same one we used for the block) type this:
public static Item YourItemName;
now that we have our variable hit CTRL+SHIFT+O (to sort out our imports)
now that we have done that go into your @Init method and type this
YourItemName = (new ItemYourItemName(900)).setItemYourItemName("Code Name Anything here");
Now 900 is out item id this can be anything but make sure not to overload it because it could crash the game! I really shouldnt mention this now but oh whatever add .setIconIndex(0) in between the )) and .setItemName this we wont use yet we will come back to it in our custom textures tutorial. You should have an error over ItemYourItemName because it doesnt exist yet we will come back to this.
Now lets add a human readable name. Add this line under the previous code.
LanguageRegistry.addName(YourItemName, "Your Items In Game Name");
now as i said we would come back to that error we are now go back to the error i mentioned and hover over it and choose create class ItemYourItemName now that we have your Item**** class we need to add extends item to the end of public class ****** this is how it should look
package yourusername.yourmodname.common;
import net.minecraft.src.Item;
public class ItemYourItemName extends Item {
}
Now we have to add the constructor
public ItemYourItemName(int par1){
}
Par 1 is used to define the item id this is important!
now just stick a super(par1); on the end of it and this is how it should turn out:
package yourusername.yourmodname.common;
import net.minecraft.src.Item;
public class ItemYourItemName extends Item {
public ItemYourItemName(int par1){
super(par1);
}
}
now on to customization
to set a creative tab to your item add this line to the constructor
this.setCreativeTab(CreativeTabs.tabMaterials);
materials is obviously the variable here just switch it to a different tab to change the tab ex. tabBlock
now however I havent shown you everything possible in customization which will come soon always make sure to stick this into the constructor:
maxStackSize = 64;
Now heres our final codes:
Lets Make A Mod! consists of making your first item now to make an item
First as always open your mod in eclipse
Now we have our mod open heres what we are going to do first your going to want to make a variable as always so in your public static section (the same one we used for the block) type this:
public static Item YourItemName;
now that we have our variable hit CTRL+SHIFT+O (to sort out our imports)
now that we have done that go into your @Init method and type this
YourItemName = (new ItemYourItemName(900)).setItemYourItemName("Code Name Anything here");
Now 900 is out item id this can be anything but make sure not to overload it because it could crash the game! I really shouldnt mention this now but oh whatever add .setIconIndex(0) in between the )) and .setItemName this we wont use yet we will come back to it in our custom textures tutorial. You should have an error over ItemYourItemName because it doesnt exist yet we will come back to this.
Now lets add a human readable name. Add this line under the previous code.
LanguageRegistry.addName(YourItemName, "Your Items In Game Name");
now as i said we would come back to that error we are now go back to the error i mentioned and hover over it and choose create class ItemYourItemName now that we have your Item**** class we need to add extends item to the end of public class ****** this is how it should look
package yourusername.yourmodname.common;
import net.minecraft.src.Item;
public class ItemYourItemName extends Item {
}
Now we have to add the constructor
public ItemYourItemName(int par1){
}
Par 1 is used to define the item id this is important!
now just stick a super(par1); on the end of it and this is how it should turn out:
package yourusername.yourmodname.common;
import net.minecraft.src.Item;
public class ItemYourItemName extends Item {
public ItemYourItemName(int par1){
super(par1);
}
}
now on to customization
to set a creative tab to your item add this line to the constructor
this.setCreativeTab(CreativeTabs.tabMaterials);
materials is obviously the variable here just switch it to a different tab to change the tab ex. tabBlock
now however I havent shown you everything possible in customization which will come soon always make sure to stick this into the constructor:
maxStackSize = 64;
Now heres our final codes:
YourModNameMain.java
ItemYourItemName.java
Tags |
tools/tracking
1729319
6
lets-make-a-mod-ep4-your-first-item
Create an account or sign in to comment.