mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
Merge branch 'main' into heightmaps
This commit is contained in:
commit
ea9ad08bfd
64 changed files with 3473 additions and 733 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#include "Inventory.hpp"
|
||||
|
||||
#include "content/ContentLUT.hpp"
|
||||
#include "content/ContentReport.hpp"
|
||||
|
||||
Inventory::Inventory(int64_t id, size_t size) : id(id), slots(size) {
|
||||
}
|
||||
|
|
@ -83,11 +83,20 @@ dv::value Inventory::serialize() const {
|
|||
return map;
|
||||
}
|
||||
|
||||
void Inventory::convert(dv::value& data, const ContentLUT* lut) {
|
||||
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(dv::value& data, const ContentReport* report) {
|
||||
auto& slotsarr = data["slots"];
|
||||
for (auto& item : data["slots"]) {
|
||||
itemid_t id = item["id"].asInteger(ITEM_EMPTY);
|
||||
itemid_t replacement = lut->items.getId(id);
|
||||
itemid_t replacement = report->items.getId(id);
|
||||
item["id"] = replacement;
|
||||
if (replacement == 0 && item.has("count")) {
|
||||
item.erase("count");
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "typedefs.hpp"
|
||||
#include "ItemStack.hpp"
|
||||
|
||||
class ContentLUT;
|
||||
class ContentReport;
|
||||
class ContentIndices;
|
||||
|
||||
class Inventory : public Serializable {
|
||||
|
|
@ -37,7 +37,8 @@ public:
|
|||
|
||||
dv::value serialize() const override;
|
||||
|
||||
static void convert(dv::value& data, const ContentLUT* lut);
|
||||
void convert(const ContentReport* report);
|
||||
static void convert(dv::value& data, const ContentReport* report);
|
||||
|
||||
inline void setId(int64_t id) {
|
||||
this->id = 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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue