package pcc.chemicraft.core.item;
+import java.util.ArrayList;
import java.util.List;
+import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
import net.minecraft.world.World;
-import pcc.chemicraft.ChemiCraft;
import pcc.chemicraft.core.ChemiCraftAPI;
import pcc.chemicraft.core.ChemiCraftCore;
import cpw.mods.fml.relauncher.Side;
public class ItemCompounds extends Item {
+ private Icon[] icons;
+
public ItemCompounds(int par1){
super(par1);
this.setHasSubtypes(true);
@Override
- public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
- {
+ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
try {
for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
@Override
- public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
+ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
try {
for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
for(int type = 0; type < ChemiCraftAPI.instance().getCompoundsName().get("en_US").size(); type++) {
par3List.add(new ItemStack(par1, 1, type));
- this.setIconIndex(type);
}
}
@Override
- public String getItemNameIS(ItemStack par1ItemStack){
- try {
- return super.getItemName() + "." + ChemiCraftAPI.instance().getCompoundsName().get("en_US", par1ItemStack.getItemDamage());
- } catch (ArrayIndexOutOfBoundsException e) {
- par1ItemStack.stackSize = 0;
- }
- return null;
+ public String getUnlocalizedName(ItemStack par1ItemStack){
+ return super.getUnlocalizedName() + "." + ChemiCraftCore.instance.api.getCompoundsName().get("en_US", par1ItemStack.getItemDamage());
}
@Override
- public String getTextureFile(){
- return ChemiCraft.ITEM_COMPOUNDS_TEXTURE;
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister) {
+ ArrayList<String> textures = ChemiCraftAPI.getCompoundsTexture();
+ this.icons = new Icon[textures.size()];
+ for (int i = 0; i < textures.size(); i++) {
+ this.icons[i] = par1IconRegister.registerIcon(textures.get(i));
+ }
}
-
-
- @SideOnly(Side.CLIENT)
@Override
- public int getIconFromDamage(int par1){
- try {
- for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
- if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
- return ChemiCraftAPI.instance().getCompoundHandler().get(i).getIconIndexHandler();
- }
- }
- } catch (IndexOutOfBoundsException e) {
- return 0;
- }
- return 0;
+ @SideOnly(Side.CLIENT)
+ public Icon getIconFromDamage(int par1) {
+ return this.icons[par1];
}
}