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

Method HandleLeftClick

src/ClientHandle.cpp:684–781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

682
683
684void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Status)
685{
686 LOGD("HandleLeftClick: {%i, %i, %i}; Face: %i; Stat: %i",
687 a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status
688 );
689
690 m_NumBlockChangeInteractionsThisTick++;
691
692 if (!CheckBlockInteractionsRate())
693 {
694 Kick("Too many blocks were destroyed per unit time - hacked client?");
695 return;
696 }
697
698 cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
699 if (PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status))
700 {
701 // A plugin doesn't agree with the action, replace the block on the client and quit:
702 m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
703 return;
704 }
705
706 switch (a_Status)
707 {
708 case DIG_STATUS_DROP_HELD: // Drop held item
709 {
710 if (PlgMgr->CallHookPlayerTossingItem(*m_Player))
711 {
712 // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
713 return;
714 }
715
716 m_Player->TossEquippedItem();
717 return;
718 }
719
720 case DIG_STATUS_SHOOT_EAT:
721 {
722 cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
723 if (ItemHandler->IsFood())
724 {
725 m_Player->AbortEating();
726 return;
727 }
728 else
729 {
730 if (PlgMgr->CallHookPlayerShooting(*m_Player))
731 {
732 // A plugin doesn't agree with the action. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
733 return;
734 }
735 ItemHandler->OnItemShoot(m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
736 }
737 return;
738 }
739
740 case DIG_STATUS_STARTED:
741 {

Callers 2

ParseBlockDigMethod · 0.80
HandlePacketBlockDigMethod · 0.80

Calls 11

GetPluginManagerMethod · 0.80
TossEquippedItemMethod · 0.80
AbortEatingMethod · 0.80
SendBlockToMethod · 0.45
GetWorldMethod · 0.45
IsFoodMethod · 0.45
OnItemShootMethod · 0.45
GetBlockTypeMetaMethod · 0.45

Tested by

no test coverage detected