add ItemStack::fields

This commit is contained in:
MihailRis
2025-02-15 20:30:22 +03:00
parent fd8c26d585
commit d86c5508d2
5 changed files with 85 additions and 29 deletions
+9 -3
View File
@@ -72,8 +72,12 @@ void Inventory::deserialize(const dv::value& src) {
if (item.has("count")){
count = item["count"].asInteger();
}
dv::value fields = nullptr;
if (item.has("fields")) {
fields = item["fields"];
}
auto& slot = slots[i];
slot.set(ItemStack(id, count));
slot.set(ItemStack(id, count, fields));
}
}
@@ -92,6 +96,10 @@ dv::value Inventory::serialize() const {
if (count) {
slotmap["count"] = count;
}
const auto& fields = item.getFields();
if (fields != nullptr) {
slotmap["fields"] = fields;
}
}
return map;
}
@@ -110,5 +118,3 @@ void Inventory::convert(dv::value& data, const ContentReport* report) {
inventory.convert(report);
data = inventory.serialize();
}
const size_t Inventory::npos = -1;