Basic Items
A basic item is an item basically like sticks that have no special features. Again we need to add a few lines of code to our Core File.
Core Class:
package mymod.common;
import net.minecraft.src.*;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "ID of Your Mod", name = "Name of Your Mod", version = "Version of Your Mod")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class CoreModFileName
{
@SidedProxy(clientSide = "mymod.client.ClientProxy", serverSide = "mymod.common.CommonProxy")
public static CommonProxy proxy;
public static Block BasicBlock;
public static Item BasicItem;
@Init
public void Init(FMLInitializationEvent event)
{
BasicBlock = new BlockBasicBlock(3000, 0);
GameRegistry.registerBlock(BasicBlock);
LanguageRegistry.addName(BasicBlock, "Basic Block");
//Again, the 3200 is the item ID and this time there is no second parameter. The 16X texture it will use will come from a method called .setIconIndex(). This will be explained in the actual class. The LanguageRegistry gives the item it's name.
BasicItem = new ItemBasicItem(3200);
LanguageRegistry.addName(BasicItem, "Basic Item");
proxy.registerRenderThings();
}
}
Next thing is to actually make the item's class. Call it ItemBasicItem or whatever you want. If you name it something else, just remember to change it in the core file too. All of the methods are already explained in the Basic Block tutorial so there won't be anything else to explain.
ItemBasicItem:
package mymod.common;
import net.minecraft.src.*;
import java.util.Random;
import java.util.List;
public class ItemBasicItem extends Item
{
public ItemBasicItem(int a)
{
super(a);
//Name of the Item
this.setItemName("Basic Item");
//The 16X texture that it will load, 0 being at the top left. Wherever your texture is just change the number to whatever it is.
this.setIconIndex(0);
//What Creative Tab to display it on, I'll put a tutorial on how to make your own eventually.
this.setCreativeTab(CreativeTabs.tabMaterials);
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("A Basic Item");
}
public String getTextureFile()
{
return "/myitems.png";
}
}
Core Class:
package mymod.common;
import net.minecraft.src.*;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "ID of Your Mod", name = "Name of Your Mod", version = "Version of Your Mod")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class CoreModFileName
{
@SidedProxy(clientSide = "mymod.client.ClientProxy", serverSide = "mymod.common.CommonProxy")
public static CommonProxy proxy;
public static Block BasicBlock;
public static Item BasicItem;
@Init
public void Init(FMLInitializationEvent event)
{
BasicBlock = new BlockBasicBlock(3000, 0);
GameRegistry.registerBlock(BasicBlock);
LanguageRegistry.addName(BasicBlock, "Basic Block");
//Again, the 3200 is the item ID and this time there is no second parameter. The 16X texture it will use will come from a method called .setIconIndex(). This will be explained in the actual class. The LanguageRegistry gives the item it's name.
BasicItem = new ItemBasicItem(3200);
LanguageRegistry.addName(BasicItem, "Basic Item");
proxy.registerRenderThings();
}
}
Next thing is to actually make the item's class. Call it ItemBasicItem or whatever you want. If you name it something else, just remember to change it in the core file too. All of the methods are already explained in the Basic Block tutorial so there won't be anything else to explain.
ItemBasicItem:
package mymod.common;
import net.minecraft.src.*;
import java.util.Random;
import java.util.List;
public class ItemBasicItem extends Item
{
public ItemBasicItem(int a)
{
super(a);
//Name of the Item
this.setItemName("Basic Item");
//The 16X texture that it will load, 0 being at the top left. Wherever your texture is just change the number to whatever it is.
this.setIconIndex(0);
//What Creative Tab to display it on, I'll put a tutorial on how to make your own eventually.
this.setCreativeTab(CreativeTabs.tabMaterials);
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("A Basic Item");
}
public String getTextureFile()
{
return "/myitems.png";
}
}