From e4d21c940be9048076180976eaba31f0138661a3 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 23 Feb 2026 17:05:13 +0300 Subject: [PATCH] fix: block inventory not removing in some cases --- src/voxels/Chunk.cpp | 5 +++-- src/voxels/Chunk.hpp | 1 + src/world/files/WorldRegions.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/voxels/Chunk.cpp b/src/voxels/Chunk.cpp index 732e67a02..f49999270 100644 --- a/src/voxels/Chunk.cpp +++ b/src/voxels/Chunk.cpp @@ -1,13 +1,13 @@ #include "Chunk.hpp" -#include - #include "content/ContentReport.hpp" #include "items/Inventory.hpp" #include "lighting/Lightmap.hpp" #include "util/data_io.hpp" #include "voxel.hpp" +#include + Chunk::Chunk(int xpos, int zpos, std::shared_ptr lightmap) : x(xpos), z(zpos), lightmap(std::move(lightmap)) { bottom = 0; @@ -40,6 +40,7 @@ void Chunk::addBlockInventory( void Chunk::removeBlockInventory(uint x, uint y, uint z) { if (inventories.erase(vox_index(x, y, z))) { flags.unsaved = true; + flags.inventoriesRemoved = true; } } diff --git a/src/voxels/Chunk.hpp b/src/voxels/Chunk.hpp index 5377df020..941034073 100644 --- a/src/voxels/Chunk.hpp +++ b/src/voxels/Chunk.hpp @@ -38,6 +38,7 @@ public: bool entities : 1; bool blocksData : 1; bool dirtyHeights : 1; + bool inventoriesRemoved : 1; } flags {}; uint64_t lastRandomTickId = -1; diff --git a/src/world/files/WorldRegions.cpp b/src/world/files/WorldRegions.cpp index 0f8535e12..14139ed37 100644 --- a/src/world/files/WorldRegions.cpp +++ b/src/world/files/WorldRegions.cpp @@ -183,7 +183,7 @@ void WorldRegions::put(Chunk* chunk, std::vector entitiesData) { LIGHTMAP_DATA_LEN); } // Writing block inventories - if (!chunk->inventories.empty()) { + if (!chunk->inventories.empty() || chunk->flags.inventoriesRemoved) { uint datasize; auto data = write_inventories(chunk->inventories, datasize); put(chunk->x,