summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-11-25 21:24:25 +0100
committerMattes D <github@xoft.cz>2014-11-25 21:24:25 +0100
commitc1a52dc9fb54c5eb595c1e554787902b82924e9d (patch)
treecc9fa9d3905f5f3ae4e4fa1aa13f1a2293b71774
parentMerge pull request #1604 from mc-server/GeneratorShapeRefactor (diff)
downloadcuberite-c1a52dc9fb54c5eb595c1e554787902b82924e9d.tar
cuberite-c1a52dc9fb54c5eb595c1e554787902b82924e9d.tar.gz
cuberite-c1a52dc9fb54c5eb595c1e554787902b82924e9d.tar.bz2
cuberite-c1a52dc9fb54c5eb595c1e554787902b82924e9d.tar.lz
cuberite-c1a52dc9fb54c5eb595c1e554787902b82924e9d.tar.xz
cuberite-c1a52dc9fb54c5eb595c1e554787902b82924e9d.tar.zst
cuberite-c1a52dc9fb54c5eb595c1e554787902b82924e9d.zip
-rw-r--r--src/ClientHandle.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index c4ce721c3..a6cbad32a 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1238,12 +1238,18 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
// TODO: Rewrite this function
- LOGD("HandleRightClick: {%d, %d, %d}, face %d, HeldItem: %s",
- a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, ItemToFullString(a_HeldItem).c_str()
+ // Distance from the block's center to the player's eye height
+ double dist = (Vector3d(a_BlockX, a_BlockY, a_BlockZ) + Vector3d(0.5, 0.5, 0.5) - m_Player->GetEyePosition()).Length();
+ LOGD("HandleRightClick: {%d, %d, %d}, face %d, HeldItem: %s; dist: %.02f",
+ a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, ItemToFullString(a_HeldItem).c_str(), dist
);
-
+
+ // Check the reach distance:
+ // _X 2014-11-25: I've maxed at 5.26 with a Survival client and 5.78 with a Creative client in my tests
+ double maxDist = m_Player->IsGameModeCreative() ? 5.78 : 5.26;
+ bool AreRealCoords = (dist <= maxDist);
+
cWorld * World = m_Player->GetWorld();
- bool AreRealCoords = (Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() <= 5;
if (
(a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block