OSDN Git Service

処理をスレッド化した(ノリで
[chemicraft/chemicraft.git] / common / pcc / chemicraft / ChemiCraft.java
index b8f54cc..316aec7 100644 (file)
@@ -53,7 +53,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
  */
 @Mod(modid = "chemiCraft", name = "ChemiCraft", version = "beta")
 @NetworkMod(clientSideRequired = true, serverSideRequired = true, versionBounds = "1.4.6", channels = "chemicraft", packetHandler = PacketHandler.class)
-public class ChemiCraft {
+public class ChemiCraft implements Runnable {
 
        public static final String[] ATOMSNAME = {
                "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon",
@@ -166,6 +166,16 @@ public class ChemiCraft {
        private ChemiCraftAPI api = ChemiCraftAPI.instance();
        private ChemiCraftData chemicalData = new ChemiCraftData();
 
+       /**
+        * このMODのスレッド
+        */
+       private Thread thread;
+
+       /**
+        * Eventのインスタンス(PostInit以降)
+        */
+       private FMLPostInitializationEvent event;
+
        @Mod.PreInit
        public void chemiPreLoadMethod(final FMLPreInitializationEvent event) {
                Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
@@ -228,9 +238,28 @@ public class ChemiCraft {
 
        @Mod.PostInit
        public void chemiPostLoadMethod(final FMLPostInitializationEvent event) {
-               this.settingProcessing(event);
-               this.apiProcessing(event);
-               this.debug(event);
+               this.thread = new Thread(this);
+               this.event = event;
+               this.thread.start();
+               try {
+                       this.thread.join();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+               proxy.registerRenderInformation();
+               Thread.yield();
+       }
+
+       @Override
+       public void run() {
+               while (true) {
+                       if (proxy != null && instance != null) {
+                               this.settingProcessing(event);
+                               this.apiProcessing(event);
+                               this.debug(event);
+                               break;
+                       }
+               }
        }
 
        private void settingProcessing(final FMLPostInitializationEvent event) {
@@ -277,7 +306,7 @@ public class ChemiCraft {
                this.itemCompounds = new ItemCompounds(this.compoundsID).setItemName("compounds");
                this.itemGasCollectingBottle = new ItemGasCollectingBottle(this.gasCollectingBottleID).setItemName("gasCollectingBottle").setIconIndex(0);
                this.itemAtomGrenade = new ItemAtomsGrenade(this.atomGrenadeID).setItemName("grenade").setIconIndex(1);
-               this.itemChemicalCells = new ItemChemiCell(this.chemicalCellsID).setItemName("chemiCell");
+               this.itemChemicalCells = new ItemChemiCell(this.chemicalCellsID).setItemName("chemiCell").setIconIndex(3);
 
                // BlockをMinecraftに登録します
                GameRegistry.registerBlock(this.blockPyrolysisTable, "BlockPyrolysisTable");
@@ -316,9 +345,6 @@ public class ChemiCraft {
                // GUIを追加します
                NetworkRegistry.instance().registerGuiHandler(instance, proxy);
 
-               // 描画関係の読み込み
-               proxy.registerRenderInformation();
-
                //化学作業台類のレシピを追加します
                GameRegistry.addRecipe(new ItemStack(this.blockPyrolysisTable),
                                new Object[]{
@@ -366,10 +392,6 @@ public class ChemiCraft {
                api.addAtomOresLanguage("Spodumene", "リチア輝石", "ja_JP");
 
                // ベリリウム
-               api.addAtomsOre("Beryl", this.atomsOreID[api.getAtomsOreIndex()], 5, 20, 50); // Be3Al2Si6O18
-               api.addAtomsOreLanguage("Beryl", "緑柱石", "ja_JP");
-               api.addAtomsOre("Chrysoberyl", this.atomsOreID[api.getAtomsOreIndex()], 5, 200, 50); // BeAl2O4
-               api.addAtomsOreLanguage("Chrysoberyl", "金緑石", "ja_JP");
                api.addAtomOres("Beryl", new String[]{"Be", "Al", "Si", "O"}, new Integer[]{3, 2, 6, 18}, this.atomOresID[api.getAtomOresLastIndex()], 5, 1, 50); // Be3Al2Si6O18
                api.addAtomOresLanguage("Beryl", "緑柱石", "ja_JP");
                api.addAtomOres("Chrysoberyl", new String[]{"Be", "Al", "O"}, new Integer[]{1, 2, 4}, this.atomOresID[api.getAtomOresLastIndex()], 5, 1, 50); // BeAl2O4
@@ -442,6 +464,21 @@ public class ChemiCraft {
                this.api.addChemicalCombinationRecipe(new String[]{"H", "O", "Cl"}, new Integer[]{1, 2, 1}, new ItemStack(this.itemCompounds, 1, this.api.getCompound("ChlorousAcid")));
                this.api.addChemicalCombinationRecipe(new String[]{"H", "O"}, new Integer[]{2, 1}, new ItemStack(this.itemCompounds, 1, this.api.getCompound("Water")));
 
+               //化学電池の追加
+               this.api.addMaterialRecipe(new ItemStack[] {
+                               null,
+                               null,
+                               null,
+                               new ItemStack(this.itemAtoms, 1, ChemiCraftData.ZINC),
+                               null,
+                               new ItemStack(this.itemAtoms, 1, ChemiCraftData.COPPER),
+                               new ItemStack(Item.bucketWater),
+                               new ItemStack(Item.bucketWater),
+                               new ItemStack(Item.bucketWater),
+               },
+               new ItemStack(this.itemChemicalCells, 1, 0),
+               null);
+
                //手榴弾の追加
                this.api.addMaterialRecipe(new ItemStack[] {
                                null,
@@ -458,21 +495,21 @@ public class ChemiCraft {
                new NBTRecipeGrenade()
                                );
 
-               this.api.addDecompositionRecipe(new ItemStack(Item.potion, 1, 0),
+               this.api.addPyrolysisDecompositionRecipe(new ItemStack(Item.potion, 1, 0),
                                new Integer[] {ChemiCraftData.HYDROGEN, ChemiCraftData.OXYGEN},
                                new Integer[] {2, 1});
 
-               this.api.addDecompositionRecipe(new ItemStack(this.itemCompounds, 1, this.api.getCompound("Water")),
+               this.api.addPyrolysisDecompositionRecipe(new ItemStack(this.itemCompounds, 1, this.api.getCompound("Water")),
                                new Integer[] {ChemiCraftData.HYDROGEN, ChemiCraftData.OXYGEN},
                                new Integer[] {2, 1});
 
                for (int i = 0; i < api.getAtomOresName().sizeKeysList(); i++){
-                       this.api.addDecompositionRecipe(new ItemStack(this.blockAtomOres[i / 16], 1, i - i / 16 * 16),
+                       this.api.addPyrolysisDecompositionRecipe(new ItemStack(this.blockAtomOres[i / 16], 1, i - i / 16 * 16),
                                        api.getAtomOresAtoms().get(api.getAtomOresName().getKeyList(i)),
                                        api.getAtomOresAmounts().get(api.getAtomOresName().getKeyList(i)));
                }
 
-               this.api.addDecompositionFuel(new ItemStack(Item.coal), 2000*8);
+               this.api.addPyrolysisDecompositionFuel(new ItemStack(Item.coal), 2000*8);
        }
 
        private void apiProcessing(final FMLPostInitializationEvent event) {
@@ -510,14 +547,10 @@ public class ChemiCraft {
        }
 
        private void debug(final FMLPostInitializationEvent event) {
-               //DebugTickingの追加
                this.proxy.registerTickHandler();
                this.api.addCompound("Debug");
                this.api.settingCompoundHandler("Debug", new CompoundDebug());
 
-               /*
-                * TWDebug
-                */
                this.api.addToolAndWeaponRecipe(new ItemStack[] {
                                new ItemStack(Block.stone, 1, 1)
                },