MCPcopy Create free account
hub / github.com/cuberite/cuberite / HandleBlockDigFinished

Method HandleBlockDigFinished

src/ClientHandle.cpp:870–913  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

868
869
870void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta)
871{
872 if (
873 !m_HasStartedDigging || // Hasn't received the DIG_STARTED packet
874 (m_LastDigBlockX != a_BlockX) || // DIG_STARTED has had different pos
875 (m_LastDigBlockY != a_BlockY) ||
876 (m_LastDigBlockZ != a_BlockZ)
877 )
878 {
879 LOGD("Prevented a dig/aim bug in the client (finish {%d, %d, %d} vs start {%d, %d, %d}, HSD: %s)",
880 a_BlockX, a_BlockY, a_BlockZ,
881 m_LastDigBlockX, m_LastDigBlockY, m_LastDigBlockZ,
882 (m_HasStartedDigging ? "True" : "False")
883 );
884 return;
885 }
886
887 m_HasStartedDigging = false;
888 if (m_BlockDigAnimStage != -1)
889 {
890 // End dig animation
891 m_BlockDigAnimStage = -1;
892 // It seems that 10 ends block animation
893 m_Player->GetWorld()->BroadcastBlockBreakAnimation(m_UniqueID, m_BlockDigAnimX, m_BlockDigAnimY, m_BlockDigAnimZ, 10, this);
894 }
895
896 cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
897
898 if (a_OldBlock == E_BLOCK_AIR)
899 {
900 LOGD("Dug air - what the function?");
901 return;
902 }
903
904 cWorld * World = m_Player->GetWorld();
905 ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ);
906 // The ItemHandler is also responsible for spawning the pickups
907 cChunkInterface ChunkInterface(World->GetChunkMap());
908 BlockHandler(a_OldBlock)->OnDestroyedByPlayer(ChunkInterface,*World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
909 World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this);
910 World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
911
912 cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta);
913}
914
915
916

Callers

nothing calls this directly

Calls 10

BlockHandlerFunction · 0.85
OnBlockDestroyedMethod · 0.80
GetChunkMapMethod · 0.80
GetPluginManagerMethod · 0.80
GetWorldMethod · 0.45
OnDestroyedByPlayerMethod · 0.45
DigBlockMethod · 0.45

Tested by

no test coverage detected