package pegasusepsilon.hardmodenavigation.common;
import java.util.ArrayList;
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 cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CraftingIngredient extends Item {
public static final String MODID = HardModeNavigation.MODID;
public enum internalNames {
itemRoughCutLens,
itemDiamondSand,
itemGroundLens,
itemDiamondDust,
itemPolishingCompound,
itemPolishedLens
}
private static final String[] visibleNames = {
"Rough Cut Lens",
"Diamond Sand",
"Ground Lens",
"Diamond Dust",
"Polishing Compound",
"Polished Lens"
};
private static final int numIngredients = internalNames.values().length;
public CraftingIngredient (int id) {
super(id);
// explode if lists aren't in sync
assert visibleNames.length == numIngredients;
setHasSubtypes(true);
setMaxDamage(0);
setMaxStackSize(64);
setCreativeTab(CreativeTabs.tabMaterials);
}
@SideOnly(Side.CLIENT)
public String getUnlocalizedName (ItemStack what) {
int dmg = what.getItemDamage();
return internalNames.values()[dmg <= numIngredients ? dmg : 0].toString();
}
@SideOnly(Side.CLIENT)
public void getSubItems (int id, CreativeTabs tab, List items) {
for (internalNames item : internalNames.values()) {
items.add(new ItemStack(id, 1, item.ordinal()));
}
}
@SideOnly(Side.CLIENT)
public String getItemDisplayName (ItemStack what) {
int dmg = what.getItemDamage();
return visibleNames[dmg <= numIngredients ? dmg : 0];
}
@SideOnly(Side.CLIENT)
private List<Icon> icons = new ArrayList<Icon>();
@SideOnly(Side.CLIENT)
public Icon getIconFromDamage (int dmg) {
return icons.get(dmg <= numIngredients ? dmg : 0);
}
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister reg) {
for (internalNames item : internalNames.values()) {
icons.add(reg.registerIcon(MODID + ":" + item.name()));
}
}
}