OSDN Git Service

要チェック!!!
[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.base.entity.EntityAtomsGrenade;
12
13 public class ItemAtomsGrenade extends Item {
14
15         public ItemAtomsGrenade(int par1) {
16                 super(par1);
17         }
18
19         @Override
20         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
21                 if(par1ItemStack.stackSize <= 0){
22                         return null;
23                 }
24
25                 boolean var1 = false;
26                 boolean var2 = false;
27                 boolean var3 = false;
28
29                 if(par1ItemStack.stackTagCompound != null){
30                         NBTTagList var4 = par1ItemStack.getTagCompound().getTagList("Effect");
31
32                         for(int i = 0;i < 3;i++){
33                                 if(!((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("")){
34                                         if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Hydrogen")){
35                                                 var1 = true;
36                                         }
37                                         if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Carbon")){
38                                                 var2 = true;
39                                         }
40                                         if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Uranium")){
41                                                 var3 = true;
42                                         }
43                                 }
44                         }
45                 }
46                 EntityAtomsGrenade entity = new EntityAtomsGrenade(par2World, par3EntityPlayer, var1, var2, var3);
47                 par2World.spawnEntityInWorld(entity);
48                 par1ItemStack.stackSize--;
49                 return par1ItemStack;
50         }
51
52         @Override
53         public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
54                 ItemStack var2 = new ItemStack(this);
55                 if(par1ItemStack.hasTagCompound()){
56                         NBTTagList var1 = par1ItemStack.getTagCompound().getTagList("Effect");
57
58                         for(int i = 0;i < 3;i++){
59                                 if(!((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i).equals("")){
60                                         par3List.add(
61                                                         ((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i)
62                                                         );
63                                 }
64                         }
65                 }
66         }
67
68         @Override
69         public boolean getShareTag()
70         {
71                 return true;
72         }
73
74         @Override
75         public String getTextureFile(){
76                 return "/chemicraft/items/items.png";
77         }
78
79 }