mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
add ItemStack::fields
This commit is contained in:
parent
fd8c26d585
commit
d86c5508d2
5 changed files with 85 additions and 29 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue