BiomesOPlenty/common/biomesoplenty/items/ItemBOP.java

88 lines
2.1 KiB
Java
Raw Normal View History

2013-05-03 13:00:44 +00:00
package biomesoplenty.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Items;
2013-05-03 13:00:44 +00:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBOP extends Item
{
private static String[] items = {"mudbrick", "ash", "emptyhoneycomb", "thing", "crystalshard", "bluedye", "browndye", "greendye", "whitedye", "blackdye", "ghastlysoul", "jarempty", "jarhoney", "jarpoison"};
2013-05-31 10:34:02 +00:00
@SideOnly(Side.CLIENT)
private Icon[] textures;
2013-05-03 13:00:44 +00:00
public ItemBOP(int id)
{
super(id);
setMaxDamage(0);
2013-05-31 10:34:02 +00:00
setHasSubtypes(true);
2013-05-03 13:00:44 +00:00
setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
2013-05-31 10:34:02 +00:00
@Override
2013-05-03 13:00:44 +00:00
public void registerIcons(IconRegister iconRegister)
{
2013-05-31 10:34:02 +00:00
textures = new Icon[items.length];
for (int i = 0; i < items.length; ++i) {
textures[i] = iconRegister.registerIcon("biomesoplenty:"+items[i]);
2013-05-31 10:34:02 +00:00
}
}
@Override
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= items.length) {
meta = 0;
}
2013-06-09 08:15:39 +00:00
return super.getUnlocalizedName() + "." + items[meta];
2013-05-03 13:00:44 +00:00
}
2013-05-31 10:34:02 +00:00
2013-05-03 13:00:44 +00:00
@Override
2013-05-31 10:34:02 +00:00
public Icon getIconFromDamage(int meta)
{
if (meta < 0 || meta >= textures.length) {
meta = 0;
}
return textures[meta];
}
@Override
public int getItemStackLimit(ItemStack par1ItemStack)
{
if (par1ItemStack.itemID == this.itemID && par1ItemStack.getItemDamage() == 11)
{
return 1;
}
if (par1ItemStack.itemID == this.itemID && par1ItemStack.getItemDamage() == 12)
{
return 1;
}
if (par1ItemStack.itemID == this.itemID && par1ItemStack.getItemDamage() == 13)
{
return 1;
}
return 64;
}
2013-05-31 10:34:02 +00:00
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubItems(int itemId, CreativeTabs creativeTab, List subTypes)
{
for(int meta = 0; meta < items.length; ++meta) {
subTypes.add(new ItemStack(itemId, 1, meta));
}
}
2013-05-03 13:00:44 +00:00
}