OSDN Git Service

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