diff --git a/src/logic/PlayerController.cpp b/src/logic/PlayerController.cpp index 00e4d1a7d..5b315d349 100644 --- a/src/logic/PlayerController.cpp +++ b/src/logic/PlayerController.cpp @@ -437,11 +437,15 @@ void PlayerController::processRightClick(const Block& def, const Block& target) } blockid_t chosenBlock = def.rt.id; - AABB blockAABB(coord, coord + 1); - bool blocked = level->entities->hasBlockingInside(blockAABB); - if (def.obstacle && blocked) { - return; + if (def.obstacle) { + std::vector hitboxes = def.rotatable ? def.rt.hitboxes[state.rotation] : def.hitboxes; + for (AABB blockAABB : hitboxes) { + bool blocked = level->entities->hasBlockingInside(blockAABB.move(coord)); + if (blocked) { + return; + } + } } auto vox = chunks->get(coord); if (vox == nullptr) { diff --git a/src/maths/aabb.hpp b/src/maths/aabb.hpp index 6354d7a81..a56f32a5f 100644 --- a/src/maths/aabb.hpp +++ b/src/maths/aabb.hpp @@ -34,6 +34,10 @@ struct AABB { return (a + b) * 0.5f; } + inline AABB move(glm::vec3 pos) const { + return AABB(a + pos, b + pos); + } + /// @brief Multiply AABB size from center inline void scale(const glm::vec3 mul) { glm::vec3 center = (a + b) * 0.5f;