예제 #1
0
QString BaseInstance::minecraftRoot() const
{
	QFileInfo mcDir(PathCombine(instanceRoot(), "minecraft"));
	QFileInfo dotMCDir(PathCombine(instanceRoot(), ".minecraft"));

	if (dotMCDir.exists() && !mcDir.exists())
		return dotMCDir.filePath();
	else
		return mcDir.filePath();
}
예제 #2
0
bool OneSixInstance::setIntendedVersionId(QString version)
{
	settings().set("IntendedVersion", version);
	setShouldUpdate(true);
	auto pathCustom = PathCombine(instanceRoot(), "custom.json");
	auto pathOrig = PathCombine(instanceRoot(), "version.json");
	QFile::remove(pathCustom);
	QFile::remove(pathOrig);
	reloadFullVersion();
	return true;
}
예제 #3
0
bool OneSixInstance::customizeVersion()
{
	if (!versionIsCustom())
	{
		auto pathCustom = PathCombine(instanceRoot(), "custom.json");
		auto pathOrig = PathCombine(instanceRoot(), "version.json");
		QFile::copy(pathOrig, pathCustom);
		return reloadFullVersion();
	}
	else
		return true;
}
예제 #4
0
bool OneSixInstance::revertCustomVersion()
{
	if (versionIsCustom())
	{
		auto path = PathCombine(instanceRoot(), "custom.json");
		QFile::remove(path);
		return reloadFullVersion();
	}
	else
		return true;
}
예제 #5
0
bool OneSixInstance::reloadFullVersion()
{
	I_D(OneSixInstance);

	QString verpath = PathCombine(instanceRoot(), "version.json");
	{
		QString verpath_custom = PathCombine(instanceRoot(), "custom.json");
		QFile versionfile(verpath_custom);
		if (versionfile.exists())
			verpath = verpath_custom;
	}

	auto version = OneSixVersion::fromFile(verpath);
	if (version)
	{
		d->version = version;
		return true;
	}
	else
	{
		d->version.reset();
		return false;
	}
}
예제 #6
0
bool OneSixInstance::reloadFullVersion()
{
	I_D(OneSixInstance);
	
	QString verpath = PathCombine(instanceRoot(), "version.json");
	QFile versionfile(verpath);
	if(versionfile.exists() && versionfile.open(QIODevice::ReadOnly))
	{
		FullVersionFactory fvf;
		auto version = fvf.parse(versionfile.readAll());
		versionfile.close();
		if(version)
		{
			d->version = version;
			return true;
		}
	};
	return false;
}
예제 #7
0
void OneSixUpdate::prepareForLaunch()
{
	setStatus(tr("Preparing for launch..."));
	QLOG_INFO() << m_inst->name() << ": preparing for launch";
	auto onesix_inst = (OneSixInstance *)m_inst;

	// delete any leftovers, if they are present.
	onesix_inst->cleanupAfterRun();

	QString natives_dir_raw = PathCombine(onesix_inst->instanceRoot(), "natives/");
	auto version = onesix_inst->getFullVersion();
	if (!version)
	{
		emitFailed("The version information for this instance is not complete. Try re-creating "
				   "it or changing the version.");
		return;
	}
	/*
	for (auto lib : version->getActiveNativeLibs())
	{
		if (!lib->filesExist())
		{
			emitFailed("Native library is missing some files:\n" + lib->storagePath() +
					   "\n\nRun the instance at least once in online mode to get all the "
					   "required files.");
			return;
		}
		if (!lib->extractTo(natives_dir_raw))
		{
			emitFailed("Could not extract the native library:\n" + lib->storagePath() + " to " +
					   natives_dir_raw +
					   "\n\nMake sure MultiMC has appropriate permissions and there is enough "
					   "space on the storage device.");
			return;
		}
	}
*/
	emitSucceeded();
}
예제 #8
0
MinecraftProcess* OneSixInstance::prepareForLaunch ( QString user, QString session )
{
	I_D(OneSixInstance);
	cleanupAfterRun();
	auto version = d->version;
	if(!version)
		return nullptr;
	auto libs_to_extract = version->getActiveNativeLibs();
	QString natives_dir_raw = PathCombine(instanceRoot(), "natives/");
	bool success = ensureFolderPathExists(natives_dir_raw);
	if(!success)
	{
		// FIXME: handle errors
		return nullptr;
	}
	
	for(auto lib: libs_to_extract)
	{
		QString path = "libraries/" + lib->storagePath();
		qDebug() << "Will extract " << path.toLocal8Bit();
		if(JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes).isEmpty())
		{
			return nullptr;
		}
	}

	QStringList args;
	args.append(Util::Commandline::splitArgs(settings().get("JvmArgs").toString()));
	args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt());
	args << QString("-Xmx%1m").arg(settings().get("MaxMemAlloc").toInt());
	args << QString("-XX:PermSize=%1m").arg(settings().get("PermGen").toInt());
	QDir natives_dir(natives_dir_raw);
	args << QString("-Djava.library.path=%1").arg( natives_dir.absolutePath() );
	QString classPath;
	{
		auto libs = version->getActiveNormalLibs();
		for (auto lib: libs)
		{
			QFileInfo fi(QString("libraries/") + lib->storagePath());
			classPath.append(fi.absoluteFilePath());
#ifdef Q_OS_WIN32
			classPath.append(';');
#else
			classPath.append(':');
#endif
		}
		QString targetstr = "versions/" + version->id + "/" + version->id + ".jar";
		QFileInfo fi(targetstr);
		classPath.append(fi.absoluteFilePath());
	}
	if(classPath.size())
	{
		args << "-cp";
		args << classPath;
	}
	args << version->mainClass;
	args.append(processMinecraftArgs(user, session));
	
	// create the process and set its parameters
	MinecraftProcess * proc = new MinecraftProcess(this);
	proc->setMinecraftArguments(args);
	proc->setMinecraftWorkdir(minecraftRoot());
	return proc;
}
예제 #9
0
QString OneSixInstance::defaultCustomBaseJar() const
{
	return PathCombine(instanceRoot(), "custom.jar");
}
예제 #10
0
void OneSixInstance::cleanupAfterRun()
{
	QString target_dir = PathCombine(instanceRoot(), "natives/");
	QDir dir(target_dir);
	dir.removeRecursively();
}
예제 #11
0
QString LegacyInstance::modListFile() const
{
	return PathCombine(instanceRoot(), "modlist");
}
예제 #12
0
QString LegacyInstance::jarModsDir() const
{
	return PathCombine(instanceRoot(), "instMods");
}
예제 #13
0
QString BaseInstance::id() const
{
	return QFileInfo(instanceRoot()).fileName();
}
예제 #14
0
void BaseInstance::nuke()
{
	QDir(instanceRoot()).removeRecursively();
	emit nuked(this);
}
예제 #15
0
MinecraftProcess *OneSixInstance::prepareForLaunch(LoginResponse response)
{
	I_D(OneSixInstance);
	cleanupAfterRun();
	auto version = d->version;
	if (!version)
		return nullptr;
	auto libs_to_extract = version->getActiveNativeLibs();
	QString natives_dir_raw = PathCombine(instanceRoot(), "natives/");
	bool success = ensureFolderPathExists(natives_dir_raw);
	if (!success)
	{
		// FIXME: handle errors
		return nullptr;
	}

	for (auto lib : libs_to_extract)
	{
		QString path = "libraries/" + lib->storagePath();
		QLOG_INFO() << "Will extract " << path.toLocal8Bit();
		if (JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes)
				.isEmpty())
		{
			return nullptr;
		}
	}

	QStringList args;
	args.append(Util::Commandline::splitArgs(settings().get("JvmArgs").toString()));
	args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt());
	args << QString("-Xmx%1m").arg(settings().get("MaxMemAlloc").toInt());
	args << QString("-XX:PermSize=%1m").arg(settings().get("PermGen").toInt());

