update WorldConverter (WIP)

This commit is contained in:
MihailRis
2024-09-02 23:24:59 +03:00
parent 3f826a88d3
commit 728795f0f3
12 changed files with 299 additions and 97 deletions
+9
View File
@@ -81,6 +81,15 @@ std::unique_ptr<dynamic::Map> Inventory::serialize() const {
return map;
}
void Inventory::convert(const ContentReport* report) {
for (auto& slot : slots) {
itemid_t id = slot.getItemId();
itemid_t replacement = report->items.getId(id);
slot.set(ItemStack(replacement, slot.getCount()));
}
}
// TODO: remove
void Inventory::convert(dynamic::Map* data, const ContentReport* report) {
auto slotsarr = data->list("slots");
for (size_t i = 0; i < slotsarr->size(); i++) {
+1
View File
@@ -42,6 +42,7 @@ public:
/* serializing inventory */
std::unique_ptr<dynamic::Map> serialize() const override;
void convert(const ContentReport* report);
static void convert(dynamic::Map* data, const ContentReport* report);
inline void setId(int64_t id) {
+3
View File
@@ -16,6 +16,9 @@ void ItemStack::set(const ItemStack& item) {
if (count == 0) {
this->item = 0;
}
if (this->item == 0) {
count = 0;
}
}
bool ItemStack::accepts(const ItemStack& other) const {