OSDN Git Service

コミットしてといわれたのでコミット
authormozipi <mozipi@users.sourceforge.jp>
Thu, 3 Jan 2013 14:55:32 +0000 (23:55 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Thu, 3 Jan 2013 14:55:32 +0000 (23:55 +0900)
common/chemicraft/ChemiCraft.java
common/chemicraft/ChemiCraftAPI.java
common/chemicraft/system/ChemiCraftCraftingManager.java
common/chemicraft/tileentity/TileEntityChemicalCombinationTable.java
common/chemicraft/util/ComparatorFormulaPart.java [moved from common/chemicraft/util/CompaeatorFormulaPart.java with 79% similarity]

index 94ad8f5..2e91817 100644 (file)
@@ -299,18 +299,17 @@ public class ChemiCraft {
                });\r
 \r
                // 化合物を追加します\r
+               api.addLangCompound("ja_JP", "CarbonMonoxide", "一酸化炭素");\r
                api.addLangCompound("ja_JP", "CarbonDioxide", "二酸化炭素");\r
-               api.addLangCompound("ja_JP", "Water", "水");
-               ChemiCraftAPI.getInstance().addLangCompound("ja_JP", "CarbonMonoxide", "一酸化炭素");\r
-               ChemiCraftAPI.getInstance().addLangCompound("ja_JP", "CarbonDioxide", "二酸化炭素");\r
-               ChemiCraftAPI.getInstance().addLangCompound("ja_JP", "Water", "水");\r
+               api.addLangCompound("ja_JP", "Water", "水");\r
+               api.addCompound("Test");\r
 
 \r
                //化合物のHandlerを設定します\r
                api.settingCompoundHandler("Water", new CompoundWater());\r
 \r
                //化合物のレシピを追加します\r
-               api.addChemicalCombinationRecipe(new String[]{"H", "O"}, new Integer[]{2, 1}, new ItemStack(this.itemCompounds, 1, 1));\r
+               api.addChemicalCombinationRecipe(new String[]{"H", "O"}, new Integer[]{2, 1}, new ItemStack(this.itemCompounds, 1, api.getCompound("Water")));\r
 \r
                //手榴弾の追加\r
                api.addMaterialRecipe(\r
@@ -332,9 +331,10 @@ public class ChemiCraft {
 \r
        private void apiProcessing(final FMLPostInitializationEvent event) {\r
                // API用の処理\r
-               this.nameAuxiliary.addName(itemCompounds, ChemiCraftAPI.getInstance().getCompoundsName().toArray());\r
-               this.nameAuxiliary.addName(itemCompounds, "ja_JP", ChemiCraftAPI.getInstance().getCompoundsLangName().toArray());\r
-               ChemiCraftAPI.getInstance().addCompoundHash(ChemiCraftAPI.getInstance().getCompoundsName().toArray());\r
+               this.nameAuxiliary.addName(itemCompounds, api.getInstance().getCompoundsName().toArray());\r
+               for (int i = 0; i < api.getCompoundsLangName().size(); i++) {\r
+                       this.nameAuxiliary.addName(itemCompounds, api.getCompoundsLangName().get(i), api.getInstance().getCompoundsLangName().toArray());\r
+               }\r
        }\r
 \r
        private void debug(final FMLPostInitializationEvent event) {\r
index ca54c3e..89019e1 100644 (file)
@@ -107,9 +107,7 @@ public class ChemiCraftAPI {
         * @param name compound name.
         */
        public void addCompound(String name){
-               compoundsNameList.add(name);
-               compoundsLangNameList.add("");
-               compoundsLangList.add("");
+               addLangCompound("", name, "");
        }
 
 
@@ -124,33 +122,7 @@ public class ChemiCraftAPI {
                compoundsNameList.add(englishName);
                compoundsLangNameList.add(langName);
                compoundsLangList.add(lang);
-       }
-
-
-
-       public int getDamageByName(String englishName){
-               for(int i = 0;i < compoundsNameList.size();i++){
-                       if(englishName.equals(compoundsNameList.get(i))){
-                               return i;
-                       }
-               }
-               return -1;
-       }
-
-
-
-       public void addCompoundHash(String key, int value){
-               compoundHash.put(key, value);
-       }
-
-
-
-       public void addCompoundHash(Object[] object){
-               for(int i = 0;i < compoundsNameList.size();i++){
-                       if(object[i].equals(compoundsNameList.get(i))){
-                               compoundHash.put((String) object[i], i);
-                       }
-               }
+               compoundHash.put(englishName, compoundHash.size());
        }
 
 
index 5af5155..05bc895 100644 (file)
@@ -1,6 +1,7 @@
 package chemicraft.system;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 
 import net.minecraft.src.IInventory;
 import net.minecraft.src.ItemStack;
@@ -9,6 +10,7 @@ import chemicraft.inventory.InventoryChemicalCraftingMaterial;
 import chemicraft.inventory.InventoryChemicalCraftingNBT;
 import chemicraft.inventory.InventoryChemicalCraftingResult;
 import chemicraft.util.ChemicalNBTRecipe;
+import chemicraft.util.ComparatorFormulaPart;
 import chemicraft.util.FormulaPart;
 
 public class ChemiCraftCraftingManager {
@@ -31,6 +33,8 @@ public class ChemiCraftCraftingManager {
                                for (int j = 0; j < api.getChemicalCombinationAtoms().get(i).length; j++) {
                                        var2[j] = new FormulaPart(api.getChemicalCombinationAtoms().get(i)[j], api.getChemicalCombinationAmounts().get(i)[j]);
                                }
+                               Arrays.sort(var1, new ComparatorFormulaPart());
+                               Arrays.sort(var2, new ComparatorFormulaPart());
                                if (var1.length != var2.length) {
                                        continue recipeSize;
                                }
index ab84c7c..8322eb4 100644 (file)
@@ -44,13 +44,6 @@ public class TileEntityChemicalCombinationTable extends TileEntity {
                        this.isProvidePower = false;
                        PacketDispatcher.sendPacketToAllPlayers(this.getDescriptionPacket());
                }
-               if (this.worldObj instanceof WorldServer) {
-                       System.out.println(this.atomsList + ":Server");
-                       System.out.println(this.atomsAmountList + ":Server");
-               } else {
-                       System.out.println(this.atomsList + ":Client");
-                       System.out.println(this.atomsAmountList + ":Client");
-               }
        }
 
        @Override
@@ -3,14 +3,14 @@ package chemicraft.util;
 import java.util.Arrays;
 import java.util.Comparator;
 
-public class CompaeatorFormulaPart implements Comparator<FormulaPart> {
+public class ComparatorFormulaPart implements Comparator<FormulaPart> {
 
        @Override
        public int compare(FormulaPart o1, FormulaPart o2) {
                int i = 0;
                byte[] var1Byte = o1.getAtom().getBytes();
                byte[] var2Byte = o2.getAtom().getBytes();
-               while (var1Byte.length < i && var2Byte.length < i) {
+               while (var1Byte.length > i && var2Byte.length > i) {
                        if (var1Byte[i] == var2Byte[i]) {
                                i++;
                                continue;