OSDN Git Service

cfabf5be104398270c4077198d9bea4380441fda
[chemicraft/chemicraft.git] / common / chemicraft / item / ItemAtomGrenade.java
1 package chemicraft.item;
2
3 import java.util.List;
4
5 import cpw.mods.fml.common.Side;
6 import cpw.mods.fml.common.asm.SideOnly;
7
8 import net.minecraft.src.EntityPlayer;
9 import net.minecraft.src.Item;
10 import net.minecraft.src.ItemStack;
11 import net.minecraft.src.NBTTagCompound;
12 import net.minecraft.src.NBTTagList;
13 import net.minecraft.src.World;
14 import chemicraft.entity.EntityAtomGrenade;
15
16 public class ItemAtomGrenade extends Item {
17
18         public ItemAtomGrenade(int par1) {
19                 super(par1);
20         }
21
22         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
23                 if(par1ItemStack.stackSize <= 0){
24                         return null;
25                 }
26
27                 boolean var1 = false;
28                 boolean var2 = false;
29                 boolean var3 = false;
30
31                 if(par1ItemStack.stackTagCompound != null){
32                         NBTTagList var4 = par1ItemStack.getTagCompound().getTagList("Effect");
33
34                         for(int i = 0;i < 3;i++){
35                                 if(!((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("")){
36                                         if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Hydrogen")){
37                                                 var1 = true;
38                                         }
39                                         if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Carbon")){
40                                                 var2 = true;
41                                         }
42                                         if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Uranium")){
43                                                 var3 = true;
44                                         }
45                                 }
46                         }
47                 }
48                 EntityAtomGrenade entity = new EntityAtomGrenade(par2World, par3EntityPlayer, var1, var2, var3);
49                 par2World.spawnEntityInWorld(entity);
50                 par1ItemStack.stackSize--;
51                 return par1ItemStack;
52         }
53
54         @Override
55         public void addInformation(ItemStack par1ItemStack, List par2List) {
56                 System.out.println(par1ItemStack.hasTagCompound());
57                 if(par1ItemStack.hasTagCompound()){
58                         NBTTagList var1 = par1ItemStack.getTagCompound().getTagList("Effect");
59
60                         for(int i = 0;i < 3;i++){
61                                 if(!((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i).equals("")){
62                                         par2List.add(
63                                                         ((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i)
64                                                         );
65                                 }
66                         }
67                 }
68         }
69
70         @Override
71         public String getTextureFile(){
72                 return "/chemicraft/items/items.png";
73         }
74
75 }