summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-08-21 07:50:58 +0200
committerMattes D <github@xoft.cz>2014-08-21 07:50:58 +0200
commitbacfca7c20fb146bdf0d46cd862da5c1d6156fef (patch)
tree2078bc6c4ed2d3f6c1f72687f24e58c94afe78b3 /src/ClientHandle.cpp
parentMerge pull request #1339 from mc-server/Hooks (diff)
parentMerge branch 'master' into Fire (diff)
downloadcuberite-bacfca7c20fb146bdf0d46cd862da5c1d6156fef.tar
cuberite-bacfca7c20fb146bdf0d46cd862da5c1d6156fef.tar.gz
cuberite-bacfca7c20fb146bdf0d46cd862da5c1d6156fef.tar.bz2
cuberite-bacfca7c20fb146bdf0d46cd862da5c1d6156fef.tar.lz
cuberite-bacfca7c20fb146bdf0d46cd862da5c1d6156fef.tar.xz
cuberite-bacfca7c20fb146bdf0d46cd862da5c1d6156fef.tar.zst
cuberite-bacfca7c20fb146bdf0d46cd862da5c1d6156fef.zip
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r--src/ClientHandle.cpp45
1 files changed, 17 insertions, 28 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index d386f3576..e2b438831 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -912,6 +912,23 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
return;
}
+ // Check for clickthrough-blocks:
+ /* When the user breaks a fire block, the client send the wrong block location.
+ We must find the right block with the face direction. */
+ if (a_BlockFace != BLOCK_FACE_NONE)
+ {
+ int BlockX = a_BlockX;
+ int BlockY = a_BlockY;
+ int BlockZ = a_BlockZ;
+ AddFaceDirection(BlockX, BlockY, BlockZ, a_BlockFace);
+ if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(BlockX, BlockY, BlockZ))->IsClickedThrough())
+ {
+ a_BlockX = BlockX;
+ a_BlockY = BlockY;
+ a_BlockZ = BlockZ;
+ }
+ }
+
if (
((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored
((Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) ||
@@ -920,10 +937,6 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
)
{
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
- if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))->IsClickedThrough())
- {
- m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player);
- }
return;
}
@@ -932,10 +945,6 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
{
// A plugin doesn't agree with the action, replace the block on the client and quit:
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
- if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))->IsClickedThrough())
- {
- m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player);
- }
return;
}
@@ -1059,26 +1068,6 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
m_LastDigBlockY = a_BlockY;
m_LastDigBlockZ = a_BlockZ;
- // Check for clickthrough-blocks:
- /* When the user breaks a fire block, the client send the wrong block location.
- We must find the right block with the face direction. */
- if (a_BlockFace != BLOCK_FACE_NONE)
- {
- int pX = a_BlockX;
- int pY = a_BlockY;
- int pZ = a_BlockZ;
-
- AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false)
- cBlockHandler * Handler = cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(pX, pY, pZ));
-
- if (Handler->IsClickedThrough())
- {
- cChunkInterface ChunkInterface(m_Player->GetWorld()->GetChunkMap());
- Handler->OnDigging(ChunkInterface, *m_Player->GetWorld(), m_Player, pX, pY, pZ);
- return;
- }
- }
-
if (
(m_Player->IsGameModeCreative()) || // In creative mode, digging is done immediately
cBlockInfo::IsOneHitDig(a_OldBlock) // One-hit blocks get destroyed immediately, too