OSDN Git Service

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