OSDN Git Service

鉱石追加用クラス・API等を追加or更新
authorponkotate <ponkotate@users.sourceforge.jp>
Sat, 16 Feb 2013 17:43:41 +0000 (02:43 +0900)
committerponkotate <ponkotate@users.sourceforge.jp>
Sat, 16 Feb 2013 17:43:41 +0000 (02:43 +0900)
・addAtomsOre()で任意の鉱石を追加。
・鉱石用テクスチャ追加(ホントは前からあったりしてw)。

common/pcc/chemicraft/ChemiCraft.java
common/pcc/chemicraft/ChemiCraftAPI.java
common/pcc/chemicraft/ore/BlockAtomsOre.java
common/pcc/chemicraft/ore/ItemAtomsOre.java [new file with mode: 0644]
common/pcc/chemicraft/util/ListHash.java [new file with mode: 0644]
common/pcc/chemicraft/util/MathHelperPlus.java [deleted file]

index b32dd60..0b99d76 100644 (file)
@@ -17,12 +17,12 @@ import pcc.chemicraft.compounds.CompoundWater;
 import pcc.chemicraft.debug.CommandDeleteItem;
 import pcc.chemicraft.debug.CommandGenDebugRoom;
 import pcc.chemicraft.debug.CommandSetTile;
-import pcc.chemicraft.gen.WorldGenAtomsOre;
 import pcc.chemicraft.item.ItemAtoms;
 import pcc.chemicraft.item.ItemAtomsGrenade;
 import pcc.chemicraft.item.ItemCompounds;
 import pcc.chemicraft.item.ItemGasCollectingBottle;
 import pcc.chemicraft.ore.BlockAtomsOre;
+import pcc.chemicraft.ore.ItemAtomsOre;
 import pcc.chemicraft.system.CommonProxy;
 import pcc.chemicraft.system.PacketHandler;
 import pcc.chemicraft.tileentity.TileEntityChemicalCombinationTable;
