OSDN Git Service

いろいろした
[chemicraft/chemicraft.git] / common / pcc / chemicraft / base / item / ItemAtomsGrenade.java
index cfca3b1..6050964 100644 (file)
@@ -8,8 +8,13 @@ import net.minecraft.item.ItemStack;
 import net.minecraft.nbt.NBTTagCompound;
 import net.minecraft.nbt.NBTTagList;
 import net.minecraft.world.World;
+import pcc.chemicraft.ChemiCraft;
 import pcc.chemicraft.base.entity.EntityAtomsGrenade;
 
+/**
+ * 手榴弾のアイテムです。
+ * @author mozipi
+ */
 public class ItemAtomsGrenade extends Item {
 
        public ItemAtomsGrenade(int par1) {
@@ -17,8 +22,8 @@ public class ItemAtomsGrenade extends Item {
        }
 
        @Override
-       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
-               if(par1ItemStack.stackSize <= 0){
+       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
+               if (par1ItemStack.stackSize <= 0) {
                        return null;
                }
 
@@ -26,25 +31,27 @@ public class ItemAtomsGrenade extends Item {
                boolean var2 = false;
                boolean var3 = false;
 
-               if(par1ItemStack.stackTagCompound != null){
+               if (par1ItemStack.stackTagCompound != null) {
                        NBTTagList var4 = par1ItemStack.getTagCompound().getTagList("Effect");
 
-                       for(int i = 0;i < 3;i++){
-                               if(!((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("")){
-                                       if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Hydrogen")){
+                       for (int i = 0;i < 3;i++) {
+                               if (!((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("")) {
+                                       if (((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Hydrogen")) {
                                                var1 = true;
                                        }
-                                       if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Carbon")){
+                                       if (((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Carbon")) {
                                                var2 = true;
                                        }
-                                       if(((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Uranium")){
+                                       if (((NBTTagCompound)var4.tagAt(0)).getString("GrenadeEffect" + i).equals("Uranium")) {
                                                var3 = true;
                                        }
                                }
                        }
                }
-               EntityAtomsGrenade entity = new EntityAtomsGrenade(par2World, par3EntityPlayer, var1, var2, var3);
-               par2World.spawnEntityInWorld(entity);
+               if (!par2World.isRemote) {
+                       EntityAtomsGrenade entity = new EntityAtomsGrenade(par2World, par3EntityPlayer, var1, var2, var3);
+                       par2World.spawnEntityInWorld(entity);
+               }
                par1ItemStack.stackSize--;
                return par1ItemStack;
        }
@@ -52,11 +59,11 @@ public class ItemAtomsGrenade extends Item {
        @Override
        public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
                ItemStack var2 = new ItemStack(this);
-               if(par1ItemStack.hasTagCompound()){
+               if (par1ItemStack.hasTagCompound()) {
                        NBTTagList var1 = par1ItemStack.getTagCompound().getTagList("Effect");
 
-                       for(int i = 0;i < 3;i++){
-                               if(!((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i).equals("")){
+                       for (int i = 0;i < 3;i++) {
+                               if (!((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i).equals("")) {
                                        par3List.add(
                                                        ((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i)
                                                        );
@@ -73,7 +80,7 @@ public class ItemAtomsGrenade extends Item {
 
        @Override
        public String getTextureFile(){
-               return "/chemicraft/items/items.png";
+               return ChemiCraft.ITEM_TEXTURE;
        }
 
 }