aboutsummaryrefslogtreecommitdiff
path: root/api/logic/minecraft
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-06-16 02:20:23 +0200
committerPetr Mrázek <peterix@gmail.com>2016-08-01 21:15:08 +0200
commit1f2bed2ef119094bdc156aa3a206b93dea5081d1 (patch)
treef154e39d3de3a3d71ed868cf396c4361b04e75c5 /api/logic/minecraft
parent57c84ec2b15d8aa6985681f79641f5989c2f049f (diff)
downloadPrismLauncher-1f2bed2ef119094bdc156aa3a206b93dea5081d1.tar.gz
PrismLauncher-1f2bed2ef119094bdc156aa3a206b93dea5081d1.tar.bz2
PrismLauncher-1f2bed2ef119094bdc156aa3a206b93dea5081d1.zip
NOISSUE implement direct java launch
Just running the Java process and giving it params on the command line
Diffstat (limited to 'api/logic/minecraft')
-rw-r--r--api/logic/minecraft/MinecraftInstance.cpp110
-rw-r--r--api/logic/minecraft/MinecraftInstance.h18
-rw-r--r--api/logic/minecraft/MinecraftProfile.cpp20
-rw-r--r--api/logic/minecraft/MinecraftProfile.h1
-rw-r--r--api/logic/minecraft/launch/DirectJavaLaunch.cpp149
-rw-r--r--api/logic/minecraft/launch/DirectJavaLaunch.h47
-rw-r--r--api/logic/minecraft/launch/ExtractNatives.cpp86
-rw-r--r--api/logic/minecraft/launch/ExtractNatives.h37
-rw-r--r--api/logic/minecraft/launch/LauncherPartLaunch.cpp (renamed from api/logic/minecraft/launch/LaunchMinecraft.cpp)22
-rw-r--r--api/logic/minecraft/launch/LauncherPartLaunch.h (renamed from api/logic/minecraft/launch/LaunchMinecraft.h)7
-rw-r--r--api/logic/minecraft/launch/PrintInstanceInfo.cpp25
-rw-r--r--api/logic/minecraft/launch/PrintInstanceInfo.h38
-rw-r--r--api/logic/minecraft/legacy/LegacyInstance.cpp198
-rw-r--r--api/logic/minecraft/legacy/LegacyInstance.h18
-rw-r--r--api/logic/minecraft/onesix/OneSixInstance.cpp284
-rw-r--r--api/logic/minecraft/onesix/OneSixInstance.h17
16 files changed, 888 insertions, 189 deletions
diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp
index 405ccd26..8cc4f805 100644
--- a/api/logic/minecraft/MinecraftInstance.cpp
+++ b/api/logic/minecraft/MinecraftInstance.cpp
@@ -1,4 +1,6 @@
#include "MinecraftInstance.h"
+#include <minecraft/launch/ExtractNatives.h>
+#include <minecraft/launch/PrintInstanceInfo.h>
#include <settings/Setting.h>
#include "settings/SettingsObject.h"
#include "Env.h"
@@ -9,6 +11,15 @@
#include <FileSystem.h>
#include <java/JavaVersion.h>
+#include "launch/LaunchTask.h"
+#include "launch/steps/PostLaunchCommand.h"
+#include "launch/steps/Update.h"
+#include "launch/steps/PreLaunchCommand.h"
+#include "launch/steps/TextPrint.h"
+#include "minecraft/launch/LauncherPartLaunch.h"
+#include "minecraft/launch/ModMinecraftJar.h"
+#include "java/launch/CheckJava.h"
+
#define IBUS "@im=ibus"
// all of this because keeping things compatible with deprecated old settings
@@ -52,6 +63,7 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO
// special!
m_settings->registerPassthrough(globalSettings->getSetting("JavaTimestamp"), javaOrLocation);
m_settings->registerPassthrough(globalSettings->getSetting("JavaVersion"), javaOrLocation);
+ m_settings->registerPassthrough(globalSettings->getSetting("JavaArchitecture"), javaOrLocation);
// Window Size
auto windowSetting = m_settings->registerSetting("OverrideWindow", false);
@@ -64,6 +76,10 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO
m_settings->registerOverride(globalSettings->getSetting("MinMemAlloc"), memorySetting);
m_settings->registerOverride(globalSettings->getSetting("MaxMemAlloc"), memorySetting);
m_settings->registerOverride(globalSettings->getSetting("PermGen"), memorySetting);
+
+ // Minecraft launch method
+ auto launchMethodOverride = m_settings->registerSetting("OverrideMCLaunchMethod", false);
+ m_settings->registerOverride(globalSettings->getSetting("MCLaunchMethod"), launchMethodOverride);
}
QString MinecraftInstance::minecraftRoot() const
@@ -105,7 +121,7 @@ QStringList MinecraftInstance::javaArguments() const
args << QString("-Xmx%1m").arg(settings()->get("MaxMemAlloc").toInt());
// No PermGen in newer java.
- JavaVersion javaVersion(settings()->get("JavaVersion").toString());
+ JavaVersion javaVersion = getJavaVersion();
if(javaVersion.requiresPermGen())
{
auto permgen = settings()->get("PermGen").toInt();
@@ -116,7 +132,6 @@ QStringList MinecraftInstance::javaArguments() const
}
args << "-Duser.language=en";
- args << "-jar" << FS::PathCombine(QCoreApplication::applicationDirPath(), "jars", "NewLaunch.jar");
return args;
}
@@ -366,4 +381,95 @@ QString MinecraftInstance::getStatusbarDescription()
return description;
}
+std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session)
+{
+ auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr()));
+ auto pptr = process.get();
+
+ // print a header
+ {
+ process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + minecraftRoot() + "\n\n", MessageLevel::MultiMC));
+ }
+
+ // check java
+ {
+ auto step = std::make_shared<CheckJava>(pptr);
+ process->appendStep(step);
+ }
+
+ // check launch method
+ QStringList validMethods = validLaunchMethods();
+ QString method = launchMethod();
+ if(!validMethods.contains(method))
+ {
+ process->appendStep(std::make_shared<TextPrint>(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal));
+ return process;
+ }
+
+ // run pre-launch command if that's needed
+ if(getPreLaunchCommand().size())
+ {
+ auto step = std::make_shared<PreLaunchCommand>(pptr);
+ step->setWorkingDirectory(minecraftRoot());
+ process->appendStep(step);
+ }
+
+ // if we aren't in offline mode,.
+ if(session->status != AuthSession::PlayableOffline)
+ {
+ process->appendStep(std::make_shared<Update>(pptr));
+ }
+
+ // if there are any jar mods
+ if(getJarMods().size())
+ {
+ auto step = std::make_shared<ModMinecraftJar>(pptr);
+ process->appendStep(step);
+ }
+
+ // print some instance info here...
+ {
+ auto step = std::make_shared<PrintInstanceInfo>(pptr, session);
+ process->appendStep(step);
+ }
+
+ // extract native jars if needed
+ auto jars = getNativeJars();
+ if(jars.size())
+ {
+ auto step = std::make_shared<ExtractNatives>(pptr);
+ process->appendStep(step);
+ }
+
+ {
+ // actually launch the game
+ auto step = createMainLaunchStep(pptr, session);
+ process->appendStep(step);
+ }
+
+ // run post-exit command if that's needed
+ if(getPostExitCommand().size())
+ {
+ auto step = std::make_shared<PostLaunchCommand>(pptr);
+ step->setWorkingDirectory(minecraftRoot());
+ process->appendStep(step);
+ }
+ if (session)
+ {
+ process->setCensorFilter(createCensorFilterFromSession(session));
+ }
+ return process;
+}
+
+QString MinecraftInstance::launchMethod()
+{
+ return m_settings->get("MCLaunchMethod").toString();
+}
+
+JavaVersion MinecraftInstance::getJavaVersion() const
+{
+ return JavaVersion(settings()->get("JavaVersion").toString());
+}
+
+
#include "MinecraftInstance.moc"
diff --git a/api/logic/minecraft/MinecraftInstance.h b/api/logic/minecraft/MinecraftInstance.h
index cd3a8d90..3aef2969 100644
--- a/api/logic/minecraft/MinecraftInstance.h
+++ b/api/logic/minecraft/MinecraftInstance.h
@@ -1,5 +1,6 @@
#pragma once
#include "BaseInstance.h"
+#include <java/JavaVersion.h>
#include "minecraft/Mod.h"
#include <QProcess>
@@ -7,6 +8,7 @@
class ModList;
class WorldList;
+class LaunchStep;
class MULTIMC_LOGIC_EXPORT MinecraftInstance: public BaseInstance
{
@@ -36,7 +38,7 @@ public:
return QList<Mod>();
}
- /// get the launch script to be used with this
+ virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override;
virtual QString createLaunchScript(AuthSessionPtr session) = 0;
//FIXME: nuke?
@@ -60,8 +62,22 @@ public:
virtual QString getStatusbarDescription() override;
+ virtual QStringList getClassPath() const = 0;
+ virtual QStringList getNativeJars() const = 0;
+
+ virtual QString getMainClass() const = 0;
+
+ virtual QString getNativePath() const = 0;
+
+ virtual QStringList processMinecraftArgs(AuthSessionPtr account) const = 0;
+
+ virtual JavaVersion getJavaVersion() const;
+
protected:
QMap<QString, QString> createCensorFilterFromSession(AuthSessionPtr session);
+ virtual QStringList validLaunchMethods() = 0;
+ virtual QString launchMethod();
+ virtual std::shared_ptr<LaunchStep> createMainLaunchStep(LaunchTask *parent, AuthSessionPtr session) = 0;
private:
QString prettifyTimeDuration(int64_t duration);
};
diff --git a/api/logic/minecraft/MinecraftProfile.cpp b/api/logic/minecraft/MinecraftProfile.cpp
index 70d0cee4..19127a54 100644
--- a/api/logic/minecraft/MinecraftProfile.cpp
+++ b/api/logic/minecraft/MinecraftProfile.cpp
@@ -573,6 +573,26 @@ const QList<LibraryPtr> & MinecraftProfile::getLibraries() const
return m_libraries;
}
+void MinecraftProfile::getLibraryFiles(const QString& architecture, QStringList& jars, QStringList& nativeJars) const
+{
+ QStringList native32, native64;
+ jars.clear();
+ nativeJars.clear();
+ for (auto lib : getLibraries())
+ {
+ lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64);
+ }
+ if(architecture == "32")
+ {
+ nativeJars.append(native32);
+ }
+ else if(architecture == "64")
+ {
+ nativeJars.append(native64);
+ }
+}
+
+
QString MinecraftProfile::getMainJarUrl() const
{
auto iter = mojangDownloads.find("client");
diff --git a/api/logic/minecraft/MinecraftProfile.h b/api/logic/minecraft/MinecraftProfile.h
index ca9288ad..cc9b89b1 100644
--- a/api/logic/minecraft/MinecraftProfile.h
+++ b/api/logic/minecraft/MinecraftProfile.h
@@ -110,6 +110,7 @@ public: /* getters for profile variables */
const QStringList & getTweakers() const;
const QList<JarmodPtr> & getJarMods() const;
const QList<LibraryPtr> & getLibraries() const;
+ void getLibraryFiles(const QString & architecture, QStringList & jars, QStringList & nativeJars) const;
QString getMainJarUrl() const;
bool hasTrait(const QString & trait) const;
ProblemSeverity getProblemSeverity() const;
diff --git a/api/logic/minecraft/launch/DirectJavaLaunch.cpp b/api/logic/minecraft/launch/DirectJavaLaunch.cpp
new file mode 100644
index 00000000..c46cdcd4
--- /dev/null
+++ b/api/logic/minecraft/launch/DirectJavaLaunch.cpp
@@ -0,0 +1,149 @@
+/* Copyright 2013-2015 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "DirectJavaLaunch.h"
+#include <launch/LaunchTask.h>
+#include <minecraft/MinecraftInstance.h>
+#include <FileSystem.h>
+#include <QStandardPaths>
+
+DirectJavaLaunch::DirectJavaLaunch(LaunchTask *parent) : LaunchStep(parent)
+{
+ connect(&m_process, &LoggedProcess::log, this, &DirectJavaLaunch::logLines);
+ connect(&m_process, &LoggedProcess::stateChanged, this, &DirectJavaLaunch::on_state);
+}
+
+void DirectJavaLaunch::executeTask()
+{
+ auto instance = m_parent->instance();
+ std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);
+ QStringList args = minecraftInstance->javaArguments();
+
+ // HACK: this is a workaround for MCL-3732 - 'server-resource-packs' is created.
+ if(!FS::ensureFolderPathExists(FS::PathCombine(minecraftInstance->minecraftRoot(), "server-resource-packs")))
+ {
+ emit logLine(tr("Couldn't create the 'server-resource-packs' folder"), MessageLevel::Error);
+ }
+
+ args.append("-Djava.library.path=" + minecraftInstance->getNativePath());
+
+ auto classPathEntries = minecraftInstance->getClassPath();
+ args.append("-cp");
+ QString classpath;
+#ifdef Q_OS_WIN32
+ classpath = classPathEntries.join(';');
+#else
+ classpath = classPathEntries.join(':');
+#endif
+ args.append(classpath);
+ args.append(minecraftInstance->getMainClass());
+
+ QString allArgs = args.join(", ");
+ emit logLine("Java Arguments:\n[" + m_parent->censorPrivateInfo(allArgs) + "]\n\n", MessageLevel::MultiMC);
+
+ auto javaPath = FS::ResolveExecutable(instance->settings()->get("JavaPath").toString());
+
+ m_process.setProcessEnvironment(instance->createEnvironment());
+
+ auto mcArgs = minecraftInstance->processMinecraftArgs(m_session);
+ args.append(mcArgs);
+
+ QString wrapperCommand = instance->getWrapperCommand();
+ if(!wrapperCommand.isEmpty())
+ {
+ auto realWrapperCommand = QStandardPaths::findExecutable(wrapperCommand);
+ if (realWrapperCommand.isEmpty())
+ {
+ QString reason = tr("The wrapper command \"%1\" couldn't be found.").arg(wrapperCommand);
+ emit logLine(reason, MessageLevel::Fatal);
+ emitFailed(reason);
+ return;
+ }
+ emit logLine("Wrapper command is:\n" + wrapperCommand + "\n\n", MessageLevel::MultiMC);
+ args.prepend(javaPath);
+ m_process.start(wrapperCommand, args);
+ }
+ else
+ {
+ m_process.start(javaPath, args);
+ }
+}
+
+void DirectJavaLaunch::on_state(LoggedProcess::State state)
+{
+ switch(state)
+ {
+ case LoggedProcess::FailedToStart:
+ {
+ //: Error message displayed if instace can't start
+ QString reason = tr("Could not launch minecraft!");
+ emit logLine(reason, MessageLevel::Fatal);
+ emitFailed(reason);
+ return;
+ }
+ case LoggedProcess::Aborted:
+ case LoggedProcess::Crashed:
+
+ {
+ m_parent->setPid(-1);
+ emitFailed("Game crashed.");
+ return;
+ }
+ case LoggedProcess::Finished:
+ {
+ m_parent->setPid(-1);
+ // if the exit code wasn't 0, report this as a crash
+ auto exitCode = m_process.exitCode();
+ if(exitCode != 0)
+ {
+ emitFailed("Game crashed.");
+ return;
+ }
+ //FIXME: make this work again
+ // m_postlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(exitCode));
+ // run post-exit
+ emitSucceeded();
+ break;
+ }
+ case LoggedProcess::Running:
+ emit logLine(tr("Minecraft process ID: %1\n\n").arg(m_process.processId()), MessageLevel::MultiMC);
+ m_parent->setPid(m_process.processId());
+ m_parent->instance()->setLastLaunch();
+ break;
+ default:
+ break;
+ }
+}
+
+void DirectJavaLaunch::setWorkingDirectory(const QString &wd)
+{
+ m_process.setWorkingDirectory(wd);
+}
+
+void DirectJavaLaunch::proceed()
+{
+ // nil
+}
+
+bool DirectJavaLaunch::abort()
+{
+ auto state = m_process.state();
+ if (state == LoggedProcess::Running || state == LoggedProcess::Starting)
+ {
+ m_process.kill();
+ }
+ return true;
+}
+
diff --git a/api/logic/minecraft/launch/DirectJavaLaunch.h b/api/logic/minecraft/launch/DirectJavaLaunch.h
new file mode 100644
index 00000000..0e3d66cc
--- /dev/null
+++ b/api/logic/minecraft/launch/DirectJavaLaunch.h
@@ -0,0 +1,47 @@
+/* Copyright 2013-2015 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <launch/LaunchStep.h>
+#include <launch/LoggedProcess.h>
+#include <minecraft/auth/AuthSession.h>
+
+class DirectJavaLaunch: public LaunchStep
+{
+ Q_OBJECT
+public:
+ explicit DirectJavaLaunch(LaunchTask *parent);
+ virtual void executeTask();
+ virtual bool abort();
+ virtual void proceed();
+ virtual bool canAbort() const
+ {
+ return true;
+ }
+ void setWorkingDirectory(const QString &wd);
+ void setAuthSession(AuthSessionPtr session)
+ {
+ m_session = session;
+ }
+private slots:
+ void on_state(LoggedProcess::State state);
+
+private:
+ LoggedProcess m_process;
+ QString m_command;
+ AuthSessionPtr m_session;
+};
+
diff --git a/api/logic/minecraft/launch/ExtractNatives.cpp b/api/logic/minecraft/launch/ExtractNatives.cpp
new file mode 100644
index 00000000..089e2559
--- /dev/null
+++ b/api/logic/minecraft/launch/ExtractNatives.cpp
@@ -0,0 +1,86 @@
+/* Copyright 2013-2016 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ExtractNatives.h"
+#include <minecraft/MinecraftInstance.h>
+#include <launch/LaunchTask.h>
+
+#include <quazip.h>
+#include <JlCompress.h>
+#include <quazipdir.h>
+#include "MMCZip.h"
+#include "FileSystem.h"
+#include <QDir>
+
+static QString replaceSuffix (QString target, const QString &suffix, const QString &replacement)
+{
+ if (!target.endsWith(suffix))
+ {
+ return target;
+ }
+ target.resize(target.length() - suffix.length());
+ return target + replacement;
+}
+
+static bool unzipNatives(QString source, QString targetFolder, bool applyJnilibHack)
+{
+ QuaZip zip(source);
+ if(!zip.open(QuaZip::mdUnzip))
+ {
+ return false;
+ }
+ QDir directory(targetFolder);
+ if (!zip.goToFirstFile())
+ {
+ return false;
+ }
+ do
+ {
+ QString name = zip.getCurrentFileName();
+ if(applyJnilibHack)
+ {
+ name = replaceSuffix(name, ".jnilib", ".dylib");
+ }
+ QString absFilePath = directory.absoluteFilePath(name);
+ if (!MMCZip::extractFile(&zip, "", absFilePath))
+ {
+ return false;
+ }
+ } while (zip.goToNextFile());
+ zip.close();
+ if(zip.getZipError()!=0)
+ {
+ return false;
+ }
+ return true;
+}
+
+void ExtractNatives::executeTask()
+{
+ auto instance = m_parent->instance();
+ std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);
+ auto outputPath = minecraftInstance->getNativePath();
+ auto toExtract = minecraftInstance->getNativeJars();
+ auto javaVersion = minecraftInstance->getJavaVersion();
+ bool jniHackEnabled = javaVersion.major() >= 8;
+ for(const auto &source: toExtract)
+ {
+ if(!unzipNatives(source, outputPath, jniHackEnabled))
+ {
+ emitFailed(tr("Couldn't extract native jar '%1' to destination '%2'").arg(source, outputPath));
+ }
+ }
+ emitSucceeded();
+}
diff --git a/api/logic/minecraft/launch/ExtractNatives.h b/api/logic/minecraft/launch/ExtractNatives.h
new file mode 100644
index 00000000..699657d7
--- /dev/null
+++ b/api/logic/minecraft/launch/ExtractNatives.h
@@ -0,0 +1,37 @@
+/* Copyright 2013-2016 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <launch/LaunchStep.h>
+#include <memory>
+#include "minecraft/auth/AuthSession.h"
+
+// FIXME: temporary wrapper for existing task.
+class ExtractNatives: public LaunchStep
+{
+ Q_OBJECT
+public:
+ explicit ExtractNatives(LaunchTask *parent) : LaunchStep(parent){};
+ virtual ~ExtractNatives(){};
+
+ virtual void executeTask();
+ virtual bool canAbort() const
+ {
+ return false;
+ }
+};
+
+
diff --git a/api/logic/minecraft/launch/LaunchMinecraft.cpp b/api/logic/minecraft/launch/LauncherPartLaunch.cpp
index 9b8cc0fb..5f233700 100644
--- a/api/logic/minecraft/launch/LaunchMinecraft.cpp
+++ b/api/logic/minecraft/launch/LauncherPartLaunch.cpp
@@ -13,25 +13,25 @@
* limitations under the License.
*/
-#include "LaunchMinecraft.h"
+#include "LauncherPartLaunch.h"
+#include <QCoreApplication>
#include <launch/LaunchTask.h>
#include <minecraft/MinecraftInstance.h>
#include <FileSystem.h>
#include <QStandardPaths>
-LaunchMinecraft::LaunchMinecraft(LaunchTask *parent) : LaunchStep(parent)
+LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent)
{
- connect(&m_process, &LoggedProcess::log, this, &LaunchMinecraft::logLines);
- connect(&m_process, &LoggedProcess::stateChanged, this, &LaunchMinecraft::on_state);
+ connect(&m_process, &LoggedProcess::log, this, &LauncherPartLaunch::logLines);
+ connect(&m_process, &LoggedProcess::stateChanged, this, &LauncherPartLaunch::on_state);
}
-void LaunchMinecraft::executeTask()
+void LauncherPartLaunch::executeTask()
{
auto instance = m_parent->instance();
std::shared_ptr<MinecraftInstance> minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(instance);
m_launchScript = minecraftInstance->createLaunchScript(m_session);
-
QStringList args = minecraftInstance->javaArguments();
// HACK: this is a workaround for MCL-3732 - 'server-resource-packs' is created.
@@ -47,6 +47,8 @@ void LaunchMinecraft::executeTask()
m_process.setProcessEnvironment(instance->createEnvironment());
+ args << "-jar" << FS::PathCombine(QCoreApplication::applicationDirPath(), "jars", "NewLaunch.jar");
+
QString wrapperCommand = instance->getWrapperCommand();
if(!wrapperCommand.isEmpty())
{
@@ -68,7 +70,7 @@ void LaunchMinecraft::executeTask()
}
}
-void LaunchMinecraft::on_state(LoggedProcess::State state)
+void LauncherPartLaunch::on_state(LoggedProcess::State state)
{
switch(state)
{
@@ -120,12 +122,12 @@ void LaunchMinecraft::on_state(LoggedProcess::State state)
}
}
-void LaunchMinecraft::setWorkingDirectory(const QString &wd)
+void LauncherPartLaunch::setWorkingDirectory(const QString &wd)
{
m_process.setWorkingDirectory(wd);
}
-void LaunchMinecraft::proceed()
+void LauncherPartLaunch::proceed()
{
if(mayProceed)
{
@@ -135,7 +137,7 @@ void LaunchMinecraft::proceed()
}
}
-bool LaunchMinecraft::abort()
+bool LauncherPartLaunch::abort()
{
if(mayProceed)
{
diff --git a/api/logic/minecraft/launch/LaunchMinecraft.h b/api/logic/minecraft/launch/LauncherPartLaunch.h
index 6b9f7919..209902e0 100644
--- a/api/logic/minecraft/launch/LaunchMinecraft.h
+++ b/api/logic/minecraft/launch/LauncherPartLaunch.h
@@ -19,11 +19,11 @@
#include <launch/LoggedProcess.h>
#include <minecraft/auth/AuthSession.h>
-class LaunchMinecraft: public LaunchStep
+class LauncherPartLaunch: public LaunchStep
{
Q_OBJECT
public:
- explicit LaunchMinecraft(LaunchTask *parent);
+ explicit LauncherPartLaunch(LaunchTask *parent);
virtual void executeTask();
virtual bool abort();
virtual void proceed();
@@ -36,13 +36,14 @@ public:
{
m_session = session;
}
+
private slots:
void on_state(LoggedProcess::State state);
private:
LoggedProcess m_process;
QString m_command;
- QString m_launchScript;
AuthSessionPtr m_session;
+ QString m_launchScript;
bool mayProceed = false;
};
diff --git a/api/logic/minecraft/launch/PrintInstanceInfo.cpp b/api/logic/minecraft/launch/PrintInstanceInfo.cpp
new file mode 100644
index 00000000..b863eb98
--- /dev/null
+++ b/api/logic/minecraft/launch/PrintInstanceInfo.cpp
@@ -0,0 +1,25 @@
+/* Copyright 2013-2016 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "PrintInstanceInfo.h"
+#include <launch/LaunchTask.h>
+
+void PrintInstanceInfo::executeTask()
+{
+ auto instance = m_parent->instance();
+ auto lines = instance->verboseDescription(m_session);
+ logLines(lines, MessageLevel::MultiMC);
+ emitSucceeded();
+}
diff --git a/api/logic/minecraft/launch/PrintInstanceInfo.h b/api/logic/minecraft/launch/PrintInstanceInfo.h
new file mode 100644
index 00000000..5dd2bdb3
--- /dev/null
+++ b/api/logic/minecraft/launch/PrintInstanceInfo.h
@@ -0,0 +1,38 @@
+/* Copyright 2013-2016 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <launch/LaunchStep.h>
+#include <memory>
+#include "minecraft/auth/AuthSession.h"
+
+// FIXME: temporary wrapper for existing task.
+class PrintInstanceInfo: public LaunchStep
+{
+ Q_OBJECT
+public:
+ explicit PrintInstanceInfo(LaunchTask *parent, AuthSessionPtr session) : LaunchStep(parent), m_session(session) {};
+ virtual ~PrintInstanceInfo(){};
+
+ virtual void executeTask();
+ virtual bool canAbort() const
+ {
+ return false;
+ }
+private:
+ AuthSessionPtr m_session;
+};
+
diff --git a/api/logic/minecraft/legacy/LegacyInstance.cpp b/api/logic/minecraft/legacy/LegacyInstance.cpp
index 28fd8872..7c552369 100644
--- a/api/logic/minecraft/legacy/LegacyInstance.cpp
+++ b/api/logic/minecraft/legacy/LegacyInstance.cpp
@@ -14,6 +14,7 @@
*/
#include <QFileInfo>
+#include <minecraft/launch/LauncherPartLaunch.h>
#include <QDir>
#include <settings/Setting.h>
@@ -21,14 +22,6 @@
#include "minecraft/legacy/LegacyUpdate.h"
#include "minecraft/legacy/LegacyModList.h"
-#include "launch/LaunchTask.h"
-#include <launch/steps/PostLaunchCommand.h>
-#include <launch/steps/Update.h>
-#include <launch/steps/PreLaunchCommand.h>
-#include <launch/steps/TextPrint.h>
-#include "minecraft/launch/LaunchMinecraft.h"
-#include "minecraft/launch/ModMinecraftJar.h"
-#include "java/launch/CheckJava.h"
#include "minecraft/ModList.h"
#include "minecraft/WorldList.h"
#include <MMCZip.h>
@@ -102,58 +95,6 @@ std::shared_ptr<Task> LegacyInstance::createUpdateTask()
return std::shared_ptr<Task>(new LegacyUpdate(this, this));
}
-std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr session)
-{
- auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr()));
- auto pptr = process.get();
-
- // print a header
- {
- process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + minecraftRoot() + "\n\n", MessageLevel::MultiMC));
- }
- {
- auto step = std::make_shared<CheckJava>(pptr);
- process->appendStep(step);
- }
- // run pre-launch command if that's needed
- if(getPreLaunchCommand().size())
- {
- auto step = std::make_shared<PreLaunchCommand>(pptr);
- step->setWorkingDirectory(minecraftRoot());
- process->appendStep(step);
- }
- // if we aren't in offline mode,.
- if(session->status != AuthSession::PlayableOffline)
- {
- process->appendStep(std::make_shared<Update>(pptr));
- }
- // if there are any jar mods
- if(getJarMods().size())
- {
- auto step = std::make_shared<ModMinecraftJar>(pptr);
- process->appendStep(step);
- }
- // actually launch the game
- {
- auto step = std::make_shared<LaunchMinecraft>(pptr);
- step->setWorkingDirectory(minecraftRoot());
- step->setAuthSession(session);
- process->appendStep(step);
- }
- // run post-exit command if that's needed
- if(getPostExitCommand().size())
- {
- auto step = std::make_shared<PostLaunchCommand>(pptr);
- step->setWorkingDirectory(minecraftRoot());
- process->appendStep(step);
- }
- if (session)
- {
- process->setCensorFilter(createCensorFilterFromSession(session));
- }
- return process;
-}
-
std::shared_ptr<Task> LegacyInstance::createJarModdingTask()
{
class JarModTask : public Task
@@ -255,11 +196,35 @@ QString LegacyInstance::createLaunchScript(AuthSessionPtr session)
launchScript += "sessionId " + session->session + "\n";
launchScript += "windowTitle " + windowTitle() + "\n";
launchScript += "windowParams " + windowParams + "\n";
- launchScript += "lwjgl " + lwjgl + "\n";
- launchScript += "launcher legacy\n";
+ launchScript += "cp bin/minecraft.jar\n";
+ launchScript += "cp " + lwjgl + "/lwjgl.jar\n";
+ launchScript += "cp " + lwjgl + "/lwjgl_util.jar\n";
+ launchScript += "cp " + lwjgl + "/jinput.jar\n";
+ launchScript += "natives " + lwjgl + "/natives\n";
+ launchScript += "traits legacyLaunch\n";
+ launchScript += "launcher onesix\n";
return launchScript;
}
+std::shared_ptr<LaunchStep> LegacyInstance::createMainLaunchStep(LaunchTask * parent, AuthSessionPtr session)
+{
+ auto step = std::make_shared<LauncherPartLaunch>(parent);
+ step->setWorkingDirectory(minecraftRoot());
+ step->setAuthSession(session);
+ return step;
+}
+
+QString LegacyInstance::launchMethod()
+{
+ return "Legacy";
+}
+
+QStringList LegacyInstance::validLaunchMethods()
+{
+ return {"Legacy"};
+}
+
+
void LegacyInstance::cleanupAfterRun()
{
// FIXME: delete the launcher