summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--logic/BaseInstance.h2
-rw-r--r--logic/InstanceFactory.cpp2
-rw-r--r--logic/OneSixFTBInstance.cpp71
-rw-r--r--logic/OneSixFTBInstance.h2
-rw-r--r--logic/OneSixInstance.cpp5
-rw-r--r--logic/OneSixInstance.h1
-rw-r--r--logic/OneSixUpdate.cpp7
-rw-r--r--logic/OneSixUpdate.h6
-rw-r--r--logic/OneSixVersion.cpp1
9 files changed, 92 insertions, 5 deletions
diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h
index d4007a41..341a6adb 100644
--- a/logic/BaseInstance.h
+++ b/logic/BaseInstance.h
@@ -25,6 +25,7 @@
#include "logic/auth/MojangAccount.h"
class QDialog;
+class QDir;
class Task;
class MinecraftProcess;
class OneSixUpdate;
@@ -52,6 +53,7 @@ public:
virtual ~BaseInstance() {};
virtual void init() {}
+ virtual void copy(const QDir &newDir) {}
/// nuke thoroughly - deletes the instance contents, notifies the list/model which is
/// responsible of cleaning up the husk
diff --git a/logic/InstanceFactory.cpp b/logic/InstanceFactory.cpp
index 2c89bf43..d6e06133 100644
--- a/logic/InstanceFactory.cpp
+++ b/logic/InstanceFactory.cpp
@@ -184,6 +184,8 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
if(inst_type == "LegacyFTB")
m_settings->set("InstanceType", "Legacy");
+ oldInstance->copy(instDir);
+
auto error = loadInstance(newInstance, instDir);
switch (error)
diff --git a/logic/OneSixFTBInstance.cpp b/logic/OneSixFTBInstance.cpp
index 4bd30b1d..307ddb7c 100644
--- a/logic/OneSixFTBInstance.cpp
+++ b/logic/OneSixFTBInstance.cpp
@@ -6,7 +6,9 @@
#include "ForgeInstaller.h"
#include "lists/ForgeVersionList.h"
#include "OneSixInstance_p.h"
+#include "OneSixVersionBuilder.h"
#include "MultiMC.h"
+#include "pathutils.h"
class OneSixFTBInstanceForge : public Task
{
@@ -88,6 +90,70 @@ void OneSixFTBInstance::init()
reloadVersion();
}
+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");
+ 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);
+ lib->finalize();
+ 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();
+ }
+ }
+ }
+}
+
QString OneSixFTBInstance::id() const
{
return "FTB/" + BaseInstance::id();
@@ -109,6 +175,11 @@ QStringList OneSixFTBInstance::externalPatches() const
<< minecraftRoot() + "/pack.json";
}
+bool OneSixFTBInstance::providesVersionFile() const
+{
+ return true;
+}
+
QString OneSixFTBInstance::getStatusbarDescription()
{
return "OneSix FTB: " + intendedVersionId();
diff --git a/logic/OneSixFTBInstance.h b/logic/OneSixFTBInstance.h
index bcf3df8f..c4f845e0 100644
--- a/logic/OneSixFTBInstance.h
+++ b/logic/OneSixFTBInstance.h
@@ -12,6 +12,7 @@ public:
QObject *parent = 0);
void init() override;
+ void copy(const QDir &newDir) override;
virtual QString getStatusbarDescription();
virtual bool menuActionEnabled(QString action_name) const;
@@ -23,6 +24,7 @@ public:
QDir librariesPath() const override;
QDir versionsPath() const override;
QStringList externalPatches() const override;
+ bool providesVersionFile() const override;
private:
std::shared_ptr<OneSixLibrary> m_forge;
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index f7e56591..bc085c8e 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -391,6 +391,11 @@ QStringList OneSixInstance::externalPatches() const
return QStringList();
}
+bool OneSixInstance::providesVersionFile() const
+{
+ return false;
+}
+
QString OneSixInstance::loaderModsDir() const
{
return PathCombine(minecraftRoot(), "mods");
diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h
index 96526693..06fd9de3 100644
--- a/logic/OneSixInstance.h
+++ b/logic/OneSixInstance.h
@@ -73,6 +73,7 @@ public:
virtual QDir librariesPath() const;
virtual QDir versionsPath() const;
virtual QStringList externalPatches() const;
+ virtual bool providesVersionFile() const;
signals:
void versionReloaded();
diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp
index d3ac80c2..f87c65e7 100644
--- a/logic/OneSixUpdate.cpp
+++ b/logic/OneSixUpdate.cpp
@@ -35,7 +35,7 @@
#include "pathutils.h"
#include <JlCompress.h>
-OneSixUpdate::OneSixUpdate(BaseInstance *inst, QObject *parent)
+OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent)
: Task(parent), m_inst(inst)
{
}
@@ -73,6 +73,11 @@ void OneSixUpdate::executeTask()
void OneSixUpdate::versionFileStart()
{
+ if (m_inst->providesVersionFile())
+ {
+ jarlibStart();
+ return;
+ }
QLOG_INFO() << m_inst->name() << ": getting version file.";
setStatus(tr("Getting the version files from Mojang..."));
diff --git a/logic/OneSixUpdate.h b/logic/OneSixUpdate.h
index 3c18211e..eac882b5 100644
--- a/logic/OneSixUpdate.h
+++ b/logic/OneSixUpdate.h
@@ -23,13 +23,13 @@
#include "logic/tasks/Task.h"
class MinecraftVersion;
-class BaseInstance;
+class OneSixInstance;
class OneSixUpdate : public Task
{
Q_OBJECT
public:
- explicit OneSixUpdate(BaseInstance *inst, QObject *parent = 0);
+ explicit OneSixUpdate(OneSixInstance *inst, QObject *parent = 0);
virtual void executeTask();
private
@@ -55,5 +55,5 @@ private:
// target version, determined during this task
std::shared_ptr<MinecraftVersion> targetVersion;
- BaseInstance *m_inst = nullptr;
+ OneSixInstance *m_inst = nullptr;
};
diff --git a/logic/OneSixVersion.cpp b/logic/OneSixVersion.cpp
index ed8d5fa5..06e748bd 100644
--- a/logic/OneSixVersion.cpp
+++ b/logic/OneSixVersion.cpp
@@ -104,7 +104,6 @@ QList<std::shared_ptr<OneSixLibrary> > OneSixVersion::getActiveNormalLibs()
QList<std::shared_ptr<OneSixLibrary> > output;
for (auto lib : libraries)
{
- qDebug() << "Checking" << lib->rawName() << lib->isActive() << !lib->isNative();
if (lib->isActive() && !lib->isNative())
{
output.append(lib);