Revisión | f765184d4cff2134701a2d48b5c530151c3b1a21 (tree) |
---|---|
Tiempo | 2013-03-04 20:30:18 |
Autor | mozipi <mozipi@user...> |
Commiter | mozipi |
処理をスレッド化した(ノリで
@@ -53,7 +53,7 @@ import cpw.mods.fml.common.registry.GameRegistry; | ||
53 | 53 | */ |
54 | 54 | @Mod(modid = "chemiCraft", name = "ChemiCraft", version = "beta") |
55 | 55 | @NetworkMod(clientSideRequired = true, serverSideRequired = true, versionBounds = "1.4.6", channels = "chemicraft", packetHandler = PacketHandler.class) |
56 | -public class ChemiCraft { | |
56 | +public class ChemiCraft implements Runnable { | |
57 | 57 | |
58 | 58 | public static final String[] ATOMSNAME = { |
59 | 59 | "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", |
@@ -166,6 +166,16 @@ public class ChemiCraft { | ||
166 | 166 | private ChemiCraftAPI api = ChemiCraftAPI.instance(); |
167 | 167 | private ChemiCraftData chemicalData = new ChemiCraftData(); |
168 | 168 | |
169 | + /** | |
170 | + * このMODのスレッド | |
171 | + */ | |
172 | + private Thread thread; | |
173 | + | |
174 | + /** | |
175 | + * Eventのインスタンス(PostInit以降) | |
176 | + */ | |
177 | + private FMLPostInitializationEvent event; | |
178 | + | |
169 | 179 | @Mod.PreInit |
170 | 180 | public void chemiPreLoadMethod(final FMLPreInitializationEvent event) { |
171 | 181 | Configuration cfg = new Configuration(event.getSuggestedConfigurationFile()); |
@@ -228,9 +238,28 @@ public class ChemiCraft { | ||
228 | 238 | |
229 | 239 | @Mod.PostInit |
230 | 240 | public void chemiPostLoadMethod(final FMLPostInitializationEvent event) { |
231 | - this.settingProcessing(event); | |
232 | - this.apiProcessing(event); | |
233 | - this.debug(event); | |
241 | + this.thread = new Thread(this); | |
242 | + this.event = event; | |
243 | + this.thread.start(); | |
244 | + try { | |
245 | + this.thread.join(); | |
246 | + } catch (InterruptedException e) { | |
247 | + e.printStackTrace(); | |
248 | + } | |
249 | + proxy.registerRenderInformation(); | |
250 | + Thread.yield(); | |
251 | + } | |
252 | + | |
253 | + @Override | |
254 | + public void run() { | |
255 | + while (true) { | |
256 | + if (proxy != null && instance != null) { | |
257 | + this.settingProcessing(event); | |
258 | + this.apiProcessing(event); | |
259 | + this.debug(event); | |
260 | + break; | |
261 | + } | |
262 | + } | |
234 | 263 | } |
235 | 264 | |
236 | 265 | private void settingProcessing(final FMLPostInitializationEvent event) { |
@@ -316,9 +345,6 @@ public class ChemiCraft { | ||
316 | 345 | // GUIを追加します |
317 | 346 | NetworkRegistry.instance().registerGuiHandler(instance, proxy); |
318 | 347 | |
319 | - // 描画関係の読み込み | |
320 | - proxy.registerRenderInformation(); | |
321 | - | |
322 | 348 | //化学作業台類のレシピを追加します |
323 | 349 | GameRegistry.addRecipe(new ItemStack(this.blockPyrolysisTable), |
324 | 350 | new Object[]{ |
@@ -449,8 +475,8 @@ public class ChemiCraft { | ||
449 | 475 | new ItemStack(Item.bucketWater), |
450 | 476 | new ItemStack(Item.bucketWater), |
451 | 477 | new ItemStack(Item.bucketWater), |
452 | - }, | |
453 | - new ItemStack(this.itemChemicalCells, 1, 0), | |
478 | + }, | |
479 | + new ItemStack(this.itemChemicalCells, 1, 0), | |
454 | 480 | null); |
455 | 481 | |
456 | 482 | //手榴弾の追加 |
@@ -521,14 +547,10 @@ public class ChemiCraft { | ||
521 | 547 | } |
522 | 548 | |
523 | 549 | private void debug(final FMLPostInitializationEvent event) { |
524 | - //DebugTickingの追加 | |
525 | 550 | this.proxy.registerTickHandler(); |
526 | 551 | this.api.addCompound("Debug"); |
527 | 552 | this.api.settingCompoundHandler("Debug", new CompoundDebug()); |
528 | 553 | |
529 | - /* | |
530 | - * TWDebug | |
531 | - */ | |
532 | 554 | this.api.addToolAndWeaponRecipe(new ItemStack[] { |
533 | 555 | new ItemStack(Block.stone, 1, 1) |
534 | 556 | }, |