From c4c8e99681e14e5d0e82a13cb0631107dedf96ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 17 Apr 2017 22:51:30 +0200 Subject: NOISSUE jar mods as libraries, fix for customizing net.minecraft --- .../minecraft/onesix/OneSixProfileStrategy.cpp | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'api/logic/minecraft/onesix/OneSixProfileStrategy.cpp') diff --git a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp index d3e137c7..b4be3356 100644 --- a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp +++ b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp @@ -248,16 +248,22 @@ bool OneSixProfileStrategy::removePatch(ProfilePatchPtr patch) m_instance->setComponentVersion(patch->getID(), QString()); } - auto preRemoveJarMod = [&](JarmodPtr jarMod) -> bool + // FIXME: we need a generic way of removing local resources, not just jar mods... + auto preRemoveJarMod = [&](LibraryPtr jarMod) -> bool { - QString fullpath = FS::PathCombine(m_instance->jarModsDir(), jarMod->name); - QFileInfo finfo (fullpath); + if (!jarMod->isLocal()) + { + return true; + } + QStringList jar, temp1, temp2, temp3; + jarMod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, m_instance->jarmodsPath().absolutePath()); + QFileInfo finfo (jar[0]); if(finfo.exists()) { - QFile jarModFile(fullpath); + QFile jarModFile(jar[0]); if(!jarModFile.remove()) { - qCritical() << "File" << fullpath << "could not be removed because:" << jarModFile.errorString(); + qCritical() << "File" << jar[0] << "could not be removed because:" << jarModFile.errorString(); return false; } return true; @@ -381,9 +387,11 @@ bool OneSixProfileStrategy::installJarMods(QStringList filepaths) } auto f = std::make_shared(); - auto jarMod = std::make_shared(); - jarMod->name = target_filename; - jarMod->originalName = sourceInfo.completeBaseName(); + auto jarMod = std::make_shared(); + jarMod->setRawName(GradleSpecifier("org.multimc.jarmods:" + id + ":1")); + jarMod->setFilename(target_filename); + jarMod->setDisplayName(sourceInfo.completeBaseName()); + jarMod->setHint("local"); f->jarMods.append(jarMod); f->name = target_name; f->uid = target_id; -- cgit v1.2.3