1
0

cClientHandle: Always call HOOK_PLAYER_RIGHT_CLICK (#4149)

Reverts the reduction in cases where the hook was called, a change which broke plugins.
This commit is contained in:
peterbell10 2018-01-25 08:10:16 +00:00 committed by GitHub
parent d3a3c6ad2c
commit 95108c134d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1431,7 +1431,10 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
bool Success = false; bool Success = false;
if (IsWithinReach && !m_Player->IsFrozen()) if (
!PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ) &&
IsWithinReach && !m_Player->IsFrozen()
)
{ {
BLOCKTYPE BlockType; BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta; NIBBLETYPE BlockMeta;
@ -1470,11 +1473,8 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
Kick("Too many blocks were placed / interacted with per unit time - hacked client?"); Kick("Too many blocks were placed / interacted with per unit time - hacked client?");
return; return;
} }
if (!PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) // place a block
{ Success = ItemHandler->OnPlayerPlace(*World, *m_Player, HeldItem, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
// place a block
Success = ItemHandler->OnPlayerPlace(*World, *m_Player, HeldItem, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ);
}
} }
else else
{ {
@ -1752,6 +1752,11 @@ void cClientHandle::HandleUseItem(eHand a_Hand)
LOGD("HandleUseItem: Hand: %d; HeldItem: %s", a_Hand, ItemToFullString(HeldItem).c_str()); LOGD("HandleUseItem: Hand: %d; HeldItem: %s", a_Hand, ItemToFullString(HeldItem).c_str());
if (PlgMgr->CallHookPlayerRightClick(*m_Player, -1, 255, -1, BLOCK_FACE_NONE, 0, 0, 0))
{
return; // Plugin denied click action
}
// Use item in main / off hand // Use item in main / off hand
// TODO: do we need to sync the current inventory with client if it fails? // TODO: do we need to sync the current inventory with client if it fails?
if (m_Player->IsFrozen() || m_Player->IsGameModeSpectator()) if (m_Player->IsFrozen() || m_Player->IsGameModeSpectator())