private static void extractSkin(String fileName) { InputStream input = null; FileOutputStream output = null; File outputFile = new File(SkinIOUtils.getSkinLibraryDirectory(), fileName + ".armour"); if (outputFile.exists()) { if (getFileSize(outputFile) > 0) { return; } else { ModLogger.log("Deleting corrupted skin file " + fileName); outputFile.delete(); } } try { ModLogger.log("Extracting file " + fileName); input = SkinExtractor.class .getClassLoader() .getResourceAsStream(SKINS_ASSETS_LOCATION + fileName + ".armour"); if (input != null) { output = new FileOutputStream(outputFile); while (input.available() > 0) { output.write(input.read()); } output.flush(); } else { ModLogger.log(Level.ERROR, "Error extracting skin " + fileName); } } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); } }
public boolean isSkinCompatibleVersion() { if (isModLoaded()) { ModContainer mc = Loader.instance().getIndexedModList().get(getModId()); if (mc != null) { String version = mc.getVersion(); String[] versionSplit = version.split("\\."); try { int majorVersion = Integer.parseInt(versionSplit[0]); if (majorVersion > 6) { ModLogger.log("BuildCraft robot skin support active."); return true; } else { ModLogger.log("BuildCraft is out of date. Unable to active robot skin support."); } } catch (Exception e) { return false; } } } return false; }
@Mod.EventHandler public void processIMC(FMLInterModComms.IMCEvent event) { for (IMCMessage imcMessage : event.getMessages()) { if (!imcMessage.isStringMessage()) continue; if (imcMessage.key.equalsIgnoreCase("register")) { ModLogger.log( String.format( "Receiving registration request from %s for class %s", imcMessage.getSender(), imcMessage.getStringValue())); ApiRegistrar.INSTANCE.addApiRequest(imcMessage.getSender(), imcMessage.getStringValue()); } } }
@Mod.EventHandler public void perInit(FMLPreInitializationEvent event) { ModLogger.log("Loading " + LibModInfo.NAME + " " + LibModInfo.VERSION); creativeTabArmorersWorkshop.setMinecraftCreativeTab(tabArmorersWorkshop); ConfigHandler.init(event.getSuggestedConfigurationFile()); Addons.preInit(); proxy.preInit(); SkinIOUtils.makeLibraryDirectory(); UpdateCheck.checkForUpdates(); SkinExtractor.extractSkins(); modItems = new ModItems(); modBlocks = new ModBlocks(); SkinTypeRegistry.init(); CubeRegistry.init(); proxy.initLibraryManager(); }