From be53eb66f8a63730f4def5640db6205678b4e9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 13 Apr 2017 09:28:25 +0200 Subject: NOISSUE implement mainJar support in OneSix format This allows customizing the main jar like any other library. --- api/logic/minecraft/MinecraftProfile.cpp | 45 ++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'api/logic/minecraft/MinecraftProfile.cpp') diff --git a/api/logic/minecraft/MinecraftProfile.cpp b/api/logic/minecraft/MinecraftProfile.cpp index c04669c1..efe4651b 100644 --- a/api/logic/minecraft/MinecraftProfile.cpp +++ b/api/logic/minecraft/MinecraftProfile.cpp @@ -517,6 +517,19 @@ void MinecraftProfile::applyLibrary(LibraryPtr library) } } +const LibraryPtr MinecraftProfile::getMainJar() const +{ + return m_mainJar; +} + +void MinecraftProfile::applyMainJar(LibraryPtr jar) +{ + if(jar) + { + m_mainJar = jar; + } +} + void MinecraftProfile::applyProblemSeverity(ProblemSeverity severity) { if (m_problemSeverity < severity) @@ -595,7 +608,7 @@ const QList & MinecraftProfile::getNativeLibraries() const return m_nativeLibraries; } -void MinecraftProfile::getLibraryFiles(const QString& architecture, QStringList& jars, QStringList& nativeJars, const QString& overridePath) const +void MinecraftProfile::getLibraryFiles(const QString& architecture, QStringList& jars, QStringList& nativeJars, const QString& overridePath, const QString& tempPath) const { QStringList native32, native64; jars.clear(); @@ -604,6 +617,20 @@ void MinecraftProfile::getLibraryFiles(const QString& architecture, QStringList& { lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath); } + // NOTE: order is important here, add main jar last to the lists + if(m_mainJar) + { + // FIXME: HACK!! jar modding is weird and unsystematic! + if(m_jarMods.size()) + { + QDir tempDir(tempPath); + jars.append(tempDir.absoluteFilePath("minecraft.jar")); + } + else + { + m_mainJar->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath); + } + } for (auto lib : getNativeLibraries()) { lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath); @@ -618,22 +645,6 @@ void MinecraftProfile::getLibraryFiles(const QString& architecture, QStringList& } } - -QString MinecraftProfile::getMainJarUrl() const -{ - auto iter = mojangDownloads.find("client"); - if(iter != mojangDownloads.end()) - { - // current - return iter.value()->url; - } - else - { - // legacy fallback - return URLConstants::getLegacyJarUrl(getMinecraftVersion()); - } -} - void MinecraftProfile::installJarMods(QStringList selectedFiles) { m_strategy->installJarMods(selectedFiles); -- cgit v1.2.3