OSDN Git Service

3dc1d6435d57333a3994e48f34820b46e0176d60
[chemicraft/ChemiCraftNext.git] / common / chemicraft / item / ItemCompounds.java
1 package chemicraft.item;
2
3 import java.util.List;
4
5 import net.minecraft.src.CreativeTabs;
6 import net.minecraft.src.Entity;
7 import net.minecraft.src.Item;
8 import net.minecraft.src.ItemStack;
9 import net.minecraft.src.World;
10 import chemicraft.ChemiCraft;
11 import chemicraft.ChemiCraftAPI;
12 import cpw.mods.fml.common.Side;
13 import cpw.mods.fml.common.asm.SideOnly;
14
15 public class ItemCompounds extends Item {
16
17         public ItemCompounds(int par1){
18                 super(par1);
19                 this.maxStackSize = 1;
20                 this.setHasSubtypes(true);
21                 this.setMaxDamage(0);
22                 this.setCreativeTab(ChemiCraft.instance.creativeTab);
23         }
24
25
26
27         @Override
28         public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
29                 for(int i=0;i < ChemiCraftAPI.instance.getCompoundsName().size();i++){
30                         for(int j=0;j < ChemiCraftAPI.instance.getCompoundHandlerItemName().size();j++){
31                                 if(ChemiCraftAPI.instance.getCompoundsName().get(i).equals(ChemiCraftAPI.instance.getCompoundHandlerItemName().get(i))){
32                                         ChemiCraftAPI.instance.getCompoundHandler().get(j).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
33                                 }
34                         }
35                 }
36         }
37
38
39
40         @SideOnly(Side.CLIENT)
41         @Override
42         public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
43                 for(int type = 0; type < ChemiCraftAPI.instance.getCompoundsName().toArray().length; type++)
44                 {
45                         par3List.add(new ItemStack(par1, 1, type));
46                         this.setIconIndex(type);
47                 }
48         }
49
50
51
52         @Override
53         public String getItemNameIS(ItemStack par1ItemStack){
54                 return super.getItemName() + "." + ChemiCraftAPI.instance.getCompoundsName().toArray()[par1ItemStack.getItemDamage()];
55         }
56
57
58
59         @Override
60         public String getTextureFile(){
61                 return ChemiCraft.instance.itemCompoundsTexture;
62         }
63
64
65
66         @SideOnly(Side.CLIENT)
67         @Override
68         public int getIconFromDamage(int par1){
69                 return par1;
70         }
71
72 }