update WorldConverter (WIP)
This commit is contained in:
@@ -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++) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user