From 352ef6485a4b796d1cdc8dd0e00ab1a1d72a2c0a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 17 Nov 2024 16:12:59 +0300 Subject: [PATCH 1/3] fix falling block hitbox --- res/content/base/entities/falling_block.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/content/base/entities/falling_block.json b/res/content/base/entities/falling_block.json index cd0459b5..cf5146fd 100644 --- a/res/content/base/entities/falling_block.json +++ b/res/content/base/entities/falling_block.json @@ -3,5 +3,5 @@ "base:falling_block" ], "skeleton-name": "base:block", - "hitbox": [0.8, 0.8, 0.8] + "hitbox": [0.98, 0.98, 0.98] } From 1ba5b0ce33103e539ccb199ee1cd52095e286a1f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 17 Nov 2024 16:58:58 +0300 Subject: [PATCH 2/3] fix: actual block inventory size not updating on inventory-size property update --- src/items/Inventory.cpp | 4 ++++ src/items/Inventory.hpp | 2 ++ src/voxels/ChunksStorage.cpp | 22 +++++++++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/items/Inventory.cpp b/src/items/Inventory.cpp index 92f925ef..282f361f 100644 --- a/src/items/Inventory.cpp +++ b/src/items/Inventory.cpp @@ -45,6 +45,10 @@ void Inventory::move( } } +void Inventory::resize(uint newSize) { + slots.resize(newSize); +} + void Inventory::deserialize(const dv::value& src) { id = src["id"].asInteger(1); auto& slotsarr = src["slots"]; diff --git a/src/items/Inventory.hpp b/src/items/Inventory.hpp index e12029f8..176ad7ee 100644 --- a/src/items/Inventory.hpp +++ b/src/items/Inventory.hpp @@ -35,6 +35,8 @@ public: size_t end = -1 ); + void resize(uint newSize); + void deserialize(const dv::value& src) override; dv::value serialize() const override; diff --git a/src/voxels/ChunksStorage.cpp b/src/voxels/ChunksStorage.cpp index 596c4b78..272332fb 100644 --- a/src/voxels/ChunksStorage.cpp +++ b/src/voxels/ChunksStorage.cpp @@ -39,10 +39,10 @@ void ChunksStorage::remove(int x, int z) { } } -static void verifyLoadedChunk(ContentIndices* indices, Chunk* chunk) { +static void check_voxels(const ContentIndices& indices, Chunk* chunk) { for (size_t i = 0; i < CHUNK_VOL; i++) { blockid_t id = chunk->voxels[i].id; - if (indices->blocks.get(id) == nullptr) { + if (indices.blocks.get(id) == nullptr) { auto logline = logger.error(); logline << "corruped block detected at " << i << " of chunk "; logline << chunk->x << "x" << chunk->z; @@ -59,9 +59,26 @@ std::shared_ptr ChunksStorage::create(int x, int z) { auto chunk = std::make_shared(x, z); store(chunk); if (auto data = regions.getVoxels(chunk->x, chunk->z)) { + const auto& indices = *level->content->getIndices(); + chunk->decode(data.get()); + check_voxels(indices, chunk.get()); auto invs = regions.fetchInventories(chunk->x, chunk->z); + auto iterator = invs.begin(); + while (iterator != invs.end()) { + uint index = iterator->first; + const auto& def = indices.blocks.require(chunk->voxels[index].id); + if (def.inventorySize == 0) { + iterator = invs.erase(iterator); + continue; + } + auto& inventory = iterator->second; + if (def.inventorySize != inventory->size()) { + inventory->resize(def.inventorySize); + } + ++iterator; + } chunk->setBlockInventories(std::move(invs)); auto entitiesData = regions.fetchEntities(chunk->x, chunk->z); @@ -74,7 +91,6 @@ std::shared_ptr ChunksStorage::create(int x, int z) { for (auto& entry : chunk->inventories) { level->inventories->store(entry.second); } - verifyLoadedChunk(level->content->getIndices(), chunk.get()); } if (auto lights = regions.getLights(chunk->x, chunk->z)) { chunk->lightmap.set(lights.get()); From e034bda477c35efe96548e78ecc722966a7a2197 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 18 Nov 2024 04:15:51 +0300 Subject: [PATCH 3/3] fix crosshair --- src/frontend/hud.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index bfaac141..032d0602 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -571,7 +571,7 @@ void Hud::draw(const DrawContext& ctx){ // Crosshair if (!pause && !inventoryOpen && !player->debug) { - DrawContext chctx = ctx.sub(); + DrawContext chctx = ctx.sub(batch); chctx.setBlendMode(BlendMode::inversion); auto texture = assets->get("gui/crosshair"); batch->texture(texture);