2013-12-20 19:17:26 +05:30
|
|
|
#include "OneSixFTBInstance.h"
|
|
|
|
|
2014-05-19 05:52:09 +05:30
|
|
|
#include "logic/minecraft/InstanceVersion.h"
|
2014-05-09 00:50:10 +05:30
|
|
|
#include "logic/minecraft/OneSixLibrary.h"
|
2014-05-09 20:46:25 +05:30
|
|
|
#include "logic/minecraft/VersionBuilder.h"
|
2013-12-20 19:17:26 +05:30
|
|
|
#include "tasks/SequentialTask.h"
|
2014-04-23 05:57:40 +05:30
|
|
|
#include "forge/ForgeInstaller.h"
|
|
|
|
#include "forge/ForgeVersionList.h"
|
2014-02-21 22:31:06 +05:30
|
|
|
#include "OneSixInstance_p.h"
|
2013-12-20 19:17:26 +05:30
|
|
|
#include "MultiMC.h"
|
2014-02-21 23:45:59 +05:30
|
|
|
#include "pathutils.h"
|
2013-12-20 19:17:26 +05:30
|
|
|
|
|
|
|
OneSixFTBInstance::OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) :
|
|
|
|
OneSixInstance(rootDir, settings, parent)
|
|
|
|
{
|
2014-02-21 22:31:06 +05:30
|
|
|
}
|
|
|
|
|
2014-02-21 23:45:59 +05:30
|
|
|
void OneSixFTBInstance::copy(const QDir &newDir)
|
|
|
|
{
|
|
|
|
QStringList libraryNames;
|
|
|
|
// create patch file
|
|
|
|
{
|
|
|
|
QLOG_DEBUG() << "Creating patch file for FTB instance...";
|
|
|
|
QFile f(minecraftRoot() + "/pack.json");
|
|
|
|
if (!f.open(QFile::ReadOnly))
|
|
|
|
{
|
|
|
|
QLOG_ERROR() << "Couldn't open" << f.fileName() << ":" << f.errorString();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QJsonObject root = QJsonDocument::fromJson(f.readAll()).object();
|
|
|
|
QJsonArray libs = root.value("libraries").toArray();
|
|
|
|
QJsonArray outLibs;
|
|
|
|
for (auto lib : libs)
|
|
|
|
{
|
|
|
|
QJsonObject libObj = lib.toObject();
|
|
|
|
libObj.insert("MMC-hint", QString("local"));
|
|
|
|
libObj.insert("insert", QString("prepend"));
|
|
|
|
libraryNames.append(libObj.value("name").toString());
|
|
|
|
outLibs.append(libObj);
|
|
|
|
}
|
|
|
|
root.remove("libraries");
|
|
|
|
root.remove("id");
|
2014-11-18 02:15:29 +05:30
|
|
|
|
|
|
|
// HACK HACK HACK HACK
|
|
|
|
// A workaround for a problem in MultiMC, triggered by a historical problem in FTB,
|
|
|
|
// triggered by Mojang getting their library versions wrong in 1.7.10
|
|
|
|
if(intendedVersionId() == "1.7.10")
|
|
|
|
{
|
|
|
|
auto insert = [&outLibs, &libraryNames](QString name)
|
|
|
|
{
|
|
|
|
QJsonObject libObj;
|
|
|
|
libObj.insert("insert", QString("replace"));
|
|
|
|
libObj.insert("name", name);
|
|
|
|
libraryNames.push_back(name);
|
|
|
|
outLibs.prepend(libObj);
|
|
|
|
};
|
|
|
|
insert("com.google.guava:guava:16.0");
|
|
|
|
insert("org.apache.commons:commons-lang3:3.2.1");
|
|
|
|
}
|
2014-02-21 23:45:59 +05:30
|
|
|
root.insert("+libraries", outLibs);
|
|
|
|
root.insert("order", 1);
|
|
|
|
root.insert("fileId", QString("org.multimc.ftb.pack.json"));
|
|
|
|
root.insert("name", name());
|
|
|
|
root.insert("mcVersion", intendedVersionId());
|
|
|
|
root.insert("version", intendedVersionId());
|
|
|
|
ensureFilePathExists(newDir.absoluteFilePath("patches/ftb.json"));
|
|
|
|
QFile out(newDir.absoluteFilePath("patches/ftb.json"));
|
|
|
|
if (!out.open(QFile::WriteOnly | QFile::Truncate))
|
|
|
|
{
|
|
|
|
QLOG_ERROR() << "Couldn't open" << out.fileName() << ":" << out.errorString();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
out.write(QJsonDocument(root).toJson());
|
|
|
|
}
|
|
|
|
// copy libraries
|
|
|
|
{
|
|
|
|
QLOG_DEBUG() << "Copying FTB libraries";
|
|
|
|
for (auto library : libraryNames)
|
|
|
|
{
|
|
|
|
OneSixLibrary *lib = new OneSixLibrary(library);
|
|
|
|
const QString out = QDir::current().absoluteFilePath("libraries/" + lib->storagePath());
|
|
|
|
if (QFile::exists(out))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!ensureFilePathExists(out))
|
|
|
|
{
|
|
|
|
QLOG_ERROR() << "Couldn't create folder structure for" << out;
|
|
|
|
}
|
|
|
|
if (!QFile::copy(librariesPath().absoluteFilePath(lib->storagePath()), out))
|
|
|
|
{
|
|
|
|
QLOG_ERROR() << "Couldn't copy" << lib->rawName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-16 03:19:37 +05:30
|
|
|
QString OneSixFTBInstance::id() const
|
|
|
|
{
|
|
|
|
return "FTB/" + BaseInstance::id();
|
|
|
|
}
|
|
|
|
|
2014-02-20 21:36:32 +05:30
|
|
|
QDir OneSixFTBInstance::librariesPath() const
|
|
|
|
{
|
|
|
|
return QDir(MMC->settings()->get("FTBRoot").toString() + "/libraries");
|
|
|
|
}
|
2014-05-08 22:35:07 +05:30
|
|
|
|
2014-02-20 21:36:32 +05:30
|
|
|
QDir OneSixFTBInstance::versionsPath() const
|
|
|
|
{
|
|
|
|
return QDir(MMC->settings()->get("FTBRoot").toString() + "/versions");
|
|
|
|
}
|
|
|
|
|
2014-02-21 22:31:06 +05:30
|
|
|
QStringList OneSixFTBInstance::externalPatches() const
|
|
|
|
{
|
|
|
|
return QStringList() << versionsPath().absoluteFilePath(intendedVersionId() + "/" + intendedVersionId() + ".json")
|
|
|
|
<< minecraftRoot() + "/pack.json";
|
|
|
|
}
|
|
|
|
|
2014-02-21 23:45:59 +05:30
|
|
|
bool OneSixFTBInstance::providesVersionFile() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-20 19:17:26 +05:30
|
|
|
QString OneSixFTBInstance::getStatusbarDescription()
|
|
|
|
{
|
2014-09-06 21:46:56 +05:30
|
|
|
if (flags() & VersionBrokenFlag)
|
2014-02-18 01:01:50 +05:30
|
|
|
{
|
|
|
|
return "OneSix FTB: " + intendedVersionId() + " (broken)";
|
|
|
|
}
|
2013-12-20 19:17:26 +05:30
|
|
|
return "OneSix FTB: " + intendedVersionId();
|
|
|
|
}
|
|
|
|
|
2014-01-27 07:30:49 +05:30
|
|
|
std::shared_ptr<Task> OneSixFTBInstance::doUpdate()
|
2013-12-20 19:17:26 +05:30
|
|
|
{
|
2014-02-21 22:31:06 +05:30
|
|
|
return OneSixInstance::doUpdate();
|
2013-12-20 19:17:26 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
#include "OneSixFTBInstance.moc"
|