/*
* This file is part of Matter Overdrive
* Copyright (c) 2015., Simeon Radivoev, All rights reserved.
*
* Matter Overdrive is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Matter Overdrive is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Matter Overdrive. If not, see <http://www.gnu.org/licenses>.
*/
package matteroverdrive.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import matteroverdrive.Reference;
import matteroverdrive.items.includes.MOBaseItem;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import java.util.List;
/**
* Created by Simeon on 3/15/2015.
*/
public class IsolinearCircuit extends MOBaseItem
{
public static final String[] subItemNames = {"mk1","mk2","mk3","mk4"};
@SideOnly(Side.CLIENT)
private IIcon[] icons;
public IsolinearCircuit(String name)
{
super(name);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
{
list.add(new ItemStack(item, 1, 0));
list.add(new ItemStack(item, 1, 1));
list.add(new ItemStack(item, 1, 2));
list.add(new ItemStack(item, 1, 3));
}
/**
* Gets an holoIcon index based on an item's damage value
*/
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage)
{
int j = MathHelper.clamp_int(damage, 0, 3);
return this.icons[j];
}
/**
* Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have
* different names based on their damage or NBT.
*/
public String getUnlocalizedName(ItemStack stack)
{
int i = MathHelper.clamp_int(stack.getItemDamage(), 0, 3);
return super.getUnlocalizedName() + "." + subItemNames[i];
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.icons = new IIcon[subItemNames.length];
for (int i = 0; i < subItemNames.length; ++i)
{
this.icons[i] = iconRegister.registerIcon(Reference.MOD_ID + ":" + getUnlocalizedName().substring(5) + "_" + subItemNames[i]);
}
this.itemIcon = this.icons[0];
}
}