/**
 * HACK: Stupid hack for Intel drivers.
 * See: https://mojang.atlassian.net/browse/MCL-767
 */
#ifdef Q_OS_WIN32
	args << QString("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_"
					"minecraft.exe.heapdump");
#endif

	QDir natives_dir(natives_dir_raw);
	args << QString("-Djava.library.path=%1").arg(natives_dir.absolutePath());
	QString classPath;
	{
		auto libs = version->getActiveNormalLibs();
		for (auto lib : libs)
		{
			QFileInfo fi(QString("libraries/") + lib->storagePath());
			classPath.append(fi.absoluteFilePath());
#ifdef Q_OS_WIN32
			classPath.append(';');
#else
			classPath.append(':');
#endif
		}
		QString targetstr = "versions/" + version->id + "/" + version->id + ".jar";
		QFileInfo fi(targetstr);
		classPath.append(fi.absoluteFilePath());
	}
	if (classPath.size())
	{
		args << "-cp";
		args << classPath;
	}
	args << version->mainClass;
	args.append(processMinecraftArgs(response));

	// Set the width and height for 1.6 instances
	bool maximize = settings().get("LaunchMaximized").toBool();
	if (maximize)
	{
		// this is probably a BAD idea
		// args << QString("--fullscreen");
	}
	else
	{
		args << QString("--width") << settings().get("MinecraftWinWidth").toString();
		args << QString("--height") << settings().get("MinecraftWinHeight").toString();
	}

	// create the process and set its parameters
	MinecraftProcess *proc = new MinecraftProcess(this);
	proc->setMinecraftArguments(args);
	proc->setMinecraftWorkdir(minecraftRoot());
	return proc;
}
예제 #16
0
bool OneSixInstance::versionIsCustom()
{
	QString verpath_custom = PathCombine(instanceRoot(), "custom.json");
	QFile versionfile(verpath_custom);
	return versionfile.exists();
}