Add ability to change assets download server (#3875)

This commit is contained in:
timoreo
2025-07-18 09:14:45 +02:00
committed by GitHub
6 changed files with 67 additions and 3 deletions

View File

@@ -298,7 +298,8 @@ QString AssetObject::getLocalPath()
QUrl AssetObject::getUrl()
{
return BuildConfig.RESOURCE_BASE + getRelPath();
auto resourceURL = APPLICATION->settings()->get("ResourceURL").toString();
return resourceURL + getRelPath();
}
QString AssetObject::getRelPath()

View File

@@ -1,5 +1,6 @@
#include "AssetUpdateTask.h"
#include "BuildConfig.h"
#include "launch/LaunchStep.h"
#include "minecraft/AssetsUtils.h"
#include "minecraft/MinecraftInstance.h"
@@ -71,7 +72,12 @@ void AssetUpdateTask::assetIndexFinished()
auto job = index.getDownloadJob();
if (job) {
setStatus(tr("Getting the assets files from Mojang..."));
QString resourceURL = APPLICATION->settings()->get("ResourceURL").toString();
QString source = tr("Mojang");
if (resourceURL != BuildConfig.DEFAULT_RESOURCE_BASE) {
source = QUrl(resourceURL).host();
}
setStatus(tr("Getting the assets files from %1...").arg(source));
downloadJob = job;
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);