summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft/onesix
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-04-13 09:28:25 +0200
committerPetr Mrázek <peterix@gmail.com>2017-04-13 09:28:25 +0200
commitbe53eb66f8a63730f4def5640db6205678b4e9d8 (patch)
treebd5bdef96985312b6687b40f8835336bb3f56bb3 /api/logic/minecraft/onesix
parentdb7357d008ae1f4ac0599b7e410ab666dbea5805 (diff)
downloadMultiMC-be53eb66f8a63730f4def5640db6205678b4e9d8.tar
MultiMC-be53eb66f8a63730f4def5640db6205678b4e9d8.tar.gz
MultiMC-be53eb66f8a63730f4def5640db6205678b4e9d8.tar.lz
MultiMC-be53eb66f8a63730f4def5640db6205678b4e9d8.tar.xz
MultiMC-be53eb66f8a63730f4def5640db6205678b4e9d8.zip
NOISSUE implement mainJar support in OneSix format
This allows customizing the main jar like any other library.
Diffstat (limited to 'api/logic/minecraft/onesix')
-rw-r--r--api/logic/minecraft/onesix/OneSixInstance.cpp46
-rw-r--r--api/logic/minecraft/onesix/OneSixInstance.h3
-rw-r--r--api/logic/minecraft/onesix/OneSixVersionFormat.cpp26
-rw-r--r--api/logic/minecraft/onesix/update/LibrariesTask.cpp34
4 files changed, 51 insertions, 58 deletions
diff --git a/api/logic/minecraft/onesix/OneSixInstance.cpp b/api/logic/minecraft/onesix/OneSixInstance.cpp
index fd54f544..0061be08 100644
--- a/api/logic/minecraft/onesix/OneSixInstance.cpp
+++ b/api/logic/minecraft/onesix/OneSixInstance.cpp
@@ -159,20 +159,6 @@ QString OneSixInstance::getLocalLibraryPath() const
return libraries_dir.absolutePath();
}
-QString OneSixInstance::mainJarPath() const
-{
- auto jarMods = getJarMods();
- if (!jarMods.isEmpty())
- {
- return QDir(binRoot()).absoluteFilePath("minecraft.jar");
- }
- else
- {
- QString relpath = m_profile->getMinecraftVersion() + "/" + m_profile->getMinecraftVersion() + ".jar";
- return versionsPath().absoluteFilePath(relpath);
- }
-}
-
QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
{
QString launchScript;
@@ -221,12 +207,11 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
{
QStringList jars, nativeJars;
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
- m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath());
+ m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
for(auto file: jars)
{
launchScript += "cp " + file + "\n";
}
- launchScript += "cp " + mainJarPath() + "\n";
for(auto file: nativeJars)
{
launchScript += "ext " + file + "\n";
@@ -265,7 +250,7 @@ QStringList OneSixInstance::verboseDescription(AuthSessionPtr session)
out << "Libraries:";
QStringList jars, nativeJars;
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
- m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath());
+ m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
auto printLibFile = [&](const QString & path)
{
QFileInfo info(path);
@@ -282,7 +267,6 @@ QStringList OneSixInstance::verboseDescription(AuthSessionPtr session)
{
printLibFile(file);
}
- printLibFile(mainJarPath());
out << "";
out << "Native libraries:";
for(auto file: nativeJars)
@@ -390,18 +374,6 @@ std::shared_ptr<Task> OneSixInstance::createJarModdingTask()
auto profile = m_inst->getMinecraftProfile();
// nuke obsolete stripped jar(s) if needed
QString version_id = profile->getMinecraftVersion();
- QString strippedPath = version_id + "/" + version_id + "-stripped.jar";
- QFile strippedJar(strippedPath);
- if(strippedJar.exists())
- {
- strippedJar.remove();
- }
- auto tempJarPath = QDir(m_inst->instanceRoot()).absoluteFilePath("temp.jar");
- QFile tempJar(tempJarPath);
- if(tempJar.exists())
- {
- tempJar.remove();
- }
if(!FS::ensureFolderPathExists(m_inst->binRoot()))
{
emitFailed(tr("Couldn't create the bin folder for Minecraft.jar"));
@@ -421,11 +393,10 @@ std::shared_ptr<Task> OneSixInstance::createJarModdingTask()
auto jarMods = m_inst->getJarMods();
if(jarMods.size())
{
- auto sourceJarPath = m_inst->versionsPath().absoluteFilePath(version_id + "/" + version_id + ".jar");
- QString localPath = version_id + "/" + version_id + ".jar";
- auto metacache = ENV.metacache();
- auto entry = metacache->resolveEntry("versions", localPath);
- QString fullJarPath = entry->getFullPath();
+ auto mainJar = profile->getMainJar();
+ QStringList jars, temp1, temp2, temp3, temp4;
+ mainJar->getApplicableFiles(currentSystem, jars, temp1, temp2, temp3, m_inst->getLocalLibraryPath());
+ auto sourceJarPath = jars[0];
if(!MMCZip::createModdedJar(sourceJarPath, finalJarPath, jarMods))
{
emitFailed(tr("Failed to create the custom Minecraft jar file."));
@@ -699,8 +670,7 @@ QStringList OneSixInstance::getClassPath() const
{
QStringList jars, nativeJars;
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
- m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath());
- jars.append(mainJarPath());
+ m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
return jars;
}
@@ -713,6 +683,6 @@ QStringList OneSixInstance::getNativeJars() const
{
QStringList jars, nativeJars;
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
- m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath());
+ m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
return nativeJars;
}
diff --git a/api/logic/minecraft/onesix/OneSixInstance.h b/api/logic/minecraft/onesix/OneSixInstance.h
index ec8c2597..bf12160e 100644
--- a/api/logic/minecraft/onesix/OneSixInstance.h
+++ b/api/logic/minecraft/onesix/OneSixInstance.h
@@ -115,9 +115,6 @@ protected:
signals:
void versionReloaded();
-private:
- QString mainJarPath() const;
-
protected:
std::shared_ptr<MinecraftProfile> m_profile;
mutable std::shared_ptr<ModList> m_loader_mod_list;
diff --git a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp
index 266bd4bd..1da375ad 100644
--- a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp
+++ b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp
@@ -142,6 +142,32 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
readLibs("+libraries");
}
+ // if we have mainJar, just use it
+ if(root.contains("mainJar"))
+ {
+ QJsonObject libObj = requireObject(root, "mainJar");
+ out->mainJar = libraryFromJson(libObj, filename);
+ }
+ // else reconstruct it from downloads and id ... if that's available
+ else if(!out->minecraftVersion.isEmpty())
+ {
+ auto lib = std::make_shared<Library>();
+ lib->setRawName(GradleSpecifier(QString("com.mojang:minecraft:%1:client").arg(out->minecraftVersion)));
+ // we have a reliable client download, use it.
+ if(out->mojangDownloads.contains("client"))
+ {
+ auto LibDLInfo = std::make_shared<MojangLibraryDownloadInfo>();
+ LibDLInfo->artifact = out->mojangDownloads["client"];
+ lib->setMojangDownloadInfo(LibDLInfo);
+ }
+ // we got nothing... guess based on ancient hardcoded Mojang behaviour
+ // FIXME: this will eventually break...
+ else
+ {
+ lib->setAbsoluteUrl(URLConstants::getLegacyJarUrl(out->minecraftVersion));
+ }
+ }
+
/* removed features that shouldn't be used */
if (root.contains("tweakers"))
{
diff --git a/api/logic/minecraft/onesix/update/LibrariesTask.cpp b/api/logic/minecraft/onesix/update/LibrariesTask.cpp
index 3e6bb12a..1b7e71d3 100644
--- a/api/logic/minecraft/onesix/update/LibrariesTask.cpp
+++ b/api/logic/minecraft/onesix/update/LibrariesTask.cpp
@@ -21,36 +21,36 @@ void LibrariesTask::executeTask()
// Build a list of URLs that will need to be downloaded.
std::shared_ptr<MinecraftProfile> profile = inst->getMinecraftProfile();
- // minecraft.jar for this version
- {
- QString version_id = profile->getMinecraftVersion();
- QString localPath = version_id + "/" + version_id + ".jar";
- QString urlstr = profile->getMainJarUrl();
-
- auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name()));
- auto metacache = ENV.metacache();
- auto entry = metacache->resolveEntry("versions", localPath);
- job->addNetAction(Net::Download::makeCached(QUrl(urlstr), entry));
- downloadJob.reset(job);
- }
+ auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name()));
+ downloadJob.reset(job);
auto metacache = ENV.metacache();
QList<LibraryPtr> brokenLocalLibs;
QStringList failedFiles;
+ auto createJob = [&](const LibraryPtr & lib)
+ {
+ if(!lib)
+ {
+ emitFailed(tr("Null jar is specified in the metadata, aborting."));
+ return;
+ }
+ auto dls = lib->getDownloads(currentSystem, metacache.get(), failedFiles, inst->getLocalLibraryPath());
+ for(auto dl : dls)
+ {
+ downloadJob->addNetAction(dl);
+ }
+ };
auto createJobs = [&](const QList<LibraryPtr> & libs)
{
for (auto lib : libs)
{
- auto dls = lib->getDownloads(currentSystem, metacache.get(), failedFiles, inst->getLocalLibraryPath());
- for(auto dl : dls)
- {
- downloadJob->addNetAction(dl);
- }
+ createJob(lib);
}
};
createJobs(profile->getLibraries());
createJobs(profile->getNativeLibraries());
+ createJob(profile->getMainJar());
// FIXME: this is never filled!!!!
if (!brokenLocalLibs.empty())