mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 21:11:50 +00:00
Merge pull request #798 from MihailRis/fix-block-inventories
fix: block inventory not removing in some cases
This commit is contained in:
commit
0051f06e46
3 changed files with 5 additions and 3 deletions
|
|
@ -1,13 +1,13 @@
|
||||||
#include "Chunk.hpp"
|
#include "Chunk.hpp"
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "content/ContentReport.hpp"
|
#include "content/ContentReport.hpp"
|
||||||
#include "items/Inventory.hpp"
|
#include "items/Inventory.hpp"
|
||||||
#include "lighting/Lightmap.hpp"
|
#include "lighting/Lightmap.hpp"
|
||||||
#include "util/data_io.hpp"
|
#include "util/data_io.hpp"
|
||||||
#include "voxel.hpp"
|
#include "voxel.hpp"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
Chunk::Chunk(int xpos, int zpos, std::shared_ptr<Lightmap> lightmap)
|
Chunk::Chunk(int xpos, int zpos, std::shared_ptr<Lightmap> lightmap)
|
||||||
: x(xpos), z(zpos), lightmap(std::move(lightmap)) {
|
: x(xpos), z(zpos), lightmap(std::move(lightmap)) {
|
||||||
bottom = 0;
|
bottom = 0;
|
||||||
|
|
@ -40,6 +40,7 @@ void Chunk::addBlockInventory(
|
||||||
void Chunk::removeBlockInventory(uint x, uint y, uint z) {
|
void Chunk::removeBlockInventory(uint x, uint y, uint z) {
|
||||||
if (inventories.erase(vox_index(x, y, z))) {
|
if (inventories.erase(vox_index(x, y, z))) {
|
||||||
flags.unsaved = true;
|
flags.unsaved = true;
|
||||||
|
flags.inventoriesRemoved = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ public:
|
||||||
bool entities : 1;
|
bool entities : 1;
|
||||||
bool blocksData : 1;
|
bool blocksData : 1;
|
||||||
bool dirtyHeights : 1;
|
bool dirtyHeights : 1;
|
||||||
|
bool inventoriesRemoved : 1;
|
||||||
} flags {};
|
} flags {};
|
||||||
|
|
||||||
uint64_t lastRandomTickId = -1;
|
uint64_t lastRandomTickId = -1;
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ void WorldRegions::put(Chunk* chunk, std::vector<ubyte> entitiesData) {
|
||||||
LIGHTMAP_DATA_LEN);
|
LIGHTMAP_DATA_LEN);
|
||||||
}
|
}
|
||||||
// Writing block inventories
|
// Writing block inventories
|
||||||
if (!chunk->inventories.empty()) {
|
if (!chunk->inventories.empty() || chunk->flags.inventoriesRemoved) {
|
||||||
uint datasize;
|
uint datasize;
|
||||||
auto data = write_inventories(chunk->inventories, datasize);
|
auto data = write_inventories(chunk->inventories, datasize);
|
||||||
put(chunk->x,
|
put(chunk->x,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue