@Override public void run() { for (String s : imageURLs) { LogHelper.info("Checking Image: " + s); if (!checkExistence(s)) if (downloadImage(s)) reloadRequired = true; if (checkExistence(s)) { try { URL url = new URL(s); String fileName = url.getFile(); BufferedImage bi = ImageIO.read(new File(getImagesFolder(), fileName)); downloadedImages.put( s, new CustomResourceLocation( fileName.substring(fileName.indexOf("/") + 1), bi.getWidth(), bi.getHeight())); } catch (MalformedURLException e) { LogHelper.error("Image Read Failed"); e.printStackTrace(); } catch (IOException e) { LogHelper.error("Image Read Failed"); e.printStackTrace(); } } } isFinished = true; }
private static void addRSPack(boolean refreash) { File rspack = new File(getConfigFolder(), "/resources"); if (!rspack.exists()) return; if (!Arrays.asList(rspack.list()).contains("pack.mcmeta")) { try { JsonWriter writer = new JsonWriter(new FileWriter(new File(rspack, "pack.mcmeta"))); writer.beginObject(); writer.name("pack"); writer.beginObject(); writer.name("pack_format").value(1); writer.name("description").value("Draconic Evolution GUI Images"); writer.endObject(); writer.endObject(); writer.close(); } catch (IOException e) { LogHelper.error("Error creating pack.mcmeta"); e.printStackTrace(); } } Field f = ReflectionHelper.findField(Minecraft.class, "defaultResourcePacks", "field_110449_ao"); f.setAccessible(true); try { List defaultResourcePacks = (List) f.get(Minecraft.getMinecraft()); defaultResourcePacks.add(new FolderResourcePack(rspack)); f.set(Minecraft.getMinecraft(), defaultResourcePacks); LogHelper.info("RS Added"); if (refreash) Minecraft.getMinecraft().refreshResources(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
@SubscribeEvent public void tick(TickEvent.ClientTickEvent event) { if (downloadThread != null && downloadThread.isFinished) { if (downloadThread.isReloadRequired()) LogHelper.info("Image Download Finished"); downloadStatus = downloadThread.wasSuccessful ? 1 : 2; FMLCommonHandler.instance().bus().unregister(this); addRSPack(event != null); downloadThread = null; } }
public void init(FMLInitializationEvent event) { CraftingHandler.init(); registerGuiHandeler(); registerWorldGen(); registerEntities(); DETab.initialize(); PotionHandler.init(); CCOCIntegration.init(); ModHelper.init(); DragonChunkLoader.init(); LogHelper.info("Finished Initialization"); }
public void preInit(FMLPreInitializationEvent event) { ConfigHandler.init(event.getSuggestedConfigurationFile()); registerEventListeners(event.getSide()); ModBlocks.init(); ModItems.init(); ContributorHandler.init(); registerTileEntities(); initializeNetwork(); registerOres(); DraconicEvolution.reaperEnchant = new EnchantmentReaper(ConfigHandler.reaperEnchantID); // // Potion[] potionTypes = null; // LogHelper.info("Expanding Potion array size to 256"); // // for (Field f : Potion.class.getDeclaredFields()) { // f.setAccessible(true); // // try { // if (f.getName().equals("potionTypes") || f.getName().equals("field_76425_a")) { // Field modfield = Field.class.getDeclaredField("modifiers"); // modfield.setAccessible(true); // modfield.setInt(f, f.getModifiers() & ~Modifier.FINAL); // potionTypes = (Potion[]) f.get(null); // final Potion[] newPotionTypes = new Potion[256]; // System.arraycopy(potionTypes, 0, newPotionTypes, 0, potionTypes.length); // f.set(null, newPotionTypes); // } // } // catch (Exception e) { // LogHelper.error("Severe error, please report this to the mod author:"); // e.printStackTrace(); // } // } Achievements.addModAchievements(); LogHelper.info("Finished PreInitialization"); }
private static boolean downloadImage(String urlString) { try { URL url = new URL(urlString); String fileName = url.getFile(); LogHelper.info("Downloading Image " + fileName); File dll = new File(getImagesFolder(), fileName); InputStream is = url.openStream(); OutputStream os = new FileOutputStream(dll); ByteStreams.copy(is, os); is.close(); os.close(); } catch (IOException e) { LogHelper.error("Download Failed"); e.printStackTrace(); return false; } return true; }
public void postInit(FMLPostInitializationEvent event) { OreDoublingRegistry.init(); Achievements.registerAchievementPane(); LogHelper.info("Finished PostInitialization"); }