extractLegacyJson(new File(gameDir, "pack.json"));
}
}
if (new File(gameDir, "pack.json").exists()) {
Version packjson = JsonFactory.loadVersion(new File(gameDir, "pack.json"));
if (packjson.jar != null && !packjson.jar.isEmpty()) {
packmcversion = packjson.jar;
}
if (packjson.inheritsFrom != null && !packjson.inheritsFrom.isEmpty()) {
packbasejson = packjson.inheritsFrom;
}
Library.Artifact a;
for (Library lib : packjson.getLibraries()) {
//Logger.logError(new File(libDir, lib.getPath()).getAbsolutePath());
// These files are shipped inside pack.zip, can't do force update check yet
local = new File(root, "libraries/" + lib.getPath());
if (!new File(libDir, lib.getPath()).exists() || forceUpdate) {
if (lib.checksums != null) {
list.add(new DownloadInfo(new URL(lib.getUrl() + lib.getPath()), local, lib.getPath(), lib.checksums, "sha1",
DownloadInfo.DLType.NONE, DownloadInfo.DLType.NONE));
} else if (lib.download != null && lib.download) {
list.add(new DownloadInfo(new URL(lib.getUrl() + lib.getPath()), local, lib.getPath()));
}
}
a = lib.get_artifact();
if (a.getDomain().equalsIgnoreCase("net.minecraftforge") && (a.getName().equalsIgnoreCase("forge") || a.getName().equalsIgnoreCase("minecraftforge"))) {
grabJava8CompatFix(a, pack, packmcversion, installDir + "/" + pack.getDir());
}
}
//}
} else {
if (!pack.getDir().equals("mojang_vanilla")) {
Logger.logError("pack.json file not found-Forge/Liteloader will not be able to load!");
} else {
Logger.logInfo("pack.json not found in vanilla pack(this is expected)");
}
//TODO handle vanilla packs w/ tweakers w/ this stuffs !!!
}
/*
* <ftb installation location>/libraries/*
*/
//check if our copy exists of the version json if not backup to mojang's copy
Logger.logDebug("Checking minecraft version json");
if (packbasejson == null || packbasejson.isEmpty()) {
packbasejson = packmcversion;
}
URL url = new URL(DownloadUtils.getStaticCreeperhostLinkOrBackup("mcjsons/versions/{MC_VER}/{MC_VER}.json".replace("{MC_VER}", packbasejson), Locations.mc_dl
+ "versions/{MC_VER}/{MC_VER}.json".replace("{MC_VER}", packbasejson)));
File json = new File(root, "versions/{MC_VER}/{MC_VER}.json".replace("{MC_VER}", packbasejson));
DownloadUtils.downloadToFile(url, json, 3);
if (!json.exists()) {
Logger.logError("library JSON not found");
return null;
}
Version version = JsonFactory.loadVersion(json);
Logger.logDebug("checking minecraft libraries");
for (Library lib : version.getLibraries()) {
if (lib.natives == null) {
local = new File(root, "libraries/" + lib.getPath());
if (!local.exists() || forceUpdate) {
if (!lib.getUrl().toLowerCase().equalsIgnoreCase(Locations.ftb_maven)) {//DL's shouldn't be coming from maven repos but ours or mojang's
list.add(new DownloadInfo(new URL(lib.getUrl() + lib.getPath()), local, lib.getPath()));
} else {
list.add(new DownloadInfo(new URL(DownloadUtils.getCreeperhostLink(lib.getUrl() + lib.getPath())), local, lib.getPath(), true));
}
}
} else {
local = new File(root, "libraries/" + lib.getPathNatives());
if (!local.exists() || forceUpdate) {
list.add(new DownloadInfo(new URL(lib.getUrl() + lib.getPathNatives()), local, lib.getPathNatives()));
}
}
}
/*
* vanilla minecraft.jar
*/
local = new File(root, "versions/{MC_VER}/{MC_VER}.jar".replace("{MC_VER}", packmcversion));
if (!local.exists() || forceUpdate) {
list.add(new DownloadInfo(new URL(Locations.mc_dl + "versions/{MC_VER}/{MC_VER}.jar".replace("{MC_VER}", packmcversion)), local, local.getName()));
}
// Move the old format to the new:
File test = new File(root, "assets/READ_ME_I_AM_VERY_IMPORTANT.txt");
if (test.exists()) {
Logger.logDebug("Moving old format");
File assets = new File(root, "assets");
Set<File> old = FTBFileUtils.listFiles(assets);
File objects = new File(assets, "objects");
String[] skip = new String[] { objects.getAbsolutePath(), new File(assets, "indexes").getAbsolutePath(), new File(assets, "virtual").getAbsolutePath() };
for (File f : old) {
String path = f.getAbsolutePath();
boolean move = true;
for (String prefix : skip) {
if (path.startsWith(prefix)) {
move = false;
}
}
if (move) {
String hash = DownloadUtils.fileSHA(f);
File cache = new File(objects, hash.substring(0, 2) + "/" + hash);
Logger.logInfo("Caching Asset: " + hash + " - " + f.getAbsolutePath().replace(assets.getAbsolutePath(), ""));
if (!cache.exists()) {
cache.getParentFile().mkdirs();
f.renameTo(cache);
}
f.delete();
}
}
List<File> dirs = FTBFileUtils.listDirs(assets);
for (File dir : dirs) {
if (dir.listFiles().length == 0) {
dir.delete();
}
}
}
/*
* assets/*
*/
Logger.logDebug("Checking minecraft assets");
url = new URL(Locations.mc_dl + "indexes/{INDEX}.json".replace("{INDEX}", version.getAssets()));
json = new File(root, "assets/indexes/{INDEX}.json".replace("{INDEX}", version.getAssets()));
DownloadUtils.downloadToFile(url, json, 3);
if (!json.exists()) {
Logger.logError("asset JSON not found");
return null;