@@ -104,7 +104,7 @@ public class ChemiCraft {
        public int toolAndWeaponCraftingTableID;
        public int chemicalCraftingTableID;
 
-       public int atomsOreID;
+       public int[] atomsOreID = new int[1];
 
        /**
         * GUIID.
@@ -124,7 +124,7 @@ public class ChemiCraft {
        public Block blockToolAndWeaponCraftingTable;
        public Block blockChemicalCraftingTable;
 
-       public Block blockAtomsOre;
+       public Block[] blockAtomsOre = new Block[atomsOreID.length];
 
        /**
         * Item型変数.
@@ -141,7 +141,7 @@ public class ChemiCraft {
        public final String ITEM_COMPOUNDS_TEXTURE = "/pcc/chemicraft/items/Compounds.png";
        public final String ITEM_TEXTURE = "/pcc/chemicraft/items/items.png";
        public final String BLOCK_CHEMICAL_CRAFTING_TABLE_TEXTURE = "/pcc/chemicraft/blocks/cctable.png";
-       public final String BLOCK_ATOMS_ORE_TEXTURE = "/pcc/chemicraft/blocks/AtomsOres.png";
+       public final String BLOCK_ATOMS_ORE_TEXTURE = "/pcc/chemicraft/blocks/AtomsOre.png";
        public final String GUI_PYROLYSIS_TEXTURE = "/pcc/chemicraft/guis/Pyrolysis.png";
        public final String GUI_ELECTROLYSIS_TEXTURE = "/pcc/chemicraft/guis/Electrolysis.png";
        public final String GUI_CHEMICALCOMBINATION_TEXTURE = "/pcc/chemicraft/guis/ChemicalCombination.png";
@@ -169,7 +169,10 @@ public class ChemiCraft {
                Property toolAndWeaponCraftingTableIDProp = cfg.getBlock("ToolAndWeaponCraftingTableID", 2403);
                Property chemicalCraftingTableIDProp = cfg.getBlock("ChemicalCraftingTableID", 2404);
 
-               Property atomsOreIDProp = cfg.getBlock("AtomsOreID", 2500);
+               Property[] atomsOreIDProp = new Property[this.atomsOreID.length];
+               for (int i = 0; i < atomsOreIDProp.length; i++) {
+                       atomsOreIDProp[i] = cfg.getBlock("AtomsOreID:" + i, 2500 + i);
+               }
 
                Property atomsIDProp = cfg.getItem("AtomsID", 25000);
                Property compoundsIDProp = cfg.getItem("CompoundsID", 25001);
@@ -188,7 +191,9 @@ public class ChemiCraft {
                this.chemicalConbinationTableID = chemicalCombinationTableIDProp.getInt();
                this.toolAndWeaponCraftingTableID = toolAndWeaponCraftingTableIDProp.getInt();
                this.chemicalCraftingTableID = chemicalCraftingTableIDProp.getInt();
-               this.atomsOreID = atomsOreIDProp.getInt();
+               for (int i = 0; i < atomsOreID.length; i++) {
+                       this.atomsOreID[i] = atomsOreIDProp[i].getInt();
+               }
                this.atomsID = atomsIDProp.getInt();
                this.compoundsID = compoundsIDProp.getInt();
                this.gasCollectingBottleID = gasCollectingBottleIDProp.getInt();
@@ -245,6 +250,16 @@ public class ChemiCraft {
                                setStepSound(Block.soundStoneFootstep).
                                setBlockName("ChemicalCraftingTable");
 
+               for (int i = 0; i < blockAtomsOre.length; i++)
+               {
+                       this.blockAtomsOre[i] = new BlockAtomsOre(this.atomsOreID[i]).
+                                       setHardness(3.0F).
+                                       setResistance(0.0F).
+                                       setStepSound(Block.soundStoneFootstep).
+                                       setBlockName("AtomsOre" + i);
+                       GameRegistry.registerBlock(blockAtomsOre[i], ItemAtomsOre.class, "AtomsOre" + i);
+               }
+
                // Itemを追加します
                this.itemAtoms = new ItemAtoms(this.atomsID).setItemName("atoms");
                this.itemCompounds = new ItemCompounds(this.compoundsID).setItemName("compounds");
@@ -325,26 +340,16 @@ public class ChemiCraft {
                        Character.valueOf('A'), new ItemStack(this.itemAtoms, 1, 0),
                });
 
-               //鉱石の登録
-               for (int i = 0; i < api.getAtomsOreIDList().size(); i++) {
-                       this.blockAtomsOre = new BlockAtomsOre(api.getAtomsOreIDList().get(i)).
-                                       setHardness(3.0F).setResistance(5.0F).
-                                       setStepSound(Block.soundStoneFootstep).
-                                       setBlockName("AtomsOre" + "." + api.getAtomsOreIDList().get(i));
-                       GameRegistry.registerBlock(this.blockAtomsOre, "AtomsOre");
-               }
-
                //鉱石を追加します
-               api.addAtomsOre("Test", Block.blockDiamond.blockID, 0, 5, 5, 20); //テスト用
-
-               //鉱石の生成
-               for (int i = 0; i < api.getAtomsOreIDList().size(); i++) {
-                       GameRegistry.registerWorldGenerator(new WorldGenAtomsOre(api.getAtomsOreIDList().get(i), api.getAtomsOreMetaList().get(i), api.getAtomsOreSizeList().get(i), api.getAtomsOreFrequencyList().get(i), api.getAtomsOrePosYList().get(i)));
-               }
+               api.addAtomsOre("Petalite", this.atomsOreID[0], 0, 5, 5, 20); //ペタル石を追加
+               api.addAtomsOreLanguage("Petalite", "ペタル石", "ja_JP");
 
                //化合物を追加します
                api.addLangCompound("ja_JP", "ChlorousAcid", "亜塩素酸");
 
+               api.addLangCompound("ja_JP", "SodiumChloride", "塩化ナトリウム");
+               api.addLangCompound("ja_JP", "SodiumBicarbonate", "重曹");
+
                api.addLangCompound("ja_JP", "CarbonMonoxide", "一酸化炭素");
                api.addLangCompound("ja_JP", "CarbonDioxide", "二酸化炭素");
                api.addLangCompound("ja_JP", "Water", "水");
@@ -354,6 +359,7 @@ public class ChemiCraft {
                api.settingCompoundHandler("Water", new CompoundWater());
 
                //化合物のレシピを追加します
+               api.addChemicalCombinationRecipe(new String[]{"Na", "O", "H"}, new Integer[]{1, 1, 1}, new ItemStack(this.itemCompounds, 1, api.getCompound("SodiumChloride")));
                api.addChemicalCombinationRecipe(new String[]{"H", "O", "Cl"}, new Integer[]{1, 2, 1}, new ItemStack(this.itemCompounds, 1, api.getCompound("ChlorousAcid")));
 
                api.addChemicalCombinationRecipe(new String[]{"H", "O"}, new Integer[]{2, 1}, new ItemStack(this.itemCompounds, 1, api.getCompound("Water")));
@@ -391,6 +397,21 @@ public class ChemiCraft {
                for (int i = 0; i < api.getCompoundsLang().size(); i++) {
                        this.nameAuxiliary.addName(itemCompounds, api.getCompoundsLang().get(i), api.getCompoundsLangName().toArray());
                }
+
+               for (int i = 0; i < blockAtomsOre.length; i++)
+               {
+                       for (int j = 0; j < api.getAtomsOreNameListHash().sizeKeysList(); j++)
+                       {
+                               for (int k = 0; k < api.getAtomsOreNameListHash().sizeElementsList(api.getAtomsOreNameListHash().getKeyList(j)); k++)
+                               {
+                                       this.nameAuxiliary.addName(new ItemStack(blockAtomsOre[i], 0, j), api.getAtomsOreLangListHash().get(api.getAtomsOreNameListHash().getKeyList(j), k), api.getAtomsOreNameListHash().get(api.getAtomsOreNameListHash().getKeyList(j), k));
+                               }
+                       }
+               }
+               //鉱石の生成
+               for (int i = 0; i < api.getAtomsOreIDList().size(); i++) {
+                       GameRegistry.registerWorldGenerator(api.getAtomsOres().get(i));
+               }
        }
 
        private void debug(final FMLPostInitializationEvent event) {
index 84a25c6..ca4ed8b 100644 (file)
@@ -4,10 +4,12 @@ import java.util.ArrayList;
 import java.util.HashMap;
 
 import net.minecraft.item.ItemStack;
+import pcc.chemicraft.gen.WorldGenAtomsOre;
 import pcc.chemicraft.system.ChemiCraftCraftingManager;
 import pcc.chemicraft.tileentity.TileEntityPyrolysisTable;
 import pcc.chemicraft.util.ChemicalNBTRecipe;
 import pcc.chemicraft.util.ICompoundHandler;
+import pcc.chemicraft.util.ListHash;
 import pcc.chemicraft.util.MaterialRecipe;
 
 
@@ -95,7 +97,7 @@ public class ChemiCraftAPI {
        /**
         * 鉱石名リスト
         */
-       private ArrayList<String> atomsOreNameList = new ArrayList<String>();
+       private ListHash<String, String> atomsOreNameListHash = new ListHash<String, String>();
 
 
        /**
@@ -105,27 +107,15 @@ public class ChemiCraftAPI {
 
 
        /**
-        * é\89±ç\9f³ã\83¡ã\82¿ã\83\87ã\83¼ã\82¿リスト
+        * é\89±ç\9f³ã\81®è¨\80èª\9eリスト
         */
-       private ArrayList<Integer> atomsOreMetaList = new ArrayList<Integer>();
+       private ListHash<String, String> atomsOreLangListHash = new ListHash<String, String>();
 
 
        /**
-        * 鉱石リスト
+        * 鉱石リスト
         */
-       private ArrayList<Integer> atomsOreSizeList = new ArrayList<Integer>();
-
-
-       /**
-        * 鉱石頻度リスト
-        */
-       private ArrayList<Integer> atomsOreFrequencyList = new ArrayList<Integer>();
-
-
-       /**
-        * 鉱石Y座標リスト
-        */
-       private ArrayList<Integer> atomsOrePosYList = new ArrayList<Integer>();
+       private ArrayList<WorldGenAtomsOre> atomsOres = new ArrayList<WorldGenAtomsOre>();
 
 
 
@@ -293,21 +283,30 @@ public class ChemiCraftAPI {
         * @param frequency 生成頻度
         * @param posY Y座標
         */
-       public void addAtomsOre(String name, int id, int size, int frequency, int posY){
-               addAtomsOre(name, id, 0, size, frequency, posY);
+       public void addAtomsOre(String par1Name, int par2Id, int par3Size, int par4Frequency, int par5PosY){
+               addAtomsOre(par1Name, par2Id, 0, par3Size, par4Frequency, par5PosY);
        }
 
 
-       public void addAtomsOre(String name, int id, int meta, int size, int frequency, int posY){
-               atomsOreNameList.add(name);
-               atomsOreIDList.add(id);
-               atomsOreMetaList.add(meta);
-               atomsOreSizeList.add(size);
-               atomsOreFrequencyList.add(frequency);
-               atomsOrePosYList.add(posY);
+       public void addAtomsOre(String par1Name, int par2Id, int par3Meta, int par4Size, int par5Frequency, int par6PosY){
+               atomsOreNameListHash.add(par1Name, par1Name);
+               atomsOreIDList.add(par2Id);
+               atomsOreLangListHash.add(par1Name, "en_US");
+               atomsOres.add(new WorldGenAtomsOre(par2Id, par3Meta, par4Size, par5Frequency, par6PosY));
        }
 
 
+       /**
+        * 既に登録した鉱石の新しい名前・言語を追加します
+        * @param par1Name 英語名
+        * @param par2NewName 新しい名前
+        * @param par3Language 言語
+        */
+       public void addAtomsOreLanguage(String par1Name, String par2NewName, String par3Language){
+               atomsOreNameListHash.add(par1Name, par2NewName);
+               atomsOreLangListHash.add(par1Name, par3Language);
+       }
+
        
        //以下システム関連//////////////////////////////////////////////////////
 
@@ -395,8 +394,8 @@ public class ChemiCraftAPI {
 
 
 
-       public ArrayList<String> getAtomsOreNameList(){
-               return atomsOreNameList;
+       public ListHash<String, String> getAtomsOreNameListHash(){
+               return atomsOreNameListHash;
        }
 
 
@@ -407,26 +406,14 @@ public class ChemiCraftAPI {
 
 
 
-       public ArrayList<Integer> getAtomsOreMetaList(){
-               return atomsOreMetaList;
-       }
-
-
-
-       public ArrayList<Integer> getAtomsOreSizeList(){
-               return atomsOreSizeList;
-       }
-
-
-
-       public ArrayList<Integer> getAtomsOreFrequencyList(){
-               return atomsOreFrequencyList;
+       public ListHash<String, String> getAtomsOreLangListHash(){
+               return atomsOreLangListHash;
        }
 
 
 
-       public ArrayList<Integer> getAtomsOrePosYList(){
-               return atomsOrePosYList;
+       public ArrayList<WorldGenAtomsOre> getAtomsOres(){
+               return atomsOres;
        }
 
 
index a1ac1af..035be6d 100644 (file)
@@ -1,17 +1,14 @@
 package pcc.chemicraft.ore;
 
 import java.util.List;
-import java.util.Random;
 
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-
-import pcc.chemicraft.ChemiCraft;
 import net.minecraft.block.Block;
 import net.minecraft.block.material.Material;
 import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
+import pcc.chemicraft.ChemiCraft;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
 
 public class BlockAtomsOre extends Block
 {
@@ -25,7 +22,7 @@ public class BlockAtomsOre extends Block
        @Override
        public int getBlockTextureFromSideAndMetadata(int par1, int par2)
        {
-               return this.blockID * 16 + par2;
+               return (this.blockID - ChemiCraft.instance.atomsOreID[0]) * 16 + par2;
        }
 
        @Override
diff --git a/common/pcc/chemicraft/ore/ItemAtomsOre.java b/common/pcc/chemicraft/ore/ItemAtomsOre.java
new file mode 100644 (file)
index 0000000..6ddc4fa
--- /dev/null
@@ -0,0 +1,39 @@
+package pcc.chemicraft.ore;
+
+import pcc.chemicraft.ChemiCraft;
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemDye;
+import net.minecraft.item.ItemStack;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class ItemAtomsOre extends ItemBlock
+{
+
+       public ItemAtomsOre(int par1)
+       {
+               super(par1);
+               this.setMaxDamage(0);
+               this.setHasSubtypes(true);
+       }
+
+       @Override
+       @SideOnly(Side.CLIENT)
+       public int getIconFromDamage(int par1)
+       {
+               return ChemiCraft.instance.blockAtomsOre[0].getBlockTextureFromSideAndMetadata(2, BlockAtomsOre.getBlockFromDye(par1));
+       }
+
+       @Override
+       public int getMetadata(int par1)
+       {
+               return par1;
+       }
+
+       @Override
+       public String getItemNameIS(ItemStack par1ItemStack)
+       {
+               return super.getItemName() + "." + ItemDye.dyeColorNames[BlockAtomsOre.getBlockFromDye(par1ItemStack.getItemDamage())];
+       }
+}
diff --git a/common/pcc/chemicraft/util/ListHash.java b/common/pcc/chemicraft/util/ListHash.java
new file mode 100644 (file)
index 0000000..9040d1f
--- /dev/null
@@ -0,0 +1,203 @@
+package pcc.chemicraft.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+
+public class ListHash<K, E>
+{
+   /**
+    * @author Ponkotate version:1.0.0 dev
+    * 
+    *         Create ArrayList in HashMap.
+    */
+
+   protected ArrayList<K> keysList = new ArrayList<K>();
+   protected HashMap<K, ArrayList<E>> elementsHash = new HashMap<K, ArrayList<E>>();
+
+   public boolean add(K par1Key, E par2Element)
+   {
+      try
+      {
+         return this.elementsHash.get(par1Key).add(par2Element);
+      } catch (Exception e)
+      {
+         return this.put(par1Key, par2Element);
+      }
+   }
+
+   public boolean addAll(K par1Key, Collection<? extends E> par2Collection)
+   {
+      return this.elementsHash.get(par1Key).addAll(par2Collection);
+   }
+
+   public boolean addAll(K par1Key, int par2Index, Collection<? extends E> par3Collection)
+   {
+      return this.elementsHash.get(par1Key).addAll(par2Index, par3Collection);
+   }
+
+   public void clear()
+   {
+      this.elementsHash.clear();
+   }
+
+   public boolean containsKey(K par1Key)
+   {
+      return this.elementsHash.containsKey(par1Key);
+   }
+
+   public boolean containsValue(K par1Key)
+   {
+      return this.elementsHash.containsValue(par1Key);
+   }
+
+   public boolean contains(K par1Key, E par2Element)
+   {
+      return this.elementsHash.get(par1Key).contains(par2Element);
+   }
+
+   public boolean containsAll(K par1Key, Collection<?> par2Collection)
+   {
+      return this.elementsHash.get(par1Key).containsAll(par2Collection);
+   }
+
+   public Set<java.util.Map.Entry<K, E>> entrySet()
+   {
+      return this.entrySet();
+   }
+
+   public K getKeyList(int par1Index)
+   {
+      return this.keysList.get(par1Index);
+   }
+
+   public E get(K par1Key, int par2Index)
+   {
+      return this.elementsHash.get(par1Key).get(par2Index);
+   }
+
+   public int indexOf(K par1Key, E par2Element)
+   {
+      return this.elementsHash.get(par1Key).indexOf(par2Element);
+   }
+
+   public boolean isKeysListEmpty(K par1Key)
+   {
+      return this.elementsHash.get(par1Key).isEmpty();
+   }
+
+   public boolean isElementsHashEmpty()
+   {
+      return this.elementsHash.isEmpty();
+   }
+
+   public Iterator<E> iterator(K par1Key)
+   {
+      return this.elementsHash.get(par1Key).iterator();
+   }
+
+   public int lastIndexOf(K par1Key, E par2Element)
+   {
+      return this.elementsHash.get(par1Key).lastIndexOf(par2Element);
+   }
+
+   public ListIterator<E> listIterator(K par1Key)
+   {
+      return this.elementsHash.get(par1Key).listIterator();
+   }
+
+   public ListIterator<E> listIterator(K par1Key, int par2Index)
+   {
+      return this.elementsHash.get(par1Key).listIterator(par2Index);
+   }
+
+   public Set<K> keySet()
+   {
+      return this.elementsHash.keySet();
+   }
+
+   public boolean put(K par1Key, E par2Element)
+   {
+      this.keysList.add(par1Key);
+
+      ArrayList<E> elementList = new ArrayList<E>();
+      this.elementsHash.put(par1Key, elementList);
+      return this.add(par1Key, par2Element);
+   }
+
+   public void putAll(Map<? extends K, ? extends ArrayList<E>> par1Map)
+   {
+      this.elementsHash.putAll(par1Map);
+   }
+
+   public ArrayList<E> remove(K par1Key)
+   {
+      return this.elementsHash.remove(par1Key);
+   }
+
+   public boolean remove(K par1Key, E par2Element)
+   {
+      return this.elementsHash.get(par1Key).remove(par2Element);
+   }
+
+   public E remove(K par1Key, int par2Index)
+   {
+      return this.elementsHash.get(par1Key).remove(par2Index);
+   }
+
+   public boolean removeAll(K par1Key, Collection<?> par2Collection)
+   {
+      return this.elementsHash.get(par1Key).removeAll(par2Collection);
+   }
+
+   public boolean retainAll(K par1Key, Collection<?> par2Collection)
+   {
+      return this.elementsHash.get(par1Key).retainAll(par2Collection);
+   }
+
+   public E set(K par1Key, int par2Index, E par3Element)
+   {
+      return this.elementsHash.get(par1Key).set(par2Index, par3Element);
+   }
+
+   public int sizeElementsHash()
+   {
+      return this.elementsHash.size();
+   }
+
+   public int sizeKeysList()
+   {
+      return this.keysList.size();
+   }
+
+   public int sizeElementsList(K par1Key)
+   {
+      return this.elementsHash.get(par1Key).size();
+   }
+
+   public List<E> subList(K par1Key, int par2FromIndex, int par3ToIndex)
+   {
+      return this.elementsHash.get(par1Key).subList(par2FromIndex, par3ToIndex);
+   }
+
+   public E[] toArray(K par1Key)
+   {
+      return (E[])this.elementsHash.get(par1Key).toArray();
+   }
+
+   public <T> T[] toArray(K par1Key, T[] par2Array)
+   {
+      return this.elementsHash.get(par1Key).toArray(par2Array);
+   }
+
+   public Collection<ArrayList<E>> values()
+   {
+      return this.elementsHash.values();
+   }
+
+}
diff --git a/common/pcc/chemicraft/util/MathHelperPlus.java b/common/pcc/chemicraft/util/MathHelperPlus.java
deleted file mode 100644 (file)
index aaacea7..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-package pcc.chemicraft.util;
-
-import java.util.ArrayList;
-import java.util.Random;
-
-public class MathHelperPlus {
-
-       public static Random rand = new Random();
-
-       /**
-        * Return probability(0~).
-        */
-       public static int probability(double... par1) {
-               ArrayList<Double> var1 = new ArrayList<Double>();
-               for (int var2 = 0; var2 < par1.length; var2++) {
-                       var1.add(par1[var2]);
-               }
-               return probability(var1);
-       }
-
-       public static int probability(ArrayList<Double> par1) {
-               for (int i = 0; i < par1.size(); i++) {
-                       double var1 = par1.get(i) / 100;
-                       double var2 = Math.random();
-                       if (var1 <= var2) {
-                               return i;
-                       } else {
-                               continue;
-                       }
-               }
-               return -1;
-       }
-
-}