add block.get_field(...), block.set_field(...)

This commit is contained in:
MihailRis
2024-09-30 18:55:01 +03:00
parent 8d89e06ac5
commit fc99343fb5
5 changed files with 169 additions and 28 deletions
+7
View File
@@ -21,6 +21,7 @@
#include "util/stringutil.hpp"
#include "voxels/Block.hpp"
#include "data/dv_util.hpp"
#include "data/StructLayout.hpp"
namespace fs = std::filesystem;
@@ -250,6 +251,12 @@ void ContentLoader::loadBlock(
root.at("ui-layout").get(def.uiLayout);
root.at("inventory-size").get(def.inventorySize);
root.at("tick-interval").get(def.tickInterval);
if (root.has("fields")) {
def.dataStruct = std::make_unique<data::StructLayout>();
def.dataStruct->deserialize(root["fields"]);
}
if (def.tickInterval == 0) {
def.tickInterval = 1;
}