OSDN Git Service

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