Skip to content
Permalink
Browse files

HACK bare minimum to make forge 1.13 load

Probably introduces 100 bugs and 200 corner cases. \o/
  • Loading branch information...
peterix committed Feb 22, 2019
1 parent 414946c commit 30cc92a3092a6db88497001e2adf433671c84335
@@ -981,7 +981,7 @@ bool ComponentList::removeComponent_internal(ComponentPtr patch)
// FIXME: we need a generic way of removing local resources, not just jar mods...
auto preRemoveJarMod = [&](LibraryPtr jarMod) -> bool
{
if (!jarMod->isLocal())
if (!jarMod->isInstanceLocal())
{
return true;
}
@@ -117,7 +117,7 @@ struct GradleSpecifier
}
bool matchName(const GradleSpecifier & other) const
{
return other.artifactId() == artifactId() && other.groupId() == groupId();
return other.artifactId() == artifactId() && other.groupId() == groupId() && other.classifier() == classifier();
}
bool operator==(const GradleSpecifier & other) const
{
@@ -11,7 +11,7 @@
void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& native, QStringList& native32,
QStringList& native64, const QString &overridePath) const
{
bool local = isLocal();
bool local = isInstanceLocal();
auto actualPath = [&](QString relPath)
{
QFileInfo out(FS::PathCombine(storagePrefix(), relPath));
@@ -39,7 +39,7 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na
native += actualPath(raw_storage);
}
}
else
else if (!presenceOnly)
{
jar += actualPath(raw_storage);
}
@@ -54,9 +54,10 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(
{
QList<NetActionPtr> out;
bool stale = isAlwaysStale();
bool local = isLocal();
bool instanceLocal = isInstanceLocal();
bool launcherLocal = isLocalBuilt();

auto check_local_file = [&](QString storage)
auto check_instance_local_file = [&](QString storage)
{
QFileInfo fileinfo(storage);
QString fileName = fileinfo.fileName();
@@ -70,11 +71,26 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads(
return true;
};

auto check_launcher_local_file = [&](QString storage)
{
QFileInfo localFileInfo("libraries/" + storage);
if(!localFileInfo.exists())
{
failedLocalFiles.append(localFileInfo.filePath());
return false;
}
return true;
};

auto add_download = [&](QString storage, QString url, QString sha1)
{
if(local)
if(instanceLocal)
{
return check_instance_local_file(storage);
}
else if(launcherLocal)
{
return check_local_file(storage);
return check_launcher_local_file(storage);
}
auto entry = cache->resolveEntry("libraries", storage);
if(stale)
@@ -233,11 +249,16 @@ bool Library::isActive() const
return result;
}

bool Library::isLocal() const
bool Library::isInstanceLocal() const
{
return m_hint == "local";
}

bool Library::isLocalBuilt() const
{
return localBuild;
}

bool Library::isAlwaysStale() const
{
return m_hint == "always-stale";
@@ -49,6 +49,8 @@ class MULTIMC_LOGIC_EXPORT Library
newlib->m_storagePrefix = base->m_storagePrefix;
newlib->m_mojangDownloads = base->m_mojangDownloads;
newlib->m_filename = base->m_filename;
newlib->presenceOnly = base->presenceOnly;
newlib->localBuild = base->localBuild;
return newlib;
}

@@ -146,7 +148,15 @@ class MULTIMC_LOGIC_EXPORT Library
bool isActive() const;

/// Returns true if the library is contained in an instance and false if it is shared
bool isLocal() const;
bool isInstanceLocal() const;

/// Returns true if the library cannot be downloaded (was built locally somehow)
bool isLocalBuilt() const;

bool isLocal() const
{
return isInstanceLocal() || isLocalBuilt();
}

/// Returns true if the library is to always be checked for updates
bool isAlwaysStale() const;
@@ -212,6 +222,12 @@ class MULTIMC_LOGIC_EXPORT Library
/// true if the library had a rules section (even empty)
bool applyRules = false;

// MultiMC-specific: the artifact must be present, but is not part of the classpath
bool presenceOnly = false;

// MultiMC-specific: the artifact must be present, but cannot be downloaded, because it was created by some other mechanism
bool localBuild = false;

/// rules associated with the library
QList<std::shared_ptr<Rule>> m_rules;

@@ -36,7 +36,7 @@ struct MojangLibraryDownloadInfo
{
return artifact.get();
}

return classifiers[classifier].get();
}

@@ -31,7 +31,7 @@ static void readDownloadInfo(MojangDownloadInfo::Ptr out, const QJsonObject &obj
readString(obj, "path", out->path);
// required!
out->sha1 = requireString(obj, "sha1");
out->url = requireString(obj, "url");
out->url = ensureString(obj, "url", QString());
out->size = requireInteger(obj, "size");
}

@@ -21,6 +21,14 @@ LibraryPtr OneSixVersionFormat::libraryFromJson(const QJsonObject &libObj, const
readString(libObj, "MMC-absoluteUrl", out->m_absoluteURL);
readString(libObj, "MMC-filename", out->m_filename);
readString(libObj, "MMC-displayname", out->m_displayname);
if (libObj.contains("presenceOnly"))
{
out->presenceOnly = requireBoolean(libObj, "presenceOnly");
}
if (libObj.contains("localBuild"))
{
out->localBuild = requireBoolean(libObj, "localBuild");
}
return out;
}

@@ -35,6 +43,10 @@ QJsonObject OneSixVersionFormat::libraryToJson(Library *library)
libRoot.insert("MMC-filename", library->m_filename);
if (library->m_displayname.size())
libRoot.insert("MMC-displayname", library->m_displayname);
if (library->presenceOnly)
libRoot.insert("presenceOnly", true);
if (library->localBuild)
libRoot.insert("localBuild", true);
return libRoot;
}

0 comments on commit 30cc92a

Please sign in to comment.
You can’t perform that action at this time.