Merge branch 'develop' into env-vars
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
|
||||
* Copyright (c) 2023 seth <getchoo at tuta dot io>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -190,6 +191,10 @@ void MinecraftInstance::loadSpecificSettings()
|
||||
m_settings->registerSetting("OverrideEnv", false);
|
||||
m_settings->registerSetting("Env", QVariant(QMap<QString, QVariant>()));
|
||||
|
||||
// Mod loader specific options
|
||||
auto modLoaderSettings = m_settings->registerSetting("OverrideModLoaderSettings", false);
|
||||
m_settings->registerOverride(global_settings->getSetting("DisableQuiltBeacon"), modLoaderSettings);
|
||||
|
||||
m_settings->set("InstanceType", "OneSix");
|
||||
}
|
||||
|
||||
@ -395,6 +400,12 @@ QStringList MinecraftInstance::extraArguments()
|
||||
agent->library()->getApplicableFiles(runtimeContext(), jar, temp1, temp2, temp3, getLocalLibraryPath());
|
||||
list.append("-javaagent:"+jar[0]+(agent->argument().isEmpty() ? "" : "="+agent->argument()));
|
||||
}
|
||||
|
||||
{
|
||||
const auto loaders = version->getModLoaders();
|
||||
if (loaders.has_value() && loaders.value() & ResourceAPI::Quilt && settings()->get("DisableQuiltBeacon").toBool())
|
||||
list.append("-Dloader.disable_beacon=true");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ bool AuthSession::MakeOffline(QString offline_playername)
|
||||
return false;
|
||||
}
|
||||
session = "-";
|
||||
access_token = "0";
|
||||
player_name = offline_playername;
|
||||
status = PlayableOffline;
|
||||
return true;
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include "MinecraftAccount.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QUuid>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
@ -100,7 +101,7 @@ MinecraftAccountPtr MinecraftAccount::createOffline(const QString &username)
|
||||
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]"));
|
||||
account->data.minecraftEntitlement.ownsMinecraft = true;
|
||||
account->data.minecraftEntitlement.canPlayMinecraft = true;
|
||||
account->data.minecraftProfile.id = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]"));
|
||||
account->data.minecraftProfile.id = uuidFromUsername(username).toString().remove(QRegularExpression("[{}-]"));
|
||||
account->data.minecraftProfile.name = username;
|
||||
account->data.minecraftProfile.validity = Katabasis::Validity::Certain;
|
||||
return account;
|
||||
@ -334,3 +335,32 @@ void MinecraftAccount::incrementUses()
|
||||
qWarning() << "Profile" << data.profileId() << "is now in use.";
|
||||
}
|
||||
}
|
||||
|
||||
QUuid MinecraftAccount::uuidFromUsername(QString username) {
|
||||
auto input = QString("OfflinePlayer:%1").arg(username).toUtf8();
|
||||
|
||||
// basically a reimplementation of Java's UUID#nameUUIDFromBytes
|
||||
QByteArray digest = QCryptographicHash::hash(input, QCryptographicHash::Md5);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
auto bOr = [](QByteArray& array, int index, char value) {
|
||||
array[index] = array.at(index) | value;
|
||||
};
|
||||
auto bAnd = [](QByteArray& array, int index, char value) {
|
||||
array[index] = array.at(index) & value;
|
||||
};
|
||||
#else
|
||||
auto bOr = [](QByteArray& array, qsizetype index, char value) {
|
||||
array[index] |= value;
|
||||
};
|
||||
auto bAnd = [](QByteArray& array, qsizetype index, char value) {
|
||||
array[index] &= value;
|
||||
};
|
||||
#endif
|
||||
bAnd(digest, 6, (char) 0x0f); // clear version
|
||||
bOr(digest, 6, (char) 0x30); // set to version 3
|
||||
bAnd(digest, 8, (char) 0x3f); // clear variant
|
||||
bOr(digest, 8, (char) 0x80); // set to IETF variant
|
||||
|
||||
return QUuid::fromRfc4122(digest);
|
||||
}
|
||||
|
@ -98,6 +98,8 @@ public: /* construction */
|
||||
static MinecraftAccountPtr loadFromJsonV2(const QJsonObject &json);
|
||||
static MinecraftAccountPtr loadFromJsonV3(const QJsonObject &json);
|
||||
|
||||
static QUuid uuidFromUsername(QString username);
|
||||
|
||||
//! Saves a MinecraftAccount to a JSON object and returns it.
|
||||
QJsonObject saveToJson() const;
|
||||
|
||||
|
@ -44,7 +44,11 @@ static const QMap<PackedResourceType, QString> s_packed_type_names = {
|
||||
namespace ResourceUtils {
|
||||
PackedResourceType identify(QFileInfo file){
|
||||
if (file.exists() && file.isFile()) {
|
||||
if (ResourcePackUtils::validate(file)) {
|
||||
if (ModUtils::validate(file)) {
|
||||
// mods can contain resource and data packs so they must be tested first
|
||||
qDebug() << file.fileName() << "is a mod";
|
||||
return PackedResourceType::Mod;
|
||||
} else if (ResourcePackUtils::validate(file)) {
|
||||
qDebug() << file.fileName() << "is a resource pack";
|
||||
return PackedResourceType::ResourcePack;
|
||||
} else if (TexturePackUtils::validate(file)) {
|
||||
@ -53,9 +57,6 @@ PackedResourceType identify(QFileInfo file){
|
||||
} else if (DataPackUtils::validate(file)) {
|
||||
qDebug() << file.fileName() << "is a data pack";
|
||||
return PackedResourceType::DataPack;
|
||||
} else if (ModUtils::validate(file)) {
|
||||
qDebug() << file.fileName() << "is a mod";
|
||||
return PackedResourceType::Mod;
|
||||
} else if (WorldSaveUtils::validate(file)) {
|
||||
qDebug() << file.fileName() << "is a world save";
|
||||
return PackedResourceType::WorldSave;
|
||||
|
Reference in New Issue
Block a user