NOISSUE Make forge installable again
This commit is contained in:
parent
2ac0edbbdb
commit
e0596d3c86
@ -34,8 +34,15 @@
|
|||||||
OneSixInstance::OneSixInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
|
OneSixInstance::OneSixInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
|
||||||
: MinecraftInstance(globalSettings, settings, rootDir)
|
: MinecraftInstance(globalSettings, settings, rootDir)
|
||||||
{
|
{
|
||||||
|
// set explicitly during instance creation
|
||||||
m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, "");
|
m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, "");
|
||||||
m_settings->registerSetting("LWJGLVersion", "");
|
|
||||||
|
// defaults to the version we've been using for years (2.9.1)
|
||||||
|
m_settings->registerSetting("LWJGLVersion", "2.9.1");
|
||||||
|
|
||||||
|
// optionals
|
||||||
|
m_settings->registerSetting("ForgeVersion", "");
|
||||||
|
m_settings->registerSetting("LiteloaderVersion", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixInstance::init()
|
void OneSixInstance::init()
|
||||||
@ -499,6 +506,14 @@ bool OneSixInstance::setComponentVersion(const QString& uid, const QString& vers
|
|||||||
{
|
{
|
||||||
settings()->set("LWJGLVersion", version);
|
settings()->set("LWJGLVersion", version);
|
||||||
}
|
}
|
||||||
|
else if (uid == "net.minecraftforge")
|
||||||
|
{
|
||||||
|
settings()->set("ForgeVersion", version);
|
||||||
|
}
|
||||||
|
else if (uid == "com.liteloader")
|
||||||
|
{
|
||||||
|
settings()->set("LiteloaderVersion", version);
|
||||||
|
}
|
||||||
if(getMinecraftProfile())
|
if(getMinecraftProfile())
|
||||||
{
|
{
|
||||||
clearProfile();
|
clearProfile();
|
||||||
@ -515,12 +530,15 @@ QString OneSixInstance::getComponentVersion(const QString& uid) const
|
|||||||
}
|
}
|
||||||
else if(uid == "org.lwjgl")
|
else if(uid == "org.lwjgl")
|
||||||
{
|
{
|
||||||
auto version = settings()->get("LWJGLVersion").toString();
|
return settings()->get("LWJGLVersion").toString();
|
||||||
if(version.isEmpty())
|
}
|
||||||
{
|
else if(uid == "net.minecraftforge")
|
||||||
return "2.9.1";
|
{
|
||||||
}
|
return settings()->get("ForgeVersion").toString();
|
||||||
return version;
|
}
|
||||||
|
else if(uid == "com.liteloader")
|
||||||
|
{
|
||||||
|
return settings()->get("LiteloaderVersion").toString();
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@ -120,45 +120,10 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
|
|||||||
|
|
||||||
void OneSixProfileStrategy::loadUserPatches()
|
void OneSixProfileStrategy::loadUserPatches()
|
||||||
{
|
{
|
||||||
// load all patches, put into map for ordering, apply in the right order
|
// first, collect all patches (that are not builtins of OneSix) and load them
|
||||||
ProfileUtils::PatchOrder userOrder;
|
QMap<QString, ProfilePatchPtr> loadedPatches;
|
||||||
ProfileUtils::readOverrideOrders(FS::PathCombine(m_instance->instanceRoot(), "order.json"), userOrder);
|
QDir patchesDir(FS::PathCombine(m_instance->instanceRoot(),"patches"));
|
||||||
QDir patches(FS::PathCombine(m_instance->instanceRoot(),"patches"));
|
for (auto info : patchesDir.entryInfoList(QStringList() << "*.json", QDir::Files))
|
||||||
QSet<QString> seen_extra;
|
|
||||||
|
|
||||||
// first, load things by sort order.
|
|
||||||
for (auto id : userOrder)
|
|
||||||
{
|
|
||||||
// ignore builtins
|
|
||||||
if (id == "net.minecraft")
|
|
||||||
continue;
|
|
||||||
if (id == "org.lwjgl")
|
|
||||||
continue;
|
|
||||||
// parse the file
|
|
||||||
QString filename = patches.absoluteFilePath(id + ".json");
|
|
||||||
QFileInfo finfo(filename);
|
|
||||||
if(!finfo.exists())
|
|
||||||
{
|
|
||||||
qDebug() << "Patch file " << filename << " was deleted by external means...";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
qDebug() << "Reading" << filename << "by user order";
|
|
||||||
VersionFilePtr file = ProfileUtils::parseJsonFile(finfo, false);
|
|
||||||
// sanity check. prevent tampering with files.
|
|
||||||
if (file->uid != id)
|
|
||||||
{
|
|
||||||
file->addProblem(ProblemSeverity::Warning, QObject::tr("load id %1 does not match internal id %2").arg(id, file->uid));
|
|
||||||
seen_extra.insert(file->uid);
|
|
||||||
}
|
|
||||||
auto patchEntry = std::make_shared<ProfilePatch>(file, filename);
|
|
||||||
patchEntry->setRemovable(true);
|
|
||||||
patchEntry->setMovable(true);
|
|
||||||
profile->appendPatch(patchEntry);
|
|
||||||
}
|
|
||||||
// now load the rest by internal preference.
|
|
||||||
using FileEntry = std::tuple<VersionFilePtr, QString>;
|
|
||||||
QMultiMap<int, FileEntry> files;
|
|
||||||
for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
|
|
||||||
{
|
{
|
||||||
// parse the file
|
// parse the file
|
||||||
qDebug() << "Reading" << info.fileName();
|
qDebug() << "Reading" << info.fileName();
|
||||||
@ -168,51 +133,80 @@ void OneSixProfileStrategy::loadUserPatches()
|
|||||||
continue;
|
continue;
|
||||||
if (file->uid == "org.lwjgl")
|
if (file->uid == "org.lwjgl")
|
||||||
continue;
|
continue;
|
||||||
// do not load versions with broken IDs twice
|
auto patch = std::make_shared<ProfilePatch>(file, info.filePath());
|
||||||
if(seen_extra.contains(file->uid))
|
patch->setRemovable(true);
|
||||||
continue;
|
patch->setMovable(true);
|
||||||
// do not load what we already loaded in the first pass
|
if(ENV.metadataIndex()->hasUid(file->uid))
|
||||||
if (userOrder.contains(file->uid))
|
{
|
||||||
continue;
|
// FIXME: requesting a uid/list creates it in the index... this allows reverting to possibly invalid versions...
|
||||||
files.insert(file->order, std::make_tuple(file, info.filePath()));
|
patch->setRevertible(true);
|
||||||
|
}
|
||||||
|
loadedPatches[file->uid] = patch;
|
||||||
}
|
}
|
||||||
auto appendFilePatch = [&](FileEntry tuple)
|
// these are 'special'... if not already loaded from instance files, grab them from the metadata repo.
|
||||||
|
auto loadSpecial = [&](const QString & uid, int order)
|
||||||
{
|
{
|
||||||
VersionFilePtr file;
|
auto patchVersion = m_instance->getComponentVersion(uid);
|
||||||
QString filename;
|
if(!patchVersion.isEmpty() && !loadedPatches.contains(uid))
|
||||||
std::tie(file, filename) = tuple;
|
{
|
||||||
auto patchEntry = std::make_shared<ProfilePatch>(file, filename);
|
auto patch = std::make_shared<ProfilePatch>(ENV.metadataIndex()->get(uid, patchVersion));
|
||||||
patchEntry->setRemovable(true);
|
patch->setOrder(order);
|
||||||
patchEntry->setMovable(true);
|
patch->setVanilla(true);
|
||||||
profile->appendPatch(patchEntry);
|
patch->setRemovable(true);
|
||||||
|
patch->setMovable(true);
|
||||||
|
loadedPatches[uid] = patch;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
QSet<int> seen;
|
loadSpecial("net.minecraftforge", 5);
|
||||||
|
loadSpecial("com.liteloader", 10);
|
||||||
|
|
||||||
|
// now add all the patches by user sort order
|
||||||
|
ProfileUtils::PatchOrder userOrder;
|
||||||
|
ProfileUtils::readOverrideOrders(FS::PathCombine(m_instance->instanceRoot(), "order.json"), userOrder);
|
||||||
|
bool orderIsDirty = false;
|
||||||
|
for (auto uid : userOrder)
|
||||||
|
{
|
||||||
|
// ignore builtins
|
||||||
|
if (uid == "net.minecraft")
|
||||||
|
continue;
|
||||||
|
if (uid == "org.lwjgl")
|
||||||
|
continue;
|
||||||
|
// ordering has a patch that is gone?
|
||||||
|
if(!loadedPatches.contains(uid))
|
||||||
|
{
|
||||||
|
orderIsDirty = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
profile->appendPatch(loadedPatches.take(uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
// is there anything left to sort?
|
||||||
|
if(loadedPatches.isEmpty())
|
||||||
|
{
|
||||||
|
// TODO: save the order here?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// inserting into multimap by order number as key sorts the patches and detects duplicates
|
||||||
|
QMultiMap<int, ProfilePatchPtr> files;
|
||||||
|
auto iter = loadedPatches.begin();
|
||||||
|
while(iter != loadedPatches.end())
|
||||||
|
{
|
||||||
|
files.insert((*iter)->getOrder(), *iter);
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// then just extract the patches and put them in the list
|
||||||
for (auto order : files.keys())
|
for (auto order : files.keys())
|
||||||
{
|
{
|
||||||
if(seen.contains(order))
|
|
||||||
continue;
|
|
||||||
seen.insert(order);
|
|
||||||
const auto &values = files.values(order);
|
const auto &values = files.values(order);
|
||||||
if(values.size() == 1)
|
for(auto &value: values)
|
||||||
{
|
{
|
||||||
appendFilePatch(values[0]);
|
// TODO: put back the insertion of problem messages here, so the user knows about the id duplication
|
||||||
continue;
|
profile->appendPatch(value);
|
||||||
}
|
|
||||||
for(auto &file: values)
|
|
||||||
{
|
|
||||||
QStringList list;
|
|
||||||
for(auto &file2: values)
|
|
||||||
{
|
|
||||||
if(file != file2)
|
|
||||||
{
|
|
||||||
list.append(std::get<0>(file2)->name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auto vfileptr = std::get<0>(file);
|
|
||||||
vfileptr->addProblem(ProblemSeverity::Warning, QObject::tr("%1 has the same order as the following components:\n%2").arg(vfileptr->name, list.join(", ")));
|
|
||||||
appendFilePatch(file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: save the order here?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,7 +243,10 @@ bool OneSixProfileStrategy::removePatch(ProfilePatchPtr patch)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!m_instance->getComponentVersion(patch->getID()).isEmpty())
|
||||||
|
{
|
||||||
|
m_instance->setComponentVersion(patch->getID(), QString());
|
||||||
|
}
|
||||||
|
|
||||||
auto preRemoveJarMod = [&](JarmodPtr jarMod) -> bool
|
auto preRemoveJarMod = [&](JarmodPtr jarMod) -> bool
|
||||||
{
|
{
|
||||||
|
@ -401,7 +401,10 @@ void VersionPage::on_forgeBtn_clicked()
|
|||||||
vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!"));
|
vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!"));
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
m_profile->installVersion(vselect.selectedVersion());
|
auto vsn = vselect.selectedVersion();
|
||||||
|
m_inst->setComponentVersion("net.minecraftforge", vsn->descriptor());
|
||||||
|
m_profile->reload();
|
||||||
|
// m_profile->installVersion();
|
||||||
preselect(m_profile->rowCount(QModelIndex())-1);
|
preselect(m_profile->rowCount(QModelIndex())-1);
|
||||||
m_container->refreshContainer();
|
m_container->refreshContainer();
|
||||||
}
|
}
|
||||||
@ -420,7 +423,10 @@ void VersionPage::on_liteloaderBtn_clicked()
|
|||||||
vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!"));
|
vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!"));
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
m_profile->installVersion(vselect.selectedVersion());
|
auto vsn = vselect.selectedVersion();
|
||||||
|
m_inst->setComponentVersion("com.liteloader", vsn->descriptor());
|
||||||
|
m_profile->reload();
|
||||||
|
// m_profile->installVersion(vselect.selectedVersion());
|
||||||
preselect(m_profile->rowCount(QModelIndex())-1);
|
preselect(m_profile->rowCount(QModelIndex())-1);
|
||||||
m_container->refreshContainer();
|
m_container->refreshContainer();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user