mirror of
https://github.com/quizhizhe/LiteLoaderBDS-1.16.40.git
synced 2025-06-03 04:23:39 +00:00
Support AddonsHelper
This commit is contained in:
parent
f5888eb4da
commit
fa8472b947
15
LiteLoader/Header/MC/JsonHelpers.hpp
Normal file
15
LiteLoader/Header/MC/JsonHelpers.hpp
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
#pragma once
|
||||
#include "../Global.h"
|
||||
#include "Json.hpp"
|
||||
|
||||
|
||||
namespace JsonHelpers {
|
||||
//void addObjectArrayField(class Json::Value &, std::string const &, std::vector<class Json::Value> const &);
|
||||
//void addObjectField(class Json::Value &, std::string const &, class Json::Value const &);
|
||||
//void addStringField(class Json::Value &, std::string const &, std::string const &);
|
||||
//void addUint32Field(class Json::Value &, std::string const &, unsigned int const &);
|
||||
bool parseJson(std::string const &str, class Json::Value &value);
|
||||
std::string serialize(class Json::Value const &value);
|
||||
|
||||
};
|
@ -5,6 +5,40 @@
|
||||
#include "Core.hpp"
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
enum class PackOrigin : int {
|
||||
PackOrigin_Unknown = 0x0,
|
||||
PackOrigin_RealmsUnknown = 0x1,
|
||||
PackOrigin_Package = 0x2,
|
||||
PackOrigin_Treatment = 0x3,
|
||||
PackOrigin_Dev = 0x4,
|
||||
PackOrigin_World = 0x5,
|
||||
PackOrigin_User = 0x6,
|
||||
PackOrigin_TempCache = 0x7,
|
||||
PackOrigin_PremiumCache = 0x8,
|
||||
PackOrigin_PremiumTempCache = 0x9,
|
||||
};
|
||||
|
||||
enum class PackType : char {
|
||||
PackType_Invalid = 0x0,
|
||||
PackType_Addon = 0x1,
|
||||
PackType_Cached = 0x2,
|
||||
PackType_CopyProtected = 0x3,
|
||||
PackType_Behavior = 0x4,
|
||||
PackType_PersonaPiece = 0x5,
|
||||
PackType_Resources = 0x6,
|
||||
PackType_Skins = 0x7,
|
||||
PackType_WorldTemplate = 0x8,
|
||||
PackType_Count = 0x9,
|
||||
};
|
||||
|
||||
enum class PackCategory : int {
|
||||
PackCategory_Unknown = 0x0,
|
||||
PackCategory_RealmsUnknown = 0x1,
|
||||
PackCategory_Standard = 0x2,
|
||||
PackCategory_Premium = 0x3,
|
||||
PackCategory_Custom = 0x4,
|
||||
PackCategory_Subpack = 0x5,
|
||||
};
|
||||
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
|
@ -5,13 +5,24 @@
|
||||
#include "Core.hpp"
|
||||
|
||||
#define BEFORE_EXTRA
|
||||
|
||||
#include "ResourcePack.hpp"
|
||||
#undef BEFORE_EXTRA
|
||||
|
||||
class ResourcePackRepository {
|
||||
|
||||
#define AFTER_EXTRA
|
||||
public:
|
||||
struct KnownPackContainer {
|
||||
KnownPackContainer() = delete;
|
||||
KnownPackContainer(KnownPackContainer const&) = delete;
|
||||
KnownPackContainer(KnownPackContainer const&&) = delete;
|
||||
};
|
||||
LIAPI void setCustomResourcePackPath(PackType, const std::string& path);
|
||||
|
||||
inline class PackSourceFactory & getPackSourceFactory(){
|
||||
//ResourcePackRepository::_initializeWorldPackSource Line62
|
||||
return dAccess<PackSourceFactory>(this, 46 * 8);
|
||||
};
|
||||
#undef AFTER_EXTRA
|
||||
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_RESOURCEPACKREPOSITORY
|
||||
public:
|
||||
|
16
LiteLoader/Kernel/MC/JsonHelpers.cpp
Normal file
16
LiteLoader/Kernel/MC/JsonHelpers.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
//
|
||||
// Created by User on 2022/10/29.
|
||||
//
|
||||
#include "MC/JsonHelpers.hpp"
|
||||
|
||||
bool JsonHelpers::parseJson(std::string const &str, class Json::Value &value){
|
||||
auto jsonRead = new Json::Reader();
|
||||
jsonRead->parse(str,value);
|
||||
return true;
|
||||
};
|
||||
|
||||
std::string JsonHelpers::serialize(class Json::Value const &value){
|
||||
if(value.empty())
|
||||
return "";
|
||||
return value.toStyledString();
|
||||
};
|
@ -4,10 +4,10 @@
|
||||
#include <MC/PackSourceFactory.hpp>
|
||||
#include <MC/PackSource.hpp>
|
||||
|
||||
// void ResourcePackRepository::setCustomResourcePackPath(PackType type, const std::string& path) {
|
||||
// auto CompositePack = dAccess<CompositePackSource*>(this, 48);
|
||||
// auto& PackSourceFactory = getPackSourceFactory();
|
||||
// auto& DirectoryPackSource = PackSourceFactory.createDirectoryPackSource(Core::Path(path), type, PackOrigin::PackOrigin_Dev, 0);
|
||||
// CompositePack->addPackSource((PackSource*)&DirectoryPackSource);
|
||||
// refreshPacks();
|
||||
// }
|
||||
void ResourcePackRepository::setCustomResourcePackPath(PackType type, const std::string& path) {
|
||||
auto CompositePack = dAccess<CompositePackSource*>(this, 48);
|
||||
auto& PackSourceFactory = getPackSourceFactory();
|
||||
auto& DirectoryPackSource = PackSourceFactory.createDirectoryPackSource(Core::Path(path), type, PackOrigin::PackOrigin_Dev, 0);
|
||||
CompositePack->addPackSource((PackSource*)&DirectoryPackSource);
|
||||
refreshPacks();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -306,9 +306,9 @@ void LLMain() {
|
||||
CheckDevMode();
|
||||
|
||||
// Addon Helper
|
||||
// if (LL::globalConfig.enableAddonsHelper) {
|
||||
// InitAddonsHelper();
|
||||
// }
|
||||
if (LL::globalConfig.enableAddonsHelper) {
|
||||
InitAddonsHelper();
|
||||
}
|
||||
|
||||
// Load plugins
|
||||
LL::LoadMain();
|
||||
|
Loading…
Reference in New Issue
Block a user