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.client.renderer.texture.IconRegister;
6 import net.minecraft.entity.player.EntityPlayer;
7 import net.minecraft.item.Item;
8 import net.minecraft.item.ItemStack;
9 import net.minecraft.nbt.NBTTagCompound;
10 import net.minecraft.nbt.NBTTagList;
11 import net.minecraft.world.World;
12 import pcc.chemicraft.ChemiCraft;
13 import pcc.chemicraft.base.entity.EntityAtomsGrenade;
14
15 /**
16  * 手榴弾のアイテムです。
17  * @author mozipi
18  */
19 public class ItemAtomsGrenade extends Item {
20
21         public ItemAtomsGrenade(int par1) {
22                 super(par1);
23         }
24
25         @Override
26         public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
27                 if (par1ItemStack.stackSize <= 0) {
28                         return null;
29                 }
30
31                 boolean var1 = false;
32                 boolean var2 = false;
33                 boolean var3 = false;
34
35                 if (par1ItemStack.stackTagCompound != null) {
36                         NBTTagList var4 = par1ItemStack.getTagCompound().getTagList("Effect");
37
38                         for (int i = 0;i < 3;i++) {
39                                 if (!((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("")) {
40                                         if (((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Hydrogen")) {
41                                                 var1 = true;
42                                         }
43                                         if (((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Carbon")) {
44                                                 var2 = true;
45                                         }
46                                         if (((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Uranium")) {
47                                                 var3 = true;
48                                         }
49                                 }
50                         }
51                 }
52                 if (!par2World.isRemote) {
53                         EntityAtomsGrenade entity = new EntityAtomsGrenade(par2World, par3EntityPlayer, var1, var2, var3);
54                         par2World.spawnEntityInWorld(entity);
55                 }
56                 par1ItemStack.stackSize--;
57                 return par1ItemStack;
58         }
59
60         @Override
61         public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
62                 ItemStack var2 = new ItemStack(this);
63                 if (par1ItemStack.hasTagCompound()) {
64                         NBTTagList var1 = par1ItemStack.getTagCompound().getTagList("Effect");
65
66                         for (int i = 0;i < 3;i++) {
67                                 if (!((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i).equals("")) {
68                                         par3List.add(
69                                                         ((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i)
70                                                         );
71                                 }
72                         }
73                 }
74         }
75
76         @Override
77         public boolean getShareTag()
78         {
79                 return true;
80         }
81
82         @Override
83         public void updateIcons(IconRegister par1IconRegister){
84                 this.iconIndex = par1IconRegister.registerIcon(ChemiCraft.ITEM_TEXTURE + "ItemAtomsGrenade");
85         }
86
87 }