OSDN Git Service

Merge branch 'master' of https://scm.sourceforge.jp/gitroot/chemicraft/chemicraft
[chemicraft/ChemiCraftNext.git] / common / pcc / chemicraft / item / ItemCompounds.java
1 package pcc.chemicraft.item;
2
3 import java.util.List;
4
5 <<<<<<< HEAD
6 import pcc.chemicraft.ChemiCraft;
7 import pcc.chemicraft.ChemiCraftAPI;
8
9 =======
10 >>>>>>> a5e4a5c40b9001657f1e36ece533651f63183fbe
11 import net.minecraft.creativetab.CreativeTabs;
12 import net.minecraft.entity.Entity;
13 import net.minecraft.entity.player.EntityPlayer;
14 import net.minecraft.item.Item;
15 import net.minecraft.item.ItemStack;
16 import net.minecraft.world.World;
17 <<<<<<< HEAD
18 =======
19 import pcc.chemicraft.ChemiCraft;
20 import pcc.chemicraft.ChemiCraftAPI;
21 >>>>>>> a5e4a5c40b9001657f1e36ece533651f63183fbe
22 import cpw.mods.fml.relauncher.Side;
23 import cpw.mods.fml.relauncher.SideOnly;
24
25 public class ItemCompounds extends Item {
26
27         public ItemCompounds(int par1){
28                 super(par1);
29                 this.setHasSubtypes(true);
30                 this.setMaxDamage(0);
31                 this.setCreativeTab(ChemiCraft.instance.creativeTab);
32         }
33
34         @Override
35         public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
36 <<<<<<< HEAD
37                 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
38                         if(ChemiCraftAPI.instance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
39                                 return ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemUseHandler(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
40                         }
41 =======
42                 try {
43                         for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
44                                 if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
45                                         return ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onItemUseHandler(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
46                                 }
47                         }
48                 } catch (IndexOutOfBoundsException e) {
49                         par1ItemStack.stackSize = 0;
50 >>>>>>> a5e4a5c40b9001657f1e36ece533651f63183fbe
51                 }
52                 return false;
53         }
54
55
56         @Override
57         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
58         {
59 <<<<<<< HEAD
60                 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
61                         if(ChemiCraftAPI.instance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
62                                 ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemRightClickHandler(par1ItemStack, par2World, par3EntityPlayer);
63                         }
64 =======
65                 try {
66                         for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
67                                 if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
68                                         ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onItemRightClickHandler(par1ItemStack, par2World, par3EntityPlayer);
69                                 }
70                         }
71                 } catch (IndexOutOfBoundsException e) {
72                         par1ItemStack.stackSize = 0;
73 >>>>>>> a5e4a5c40b9001657f1e36ece533651f63183fbe
74                 }
75                 return par1ItemStack;
76         }
77
78
79
80         @Override
81         public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
82 <<<<<<< HEAD
83                 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
84                         if(ChemiCraftAPI.instance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
85                                 ChemiCraftAPI.instance().getCompoundHandler().get(i).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
86                         }
87 =======
88                 try {
89                         for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
90                                 if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
91                                         ChemiCraftAPI.getInstance().getCompoundHandler().get(i).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
92                                 }
93                         }
94                 } catch (IndexOutOfBoundsException e) {
95                         par1ItemStack.stackSize = 0;
96                         par1ItemStack = null;
97 >>>>>>> a5e4a5c40b9001657f1e36ece533651f63183fbe
98                 }
99         }
100
101
102
103         @SuppressWarnings({ "unchecked", "rawtypes" })
104         @SideOnly(Side.CLIENT)
105         @Override
106         public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
107 <<<<<<< HEAD
108                 for(int type = 0; type < ChemiCraftAPI.instance().getCompoundsName().toArray().length; type++)
109 =======
110                 for(int type = 0; type < ChemiCraftAPI.getInstance().getCompoundsName().toArray().length; type++)
111 >>>>>>> a5e4a5c40b9001657f1e36ece533651f63183fbe
112                 {
113                         par3List.add(new ItemStack(par1, 1, type));
114                         this.setIconIndex(type);
115                 }
116         }
117
118
119
120         @Override
121         public String getItemNameIS(ItemStack par1ItemStack){
122 <<<<<<< HEAD
123                 return super.getItemName() + "." + ChemiCraftAPI.instance().getCompoundsName().toArray()[par1ItemStack.getItemDamage()];
124 =======
125                 try {
126                         return super.getItemName() + "." + ChemiCraftAPI.getInstance().getCompoundsName().toArray()[par1ItemStack.getItemDamage()];
127                 } catch (ArrayIndexOutOfBoundsException e) {
128                         par1ItemStack.stackSize = 0;
129                 }
130                 return null;
131 >>>>>>> a5e4a5c40b9001657f1e36ece533651f63183fbe
132         }
133
134
135
136         @Override
137         public String getTextureFile(){
138                 return ChemiCraft.instance.ITEMCOMPOUNDSTEXTURE;
139         }
140
141
142
143         @SideOnly(Side.CLIENT)
144         @Override
145         public int getIconFromDamage(int par1){
146 <<<<<<< HEAD
147                 for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
148                         if(ChemiCraftAPI.instance().getCompoundsName().get(par1).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
149                                 return ChemiCraftAPI.instance().getCompoundHandler().get(i).getIconIndexHandler();
150                         }
151 =======
152                 try {
153                         for(int i=0;i < ChemiCraftAPI.getInstance().getCompoundHandlerItemName().size();i++){
154                                 if(ChemiCraftAPI.getInstance().getCompoundsName().get(par1).equals(ChemiCraftAPI.getInstance().getCompoundHandlerItemName().get(i))){
155                                         return ChemiCraftAPI.getInstance().getCompoundHandler().get(i).getIconIndexHandler();
156                                 }
157                         }
158                 } catch (IndexOutOfBoundsException e) {
159                         return 0;
160 >>>>>>> a5e4a5c40b9001657f1e36ece533651f63183fbe
161                 }
162                 return 0;
163         }
164
165 }