Skip to content

Commit

Permalink
HACK bare minimum to make forge 1.13 load
Browse files Browse the repository at this point in the history
Probably introduces 100 bugs and 200 corner cases. \o/
  • Loading branch information
peterix committed Apr 13, 2019
1 parent 70ed30f commit a9c005b
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 12 deletions.
2 changes: 1 addition & 1 deletion api/logic/minecraft/ComponentList.cpp
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion api/logic/minecraft/GradleSpecifier.h
Expand Up @@ -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
{
Expand Down
35 changes: 28 additions & 7 deletions api/logic/minecraft/Library.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}
Expand All @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -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";
Expand Down
18 changes: 17 additions & 1 deletion api/logic/minecraft/Library.h
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion api/logic/minecraft/MojangDownloadInfo.h
Expand Up @@ -36,7 +36,7 @@ struct MojangLibraryDownloadInfo
{
return artifact.get();
}

return classifiers[classifier].get();
}

Expand Down
2 changes: 1 addition & 1 deletion api/logic/minecraft/MojangVersionFormat.cpp
Expand Up @@ -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");
}

Expand Down
12 changes: 12 additions & 0 deletions api/logic/minecraft/OneSixVersionFormat.cpp
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit a9c005b

Please sign in to comment.