OSDN Git Service

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