OSDN Git Service

commonとsrc統合。電解機中途半端なので注意。
[chemicraft/chemicraft.git] / src / chemicraft / item / ItemCompounds.java
1 package chemicraft.item;
2
3 import java.util.List;
4
5 import net.minecraft.creativetab.CreativeTabs;
6 import net.minecraft.entity.Entity;
7 import net.minecraft.entity.player.EntityPlayer;
8 import net.minecraft.item.Item;
9 import net.minecraft.item.ItemStack;
10 import net.minecraft.world.World;
11 import chemicraft.ChemiCraft;
12 import chemicraft.ChemiCraftAPI;
13 import cpw.mods.fml.relauncher.Side;
14 import cpw.mods.fml.relauncher.SideOnly;
15
16 public class ItemCompounds extends Item {
17
18         public ItemCompounds(int par1){
19                 super(par1);
20                 this.setHasSubtypes(true);
21                 this.setMaxDamage(0);
22                 this.setCreativeTab(ChemiCraft.instance.creativeTab);
23         }
24
25         @Override
26         public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
27                 for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
28                         if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
29                                 return ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onItemUseHandler(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
30                         }
31                 }
32                 return false;
33         }
34
35
36         @Override
37         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
38         {
39                 for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
40                         if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
41                                 ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onItemRightClickHandler(par1ItemStack, par2World, par3EntityPlayer);
42                         }
43                 }
44                 return par1ItemStack;
45         }
46
47
48
49         @Override
50         public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
51                 for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
52                         if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
53                                 ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
54                         }
55                 }
56         }
57
58
59
60         @SuppressWarnings({ "unchecked", "rawtypes" })
61         @SideOnly(Side.CLIENT)
62         @Override
63         public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
64                 for(int type = 0; type < ChemiCraftAPI.getInstance().getCompoundsName().toArray().length; type++)
65                 {
66                         par3List.add(new ItemStack(par1, 1, type));
67                         this.setIconIndex(type);
68                 }
69         }
70
71
72
73         @Override
74         public String getItemNameIS(ItemStack par1ItemStack){
75                 return super.getItemName() + "." + ChemiCraftAPI.getInstance().getCompoundsName().toArray()[par1ItemStack.getItemDamage()];
76         }
77
78
79
80         @Override
81         public String getTextureFile(){
82                 return ChemiCraft.instance.itemCompoundsTexture;
83         }
84
85
86
87         @SideOnly(Side.CLIENT)
88         @Override
89         public int getIconFromDamage(int par1){
90                 for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
91                         if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
92                                 return ChemiCraftAPI.getInstance().getCompoundHandler().get(i).getIconIndexHandler();
93                         }
94                 }
95                 return 0;
96         }
97
98 }