From 7855335bdf219bee4d7070a4aa5483d16c1dbeee Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 30 Sep 2024 14:38:26 +0100 Subject: [PATCH] fix: compilation errors on Linux --- src/endstone_core/block/block.cpp | 11 +++++++---- src/endstone_core/block/block_state.cpp | 18 +++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/endstone_core/block/block.cpp b/src/endstone_core/block/block.cpp index aa003cf31..4df7211ef 100644 --- a/src/endstone_core/block/block.cpp +++ b/src/endstone_core/block/block.cpp @@ -37,8 +37,8 @@ bool EndstoneBlock::isValid() const Result EndstoneBlock::getType() const { - return checkState().and_then([](const auto *self) -> Result { - return self->block_source_.getBlock(self->block_pos_).getLegacyBlock().getFullNameId(); + return checkState().and_then([&](const auto * /*self*/) -> Result { + return block_source_.getBlock(block_pos_).getLegacyBlock().getFullNameId(); }); } @@ -51,8 +51,11 @@ Result EndstoneBlock::setType(std::string type, bool apply_physics) { return checkState().and_then([&](const auto * /*self*/) -> Result { const auto &server = entt::locator::value(); - return server.createBlockData(type).and_then( - [&](auto &block_data) -> Result { return setData(block_data, apply_physics); }); + auto result = server.createBlockData(type); + if (!result) { + return nonstd::make_unexpected(result.error()); + } + return setData(result.value(), apply_physics); }); } diff --git a/src/endstone_core/block/block_state.cpp b/src/endstone_core/block/block_state.cpp index ebecf3006..86edec615 100644 --- a/src/endstone_core/block/block_state.cpp +++ b/src/endstone_core/block/block_state.cpp @@ -107,13 +107,17 @@ Result EndstoneBlockState::update(bool force) Result EndstoneBlockState::update(bool force, bool apply_physics) { - return getBlock().and_then([&](const auto &block) -> Result { - if (block->getType() != getType() && !force) { - return false; - } - block->setData(getData(), apply_physics); - return true; - }); + auto result = getBlock(); + if (!result) { + return nonstd::make_unexpected(result.error()); + } + + auto &block = result.value(); + if (block->getType() != getType() && !force) { + return false; + } + block->setData(getData(), apply_physics); + return true; } } // namespace endstone::detail