OSDN Git Service

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