OSDN Git Service

手榴弾追加
authormozipi <mozipi@users.sourceforge.jp>
Sat, 22 Dec 2012 09:10:37 +0000 (18:10 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Sat, 22 Dec 2012 09:10:37 +0000 (18:10 +0900)
common/chemicraft/ChemiCraft.java
common/chemicraft/ChemiCraftCraftingManager.java
common/chemicraft/ItemGasCollectingBottle.java
common/chemicraft/ItemGrenade.java [new file with mode: 0644]
common/chemicraft/NBTRecipeGrenade.java

index 416eba4..e3e157a 100644 (file)
@@ -67,6 +67,7 @@ public class ChemiCraft {
        public int atomsID;\r
        public int compoundsID;\r
        public int gasCollectingBottleID;\r
+       public int grenadeID;\r
 \r
        /**\r
         * BlockID\r
@@ -98,12 +99,14 @@ public class ChemiCraft {
        public static Item itemAtoms;\r
        public static Item itemCompounds;\r
        public static Item itemGasCollectingBottle;\r
+       public static Item itemGrenade;\r
 \r
        /**\r
         * このmodで使用するTextureのパス\r
         */\r
        public String itemAtomsTexture = "/chemicraft/items/Atoms.png";\r
        public String itemCompoundsTexture = "/chemicraft/items/Compounds.png";\r
+       public String itemTexture = "/chemicraft/items/items.png";\r
        public String blockChemicalCraftingTableTexture = "/chemicraft/blocks/CCTable.png";\r
        public String guiDecompositionTexture = "/chemicraft/guis/Decomposition.png";\r
        public String guiChemicalCombinationTexture = "/chemicraft/guis/ChemicalCombination.png";\r
@@ -129,6 +132,7 @@ public class ChemiCraft {
                Property atomsIDProp = cfg.getItem("AtomsID", 25000);\r
                Property compoundsIDProp = cfg.getItem("CompoundsID", 25001);\r
                Property gasCollectingBottleIDProp = cfg.getItem("gasCollectingBottleID", 25002);\r
+               Property grenadeIDProp = cfg.getItem("GrenadeID0", 25003);\r
 \r
                Property guiDecompositionTableIDProp = cfg.get("GUI", "GUIChemicalCraftingTableID", 1000);\r
                Property guiChemicalCombinationTableIDProp = cfg.get("GUI", "GUIChemicalCombinationTableID", 1001);\r
@@ -143,6 +147,7 @@ public class ChemiCraft {
                this.atomsID = atomsIDProp.getInt();\r
                this.compoundsID = compoundsIDProp.getInt();\r
                this.gasCollectingBottleID = gasCollectingBottleIDProp.getInt();\r
+               this.grenadeID = grenadeIDProp.getInt();\r
                this.guiDecompositionTableID = guiDecompositionTableIDProp.getInt();\r
                this.guiChemicalCombinationTableID = guiChemicalCombinationTableIDProp.getInt();\r
                this.guiToolAndWeaponCraftingTableID = guiToolAndWeaponCraftingTableIDProp.getInt();\r
@@ -171,7 +176,8 @@ public class ChemiCraft {
                // Itemを追加します\r
                this.itemAtoms = new ItemAtoms(this.atomsID).setItemName("atoms");\r
                this.itemCompounds = new ItemCompounds(this.compoundsID).setItemName("compounds");\r
-               this.itemGasCollectingBottle = new ItemGasCollectingBottle(this.gasCollectingBottleID).setItemName("gasCollectingBottle");\r
+               this.itemGasCollectingBottle = new ItemGasCollectingBottle(this.gasCollectingBottleID).setItemName("gasCollectingBottle").setIconIndex(0);\r
+               this.itemGrenade = new ItemGrenade(this.grenadeID).setItemName("grenade").setIconIndex(1);\r
 \r
                // BlockをMinecraftに登録します\r
                GameRegistry.registerBlock(this.blockDecompositionTable);\r
@@ -195,6 +201,8 @@ public class ChemiCraft {
                this.NameAuxiliary.addName(this.itemAtoms, "ja_JP", atomsNameJP);\r
                this.NameAuxiliary.addName(this.itemGasCollectingBottle, "GasCollectingBottle");\r
                this.NameAuxiliary.addName(this.itemGasCollectingBottle, "ja_JP", "集気瓶");\r
+               this.NameAuxiliary.addName(this.itemGrenade, "Grenade");\r
+               this.NameAuxiliary.addName(this.itemGrenade, "手榴弾");\r
 \r
                // TileEntityを追加します\r
                GameRegistry.registerTileEntity(TileEntityDecompositionTable.class, "DecompositionTable");\r
@@ -208,9 +216,7 @@ public class ChemiCraft {
                //Textureをpreloadします\r
                proxy.registerTextures();\r
 \r
-               ChemiCraftAPI.instance.addChemicalCombinationRecipe(new ItemStack[]{new ItemStack(Block.stone)}, new ItemStack(Block.dirt));\r
-\r
-               ChemiCraftAPI.instance.addMaterialRecipe(new ItemStack[]{new ItemStack(Block.dirt)}, new ItemStack(Block.stone), new NBTRecipeGrenade());\r
+               ChemiCraftAPI.instance.addMaterialRecipe(new ItemStack[]{new ItemStack(Block.dirt)}, new ItemStack(this.itemGrenade), new NBTRecipeGrenade());\r
 \r
        }\r
 \r
index 2503469..be0d0e1 100644 (file)
@@ -196,9 +196,11 @@ public class ChemiCraftCraftingManager {
                                                                ChemiCraftAPI.instance.getMaterialResult().get(i).getItemDamage()
                                                                );
 
-                               ItemStack[] useItems = ChemiCraftAPI.instance.getMaterialNBTRecipe().get(i).setNBT(effectMaterial.toArray(new ItemStack[3]), result);
+                               if(ChemiCraftAPI.instance.getMaterialNBTRecipe().get(i) != null){
+                                       ItemStack[] useItems = ChemiCraftAPI.instance.getMaterialNBTRecipe().get(i).setNBT(effectMaterial.toArray(new ItemStack[3]), result);
 
-                               ((InventoryMaterialCrafting) par1IInventory).subtractStack(0, 3, useItems);
+                                       ((InventoryMaterialCrafting) par1IInventory).subtractStack(0, 3, useItems);
+                               }
 
                                ((InventoryMaterialCrafting) par1IInventory).setFlag2(false);
 
index 17843c8..cbc2608 100644 (file)
@@ -29,7 +29,7 @@ public class ItemGasCollectingBottle extends ItemAtomInfoContainer {
 
        @Override
        public String getTextureFile() {
-               return "/ChemiCraft/items/sprite.png";
+               return "/chemicraft/items/items.png";
        }
 
 }
diff --git a/common/chemicraft/ItemGrenade.java b/common/chemicraft/ItemGrenade.java
new file mode 100644 (file)
index 0000000..697660f
--- /dev/null
@@ -0,0 +1,34 @@
+package chemicraft;
+
+import java.util.List;
+
+import net.minecraft.src.Item;
+import net.minecraft.src.ItemStack;
+import net.minecraft.src.NBTTagCompound;
+import net.minecraft.src.NBTTagList;
+
+public class ItemGrenade extends Item {
+
+       protected ItemGrenade(int par1) {
+               super(par1);
+       }
+
+       @Override
+       public void addInformation(ItemStack par1ItemStack, List par2List) {
+               NBTTagList var1 = par1ItemStack.getTagCompound().getTagList("Effect");
+
+               for(int i = 0;i < 3;i++){
+                       if(!((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i).equals("")){
+                               par2List.add(
+                                               ((NBTTagCompound)var1.tagAt(0)).getString("GrenadeEffect" + i)
+                                               );
+                       }
+               }
+       }
+
+       @Override
+       public String getTextureFile(){
+               return "/chemicraft/items/items.png";
+       }
+
+}
index 9eb7469..a458cd9 100644 (file)
@@ -4,6 +4,7 @@ import java.util.ArrayList;
 
 import net.minecraft.src.ItemStack;
 import net.minecraft.src.NBTTagCompound;
+import net.minecraft.src.NBTTagList;
 
 public class NBTRecipeGrenade extends NBTRecipe {
 
@@ -16,22 +17,31 @@ public class NBTRecipeGrenade extends NBTRecipe {
                        result.stackTagCompound = new NBTTagCompound();
                }
 
+               if (!result.stackTagCompound.hasKey("Effect"))
+               {
+                       result.stackTagCompound.setTag("Effect", new NBTTagList("Effect"));
+               }
+
+               NBTTagList tagList = (NBTTagList) result.getTagCompound().getTag("Effect");
+               NBTTagCompound tag = new NBTTagCompound();
+
                for(int i = 0;i < materials.length;i++){
                        if(materials[i] != null){
                                if(materials[i].itemID-256 == ChemiCraft.instance.atomsID && materials[i].getItemDamage() == ChemiCraft.HYDROGEN){
-                                       result.getTagCompound().setString("GrenadeEffect", "Hydrogen");
+                                       tag.setString("GrenadeEffect" + i, "Hydrogen");
                                        useItems[i] = materials[i];
                                }
                                if(materials[i].itemID-256 == ChemiCraft.instance.atomsID && materials[i].getItemDamage() == ChemiCraft.CARBON){
-                                       result.getTagCompound().setString("GrenadeEffect", "Carbon");
+                                       tag.setString("GrenadeEffect" + i, "Carbon");
                                        useItems[i] = materials[i];
                                }
                                if(materials[i].itemID-256 == ChemiCraft.instance.atomsID && materials[i].getItemDamage() == ChemiCraft.URANIUM){
-                                       result.getTagCompound().setString("GrenadeEffect", "Uranium");
+                                       tag.setString("GrenadeEffect" + i, "Uranium");
                                        useItems[i] = materials[i];
                                }
                        }
                }
+               tagList.appendTag(tag);
                return useItems;
        }