aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--launcher/CMakeLists.txt14
-rw-r--r--launcher/FileSystem.cpp16
-rw-r--r--launcher/FileSystem.h8
-rw-r--r--launcher/minecraft/mod/DataPack.cpp108
-rw-r--r--launcher/minecraft/mod/DataPack.h73
-rw-r--r--launcher/minecraft/mod/Mod.cpp10
-rw-r--r--launcher/minecraft/mod/Mod.h3
-rw-r--r--launcher/minecraft/mod/ModDetails.h6
-rw-r--r--launcher/minecraft/mod/ResourcePack.cpp13
-rw-r--r--launcher/minecraft/mod/ShaderPack.cpp37
-rw-r--r--launcher/minecraft/mod/ShaderPack.h62
-rw-r--r--launcher/minecraft/mod/WorldSave.cpp43
-rw-r--r--launcher/minecraft/mod/WorldSave.h61
-rw-r--r--launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp177
-rw-r--r--launcher/minecraft/mod/tasks/LocalDataPackParseTask.h65
-rw-r--r--launcher/minecraft/mod/tasks/LocalModParseTask.cpp143
-rw-r--r--launcher/minecraft/mod/tasks/LocalModParseTask.h34
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp110
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h8
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourceParse.cpp60
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourceParse.h31
-rw-r--r--launcher/minecraft/mod/tasks/LocalShaderPackParseTask.cpp113
-rw-r--r--launcher/minecraft/mod/tasks/LocalShaderPackParseTask.h62
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp59
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h8
-rw-r--r--launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.cpp190
-rw-r--r--launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.h62
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.cpp148
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.h3
-rw-r--r--tests/CMakeLists.txt9
-rw-r--r--tests/DataPackParse_test.cpp79
-rw-r--r--tests/ResourcePackParse_test.cpp9
-rw-r--r--tests/ShaderPackParse_test.cpp77
-rw-r--r--tests/TexturePackParse_test.cpp9
-rw-r--r--tests/WorldSaveParse_test.cpp94
-rw-r--r--tests/testdata/DataPackParse/another_test_folder/data/dummy/tags/item/foo_proof/bar.json1
-rw-r--r--tests/testdata/DataPackParse/another_test_folder/pack.mcmeta6
-rw-r--r--tests/testdata/DataPackParse/test_data_pack_boogaloo.zipbin0 -> 898 bytes
-rw-r--r--tests/testdata/DataPackParse/test_folder/data/dummy/tags/item/foo_proof/bar.json1
-rw-r--r--tests/testdata/DataPackParse/test_folder/pack.mcmeta6
-rw-r--r--tests/testdata/ResourcePackParse/test_resource_pack_idk.zipbin322 -> 804 bytes
-rw-r--r--tests/testdata/ShaderPackParse/shaderpack1.zipbin0 -> 242 bytes
-rw-r--r--tests/testdata/ShaderPackParse/shaderpack2/shaders/shaders.properties0
-rw-r--r--tests/testdata/ShaderPackParse/shaderpack3.zipbin0 -> 128 bytes
-rw-r--r--tests/testdata/WorldSaveParse/minecraft_save_1.zipbin0 -> 184 bytes
-rw-r--r--tests/testdata/WorldSaveParse/minecraft_save_2.zipbin0 -> 352 bytes
-rw-r--r--tests/testdata/WorldSaveParse/minecraft_save_3/world_3/level.dat0
-rw-r--r--tests/testdata/WorldSaveParse/minecraft_save_4/saves/world_4/level.dat0
48 files changed, 1857 insertions, 161 deletions
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 6ca88ec6..8b5c63ff 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -331,12 +331,18 @@ set(MINECRAFT_SOURCES
minecraft/mod/Resource.cpp
minecraft/mod/ResourceFolderModel.h
minecraft/mod/ResourceFolderModel.cpp
+ minecraft/mod/DataPack.h
+ minecraft/mod/DataPack.cpp
minecraft/mod/ResourcePack.h
minecraft/mod/ResourcePack.cpp
minecraft/mod/ResourcePackFolderModel.h
minecraft/mod/ResourcePackFolderModel.cpp
minecraft/mod/TexturePack.h
minecraft/mod/TexturePack.cpp
+ minecraft/mod/ShaderPack.h
+ minecraft/mod/ShaderPack.cpp
+ minecraft/mod/WorldSave.h
+ minecraft/mod/WorldSave.cpp
minecraft/mod/TexturePackFolderModel.h
minecraft/mod/TexturePackFolderModel.cpp
minecraft/mod/ShaderPackFolderModel.h
@@ -347,10 +353,18 @@ set(MINECRAFT_SOURCES
minecraft/mod/tasks/LocalModParseTask.cpp
minecraft/mod/tasks/LocalModUpdateTask.h
minecraft/mod/tasks/LocalModUpdateTask.cpp
+ minecraft/mod/tasks/LocalDataPackParseTask.h
+ minecraft/mod/tasks/LocalDataPackParseTask.cpp
minecraft/mod/tasks/LocalResourcePackParseTask.h
minecraft/mod/tasks/LocalResourcePackParseTask.cpp
minecraft/mod/tasks/LocalTexturePackParseTask.h
minecraft/mod/tasks/LocalTexturePackParseTask.cpp
+ minecraft/mod/tasks/LocalShaderPackParseTask.h
+ minecraft/mod/tasks/LocalShaderPackParseTask.cpp
+ minecraft/mod/tasks/LocalWorldSaveParseTask.h
+ minecraft/mod/tasks/LocalWorldSaveParseTask.cpp
+ minecraft/mod/tasks/LocalResourceParse.h
+ minecraft/mod/tasks/LocalResourceParse.cpp
# Assets
minecraft/AssetsUtils.h
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index b3af4f4e..7a135811 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -214,6 +214,22 @@ bool copy::operator()(const QString& offset, bool dryRun)
return err.value() == 0;
}
+bool move(const QString& source, const QString& dest)
+{
+ std::error_code err;
+
+ ensureFilePathExists(dest);
+ fs::rename(StringUtils::toStdString(source), StringUtils::toStdString(dest), err);
+
+ if (err) {
+ qWarning() << "Failed to move file:" << QString::fromStdString(err.message());
+ qDebug() << "Source file:" << source;
+ qDebug() << "Destination file:" << dest;
+ }
+
+ return err.value() == 0;
+}
+
bool deletePath(QString path)
{
std::error_code err;
diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h
index 15233b66..f083f3c7 100644
--- a/launcher/FileSystem.h
+++ b/launcher/FileSystem.h
@@ -123,6 +123,14 @@ class copy : public QObject {
};
/**
+ * @brief moves a file by renaming it
+ * @param source source file path
+ * @param dest destination filepath
+ *
+ */
+bool move(const QString& source, const QString& dest);
+
+/**
* Delete a folder recursively
*/
bool deletePath(QString path);
diff --git a/launcher/minecraft/mod/DataPack.cpp b/launcher/minecraft/mod/DataPack.cpp
new file mode 100644
index 00000000..5c58f6b2
--- /dev/null
+++ b/launcher/minecraft/mod/DataPack.cpp
@@ -0,0 +1,108 @@
+// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "DataPack.h"
+
+#include <QDebug>
+#include <QMap>
+#include <QRegularExpression>
+
+#include "Version.h"
+
+// Values taken from:
+// https://minecraft.fandom.com/wiki/Tutorials/Creating_a_data_pack#%22pack_format%22
+static const QMap<int, std::pair<Version, Version>> s_pack_format_versions = {
+ { 4, { Version("1.13"), Version("1.14.4") } }, { 5, { Version("1.15"), Version("1.16.1") } },
+ { 6, { Version("1.16.2"), Version("1.16.5") } }, { 7, { Version("1.17"), Version("1.17.1") } },
+ { 8, { Version("1.18"), Version("1.18.1") } }, { 9, { Version("1.18.2"), Version("1.18.2") } },
+ { 10, { Version("1.19"), Version("1.19.3") } },
+};
+
+void DataPack::setPackFormat(int new_format_id)
+{
+ QMutexLocker locker(&m_data_lock);
+
+ if (!s_pack_format_versions.contains(new_format_id)) {
+ qWarning() << "Pack format '" << new_format_id << "' is not a recognized data pack id!";
+ }
+
+ m_pack_format = new_format_id;
+}
+
+void DataPack::setDescription(QString new_description)
+{
+ QMutexLocker locker(&m_data_lock);
+
+ m_description = new_description;
+}
+
+std::pair<Version, Version> DataPack::compatibleVersions() const
+{
+ if (!s_pack_format_versions.contains(m_pack_format)) {
+ return { {}, {} };
+ }
+
+ return s_pack_format_versions.constFind(m_pack_format).value();
+}
+
+std::pair<int, bool> DataPack::compare(const Resource& other, SortType type) const
+{
+ auto const& cast_other = static_cast<DataPack const&>(other);
+
+ switch (type) {
+ default: {
+ auto res = Resource::compare(other, type);
+ if (res.first != 0)
+ return res;
+ }
+ case SortType::PACK_FORMAT: {
+ auto this_ver = packFormat();
+ auto other_ver = cast_other.packFormat();
+
+ if (this_ver > other_ver)
+ return { 1, type == SortType::PACK_FORMAT };
+ if (this_ver < other_ver)
+ return { -1, type == SortType::PACK_FORMAT };
+ }
+ }
+ return { 0, false };
+}
+
+bool DataPack::applyFilter(QRegularExpression filter) const
+{
+ if (filter.match(description()).hasMatch())
+ return true;
+
+ if (filter.match(QString::number(packFormat())).hasMatch())
+ return true;
+
+ if (filter.match(compatibleVersions().first.toString()).hasMatch())
+ return true;
+ if (filter.match(compatibleVersions().second.toString()).hasMatch())
+ return true;
+
+ return Resource::applyFilter(filter);
+}
+
+bool DataPack::valid() const
+{
+ return m_pack_format != 0;
+}
diff --git a/launcher/minecraft/mod/DataPack.h b/launcher/minecraft/mod/DataPack.h
new file mode 100644
index 00000000..fc2703c7
--- /dev/null
+++ b/launcher/minecraft/mod/DataPack.h
@@ -0,0 +1,73 @@
+// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "Resource.h"
+
+#include <QMutex>
+
+class Version;
+
+/* TODO:
+ *
+ * Store localized descriptions
+ * */
+
+class DataPack : public Resource {
+ Q_OBJECT
+ public:
+ using Ptr = shared_qobject_ptr<Resource>;
+
+ DataPack(QObject* parent = nullptr) : Resource(parent) {}
+ DataPack(QFileInfo file_info) : Resource(file_info) {}
+
+ /** Gets the numerical ID of the pack format. */
+ [[nodiscard]] int packFormat() const { return m_pack_format; }
+ /** Gets, respectively, the lower and upper versions supported by the set pack format. */
+ [[nodiscard]] std::pair<Version, Version> compatibleVersions() const;
+
+ /** Gets the description of the data pack. */
+ [[nodiscard]] QString description() const { return m_description; }
+
+ /** Thread-safe. */
+ void setPackFormat(int new_format_id);
+
+ /** Thread-safe. */
+ void setDescription(QString new_description);
+
+ bool valid() const override;
+
+ [[nodiscard]] auto compare(Resource const& other, SortType type) const -> std::pair<int, bool> override;
+ [[nodiscard]] bool applyFilter(QRegularExpression filter) const override;
+
+ protected:
+ mutable QMutex m_data_lock;
+
+ /* The 'version' of a data pack, as defined in the pack.mcmeta file.
+ * See https://minecraft.fandom.com/wiki/Data_pack#pack.mcmeta
+ */
+ int m_pack_format = 0;
+
+ /** The data pack's description, as defined in the pack.mcmeta file.
+ */
+ QString m_description;
+};
diff --git a/launcher/minecraft/mod/Mod.cpp b/launcher/minecraft/mod/Mod.cpp
index 9cd0056c..c495cd47 100644
--- a/launcher/minecraft/mod/Mod.cpp
+++ b/launcher/minecraft/mod/Mod.cpp
@@ -43,6 +43,7 @@
#include "MetadataHandler.h"
#include "Version.h"
+#include "minecraft/mod/ModDetails.h"
static ModPlatform::ProviderCapabilities ProviderCaps;
@@ -70,6 +71,10 @@ void Mod::setMetadata(std::shared_ptr<Metadata::ModStruct>&& metadata)
m_local_details.metadata = metadata;
}
+void Mod::setDetails(const ModDetails& details) {
+ m_local_details = details;
+}
+
std::pair<int, bool> Mod::compare(const Resource& other, SortType type) const
{
auto cast_other = dynamic_cast<Mod const*>(&other);
@@ -204,3 +209,8 @@ auto Mod::provider() const -> std::optional<QString>
return ProviderCaps.readableName(metadata()->provider);
return {};
}
+
+bool Mod::valid() const
+{
+ return !m_local_details.mod_id.isEmpty();
+}
diff --git a/launcher/minecraft/mod/Mod.h b/launcher/minecraft/mod/Mod.h
index 8185c8fc..c4032538 100644
--- a/launcher/minecraft/mod/Mod.h
+++ b/launcher/minecraft/mod/Mod.h
@@ -71,6 +71,9 @@ public:
void setStatus(ModStatus status);
void setMetadata(std::shared_ptr<Metadata::ModStruct>&& metadata);
void setMetadata(const Metadata::ModStruct& metadata) { setMetadata(std::make_shared<Metadata::ModStruct>(metadata)); }
+ void setDetails(const ModDetails& details);
+
+ bool valid() const override;
[[nodiscard]] auto compare(Resource const& other, SortType type) const -> std::pair<int, bool> override;
[[nodiscard]] bool applyFilter(QRegularExpression filter) const override;
diff --git a/launcher/minecraft/mod/ModDetails.h b/launcher/minecraft/mod/ModDetails.h
index dd84b0a3..176e4fc1 100644
--- a/launcher/minecraft/mod/ModDetails.h
+++ b/launcher/minecraft/mod/ModDetails.h
@@ -81,7 +81,7 @@ struct ModDetails
ModDetails() = default;
/** Metadata should be handled manually to properly set the mod status. */
- ModDetails(ModDetails& other)
+ ModDetails(const ModDetails& other)
: mod_id(other.mod_id)
, name(other.name)
, version(other.version)
@@ -92,7 +92,7 @@ struct ModDetails
, status(other.status)
{}
- ModDetails& operator=(ModDetails& other)
+ ModDetails& operator=(const ModDetails& other)
{
this->mod_id = other.mod_id;
this->name = other.name;
@@ -106,7 +106,7 @@ struct ModDetails
return *this;
}
- ModDetails& operator=(ModDetails&& other)
+ ModDetails& operator=(const ModDetails&& other)
{
this->mod_id = other.mod_id;
this->name = other.name;
diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp
index 3a2fd771..876d5c3e 100644
--- a/launcher/minecraft/mod/ResourcePack.cpp
+++ b/launcher/minecraft/mod/ResourcePack.cpp
@@ -13,11 +13,12 @@
// Values taken from:
// https://minecraft.fandom.com/wiki/Tutorials/Creating_a_resource_pack#Formatting_pack.mcmeta
static const QMap<int, std::pair<Version, Version>> s_pack_format_versions = {
- { 1, { Version("1.6.1"), Version("1.8.9") } }, { 2, { Version("1.9"), Version("1.10.2") } },
- { 3, { Version("1.11"), Version("1.12.2") } }, { 4, { Version("1.13"), Version("1.14.4") } },
- { 5, { Version("1.15"), Version("1.16.1") } }, { 6, { Version("1.16.2"), Version("1.16.5") } },
- { 7, { Version("1.17"), Version("1.17.1") } }, { 8, { Version("1.18"), Version("1.18.2") } },
- { 9, { Version("1.19"), Version("1.19.2") } }, { 11, { Version("1.19.3"), Version("1.19.3") } },
+ { 1, { Version("1.6.1"), Version("1.8.9") } }, { 2, { Version("1.9"), Version("1.10.2") } },
+ { 3, { Version("1.11"), Version("1.12.2") } }, { 4, { Version("1.13"), Version("1.14.4") } },
+ { 5, { Version("1.15"), Version("1.16.1") } }, { 6, { Version("1.16.2"), Version("1.16.5") } },
+ { 7, { Version("1.17"), Version("1.17.1") } }, { 8, { Version("1.18"), Version("1.18.2") } },
+ { 9, { Version("1.19"), Version("1.19.2") } }, { 11, { Version("22w42a"), Version("22w44a") } },
+ { 12, { Version("1.19.3"), Version("1.19.3") } },
};
void ResourcePack::setPackFormat(int new_format_id)
@@ -25,7 +26,7 @@ void ResourcePack::setPackFormat(int new_format_id)
QMutexLocker locker(&m_data_lock);
if (!s_pack_format_versions.contains(new_format_id)) {
- qWarning() << "Pack format '%1' is not a recognized resource pack id!";
+ qWarning() << "Pack format '" << new_format_id << "' is not a recognized resource pack id!";
}
m_pack_format = new_format_id;
diff --git a/launcher/minecraft/mod/ShaderPack.cpp b/launcher/minecraft/mod/ShaderPack.cpp
new file mode 100644
index 00000000..6a9641de
--- /dev/null
+++ b/launcher/minecraft/mod/ShaderPack.cpp
@@ -0,0 +1,37 @@
+
+// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "ShaderPack.h"
+
+#include "minecraft/mod/tasks/LocalShaderPackParseTask.h"
+
+void ShaderPack::setPackFormat(ShaderPackFormat new_format)
+{
+ QMutexLocker locker(&m_data_lock);
+
+ m_pack_format = new_format;
+}
+
+bool ShaderPack::valid() const
+{
+ return m_pack_format != ShaderPackFormat::INVALID;
+}
diff --git a/launcher/minecraft/mod/ShaderPack.h b/launcher/minecraft/mod/ShaderPack.h
new file mode 100644
index 00000000..ec0f9404
--- /dev/null
+++ b/launcher/minecraft/mod/ShaderPack.h
@@ -0,0 +1,62 @@
+// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "Resource.h"
+
+/* Info:
+ * Currently For Optifine / Iris shader packs,
+ * could be expanded to support others should they exist?
+ *
+ * This class and enum are mostly here as placeholders for validating
+ * that a shaderpack exists and is in the right format,
+ * namely that they contain a folder named 'shaders'.
+ *
+ * In the technical sense it would be possible to parse files like `shaders/shaders.properties`
+ * to get information like the available profiles but this is not all that useful without more knowledge of the
+ * shader mod used to be able to change settings.
+ */
+
+#include <QMutex>
+
+enum class ShaderPackFormat { VALID, INVALID };
+
+class ShaderPack : public Resource {
+ Q_OBJECT
+ public:
+ using Ptr = shared_qobject_ptr<Resource>;
+
+ [[nodiscard]] ShaderPackFormat packFormat() const { return m_pack_format; }
+
+ ShaderPack(QObject* parent = nullptr) : Resource(parent) {}
+ ShaderPack(QFileInfo file_info) : Resource(file_info) {}
+
+ /** Thread-safe. */
+ void setPackFormat(ShaderPackFormat new_format);
+
+ bool valid() const override;
+
+ protected:
+ mutable QMutex m_data_lock;
+
+ ShaderPackFormat m_pack_format = ShaderPackFormat::INVALID;
+};
diff --git a/launcher/minecraft/mod/WorldSave.cpp b/launcher/minecraft/mod/WorldSave.cpp
new file mode 100644
index 00000000..7123f512
--- /dev/null
+++ b/launcher/minecraft/mod/WorldSave.cpp
@@ -0,0 +1,43 @@
+// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "WorldSave.h"
+
+#include "minecraft/mod/tasks/LocalWorldSaveParseTask.h"
+
+void WorldSave::setSaveFormat(WorldSaveFormat new_save_format)
+{
+ QMutexLocker locker(&m_data_lock);
+
+ m_save_format = new_save_format;
+}
+
+void WorldSave::setSaveDirName(QString dir_name)
+{
+ QMutexLocker locker(&m_data_lock);
+
+ m_save_dir_name = dir_name;
+}
+
+bool WorldSave::valid() const
+{
+ return m_save_format != WorldSaveFormat::INVALID;
+}
diff --git a/launcher/minecraft/mod/WorldSave.h b/launcher/minecraft/mod/WorldSave.h
new file mode 100644
index 00000000..5985fc8a
--- /dev/null
+++ b/launcher/minecraft/mod/WorldSave.h
@@ -0,0 +1,61 @@
+// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "Resource.h"
+
+#include <QMutex>
+
+class Version;
+
+enum class WorldSaveFormat { SINGLE, MULTI, INVALID };
+
+class WorldSave : public Resource {
+ Q_OBJECT
+ public:
+ using Ptr = shared_qobject_ptr<Resource>;
+
+ WorldSave(QObject* parent = nullptr) : Resource(parent) {}
+ WorldSave(QFileInfo file_info) : Resource(file_info) {}
+
+ /** Gets the format of the save. */
+ [[nodiscard]] WorldSaveFormat saveFormat() const { return m_save_format; }
+ /** Gets the name of the save dir (first found in multi mode). */
+ [[nodiscard]] QString saveDirName() const { return m_save_dir_name; }
+
+ /** Thread-safe. */
+ void setSaveFormat(WorldSaveFormat new_save_format);
+ /** Thread-safe. */
+ void setSaveDirName(QString dir_name);
+
+ bool valid() const override;
+
+ protected:
+ mutable QMutex m_data_lock;
+
+ /** The format in which the save file is in.
+ * Since saves can be distributed in various slightly different ways, this allows us to treat them separately.
+ */
+ WorldSaveFormat m_save_format = WorldSaveFormat::INVALID;
+
+ QString m_save_dir_name;
+};
diff --git a/launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp
new file mode 100644
index 00000000..3fcb2110
--- /dev/null
+++ b/launcher/minecraft/mod/tasks/LocalDataPackParseTask.cpp
@@ -0,0 +1,177 @@
+// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "LocalDataPackParseTask.h"
+
+#include "FileSystem.h"
+#include "Json.h"
+
+#include <quazip/quazip.h>
+#include <quazip/quazipdir.h>
+#include <quazip/quazipfile.h>
+
+#include <QCryptographicHash>
+
+namespace DataPackUtils {
+
+bool process(DataPack& pack, ProcessingLevel level)
+{
+ switch (pack.type()) {
+ case ResourceType::FOLDER:
+ return DataPackUtils::processFolder(pack