add ItemStack::fields
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user