summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-11-25 22:46:17 +0100
committerMattes D <github@xoft.cz>2014-11-25 22:46:17 +0100
commite88b93089fb8c2b49a54191b55b26aed7209a11b (patch)
treecc9fa9d3905f5f3ae4e4fa1aa13f1a2293b71774
parentMerge pull request #1604 from mc-server/GeneratorShapeRefactor (diff)
parentClientHandle: Fixed max block place distance check. (diff)
downloadcuberite-e88b93089fb8c2b49a54191b55b26aed7209a11b.tar
cuberite-e88b93089fb8c2b49a54191b55b26aed7209a11b.tar.gz
cuberite-e88b93089fb8c2b49a54191b55b26aed7209a11b.tar.bz2
cuberite-e88b93089fb8c2b49a54191b55b26aed7209a11b.tar.lz
cuberite-e88b93089fb8c2b49a54191b55b26aed7209a11b.tar.xz
cuberite-e88b93089fb8c2b49a54191b55b26aed7209a11b.tar.zst
cuberite-e88b93089fb8c2b49a54191b55b26aed7209a11b.zip
Diffstat (limited to '')
-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