summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-21 23:14:23 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-21 23:14:23 +0200
commit7615ed90c020b88db52b0b094f00cd028e326b5a (patch)
treeca7f647e77195a6346a2333f3d9fe5292cd2ed40 /src/ClientHandle.cpp
parentFixed invalid iterators (diff)
parentMerge branch 'master' of https://github.com/mc-server/MCServer (diff)
downloadcuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar
cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.gz
cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.bz2
cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.lz
cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.xz
cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.zst
cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.zip
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r--src/ClientHandle.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 84f096d67..1c6c989c5 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -952,6 +952,26 @@ 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
@@ -978,22 +998,6 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
ItemHandler->OnDiggingBlock(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
-
- // Check for clickthrough-blocks:
- 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)
- Handler = cBlockInfo::GetHandler(World->GetBlock(pX, pY, pZ));
-
- if (Handler->IsClickedThrough())
- {
- Handler->OnDigging(ChunkInterface, *World, m_Player, pX, pY, pZ);
- }
- }
}