1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
#include "OneSixFTBInstance.h"
#include "FTBProfileStrategy.h"
#include "minecraft/MinecraftProfile.h"
#include "minecraft/GradleSpecifier.h"
#include "tasks/SequentialTask.h"
#include <settings/INISettingsObject.h>
#include <FileSystem.h>
#include <QJsonArray>
OneSixFTBInstance::OneSixFTBInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir) :
OneSixInstance(globalSettings, settings, rootDir)
{
m_globalSettings = globalSettings;
}
void OneSixFTBInstance::copy(SettingsObjectPtr newSettings, const QDir &newDir)
{
QStringList libraryNames;
// create patch file
{
qDebug()<< "Creating patch file for FTB instance...";
QFile f(minecraftRoot() + "/pack.json");
if (!f.open(QFile::ReadOnly))
{
qCritical() << "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");
// 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");
}
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());
FS::ensureFilePathExists(newDir.absoluteFilePath("patches/ftb.json"));
QFile out(newDir.absoluteFilePath("patches/ftb.json"));
if (!out.open(QFile::WriteOnly | QFile::Truncate))
{
qCritical() << "Couldn't open" << out.fileName() << ":" << out.errorString();
return;
}
out.write(QJsonDocument(root).toJson());
}
// copy libraries
{
qDebug() << "Copying FTB libraries";
for (auto library : libraryNames)
{
GradleSpecifier lib(library);
const QString out = QDir::current().absoluteFilePath("libraries/" + lib.toPath());
if (QFile::exists(out))
{
continue;
}
if (!FS::ensureFilePathExists(out))
{
qCritical() << "Couldn't create folder structure for" << out;
}
if (!QFile::copy(librariesPath().absoluteFilePath(lib.toPath()), out))
{
qCritical() << "Couldn't copy" << QString(lib);
}
}
}
// now set the target instance to be plain OneSix
newSettings->set("InstanceType", "OneSix");
}
QString OneSixFTBInstance::id() const
{
return "FTB/" + BaseInstance::id();
}
QDir OneSixFTBInstance::librariesPath() const
{
return QDir(m_globalSettings->get("FTBRoot").toString() + "/libraries");
}
QDir OneSixFTBInstance::versionsPath() const
{
return QDir(m_globalSettings->get("FTBRoot").toString() + "/versions");
}
bool OneSixFTBInstance::providesVersionFile() const
{
return true;
}
void OneSixFTBInstance::createProfile()
{
m_profile.reset(new MinecraftProfile(new FTBProfileStrategy(this)));
}
shared_qobject_ptr<Task> OneSixFTBInstance::createUpdateTask()
{
return OneSixInstance::createUpdateTask();
}
QString OneSixFTBInstance::typeName() const
{
return tr("OneSix FTB");
}
#include "OneSixFTBInstance.moc"
|