This commit is contained in:
MihailRis
2024-08-11 18:21:12 +03:00
parent 3d3da1cdcd
commit 4f2448daed
9 changed files with 46 additions and 35 deletions
+8
View File
@@ -7,6 +7,8 @@
#include "files/files.hpp"
#include "items/ItemDef.hpp"
#include "voxels/Block.hpp"
#include "world/World.hpp"
#include "files/WorldFiles.hpp"
#include "Content.hpp"
ContentLUT::ContentLUT(
@@ -24,8 +26,14 @@ static constexpr size_t get_entries_count(
}
std::shared_ptr<ContentLUT> ContentLUT::create(
const std::shared_ptr<WorldFiles>& worldFiles,
const fs::path& filename, const Content* content
) {
auto worldInfo = worldFiles->readWorldInfo();
if (!worldInfo.has_value()) {
return nullptr;
}
auto root = files::read_json(filename);
auto blocklist = root->list("blocks");
auto itemlist = root->list("items");
+5 -1
View File
@@ -17,6 +17,8 @@ struct contententry {
std::string name;
};
struct WorldFiles;
template <typename T, class U>
class ContentUnitLUT {
std::vector<T> indices;
@@ -100,7 +102,9 @@ public:
ContentLUT(const ContentIndices* indices, size_t blocks, size_t items);
static std::shared_ptr<ContentLUT> create(
const fs::path& filename, const Content* content
const std::shared_ptr<WorldFiles>& worldFiles,
const fs::path& filename,
const Content* content
);
inline bool hasContentReorder() const {