OSDN Git Service

2a368384339b018cc0286342ea7eab8e3d120fa7
[chemicraft/chemicraft.git] / common / pcc / chemicraft / core / item / ItemCompounds.java
1 package pcc.chemicraft.core.item;
2
3 import net.minecraft.entity.Entity;
4 import net.minecraft.entity.player.EntityPlayer;
5 import net.minecraft.item.Item;
6 import net.minecraft.item.ItemStack;
7 import net.minecraft.world.World;
8 import pcc.chemicraft.core.ChemiCraftAPI;
9 import pcc.chemicraft.core.ChemiCraftCore;
10
11 public class ItemCompounds extends Item {
12
13         public ItemCompounds(int par1){
14                 super(par1);
15                 this.setHasSubtypes(true);
16                 this.setMaxDamage(0);
17                 this.setCreativeTab(ChemiCraftCore.instance.creativeTabChemiCraft);
18         }
19
20         @Override
21         public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
22                 try {
23                         for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
24                                 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
25                                         return ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemUseHandler(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
26                                 }
27                         }
28                 } catch (IndexOutOfBoundsException e) {
29                         par1ItemStack.stackSize = 0;
30                 }
31                 return false;
32         }
33
34
35         @Override
36         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
37         {
38                 try {
39                         for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
40                                 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
41                                         ChemiCraftAPI.instance().getCompoundHandler().get(i).onItemRightClickHandler(par1ItemStack, par2World, par3EntityPlayer);
42                                 }
43                         }
44                 } catch (IndexOutOfBoundsException e) {
45                         par1ItemStack.stackSize = 0;
46                 }
47                 return par1ItemStack;
48         }
49
50
51
52         @Override
53         public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5){
54                 try {
55                         for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
56                                 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1ItemStack.getItemDamage()).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
57                                         ChemiCraftAPI.instance().getCompoundHandler().get(i).onUpdateHandler(par1ItemStack, par2World, par3Entity, par4, par5);
58                                 }
59                         }
60                 } catch (IndexOutOfBoundsException e) {
61                         par1ItemStack.stackSize = 0;
62                         par1ItemStack = null;
63                 }
64         }
65
66
67
68         /*めんどくさいから発案者やって(´・ω・`) --WIP--
69         @SuppressWarnings({ "unchecked", "rawtypes" })
70         @SideOnly(Side.CLIENT)
71         @Override
72         public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List){
73                 for(int type = 0; type < ChemiCraftAPI.instance().getCompoundsName().get("en_US").size(); type++) {
74                         par3List.add(new ItemStack(par1, 1, type));
75                         this.setIconIndex(type);
76                 }
77         }
78
79
80
81         @Override
82         public String getItemNameIS(ItemStack par1ItemStack){
83                 try {
84                         return super.getItemName() + "." + ChemiCraftAPI.instance().getCompoundsName().get("en_US", par1ItemStack.getItemDamage());
85                 } catch (ArrayIndexOutOfBoundsException e) {
86                         par1ItemStack.stackSize = 0;
87                 }
88                 return null;
89         }
90
91
92
93         @Override
94         public String getTextureFile(){
95                 return ChemiCraft.ITEM_COMPOUNDS_TEXTURE;
96         }
97
98
99
100         @SideOnly(Side.CLIENT)
101         @Override
102         public int getIconFromDamage(int par1){
103                 try {
104                         for(int i=0;i < ChemiCraftAPI.instance().getCompoundHandlerItemName().size();i++){
105                                 if(ChemiCraftAPI.instance().getCompoundsName().getKeyList(par1).equals(ChemiCraftAPI.instance().getCompoundHandlerItemName().get(i))){
106                                         return ChemiCraftAPI.instance().getCompoundHandler().get(i).getIconIndexHandler();
107                                 }
108                         }
109                 } catch (IndexOutOfBoundsException e) {
110                         return 0;
111                 }
112                 return 0;
113         }
114         */
115
116 }