From 95108c134d410040efadfa6bb00c8ce3486fb7fa Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Thu, 25 Jan 2018 08:10:16 +0000 Subject: [PATCH] cClientHandle: Always call HOOK_PLAYER_RIGHT_CLICK (#4149) Reverts the reduction in cases where the hook was called, a change which broke plugins. --- src/ClientHandle.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 3a07de7f1..2d30224ad 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1431,7 +1431,10 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); 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; 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?"); 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 { @@ -1752,6 +1752,11 @@ void cClientHandle::HandleUseItem(eHand a_Hand) 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 // TODO: do we need to sync the current inventory with client if it fails? if (m_Player->IsFrozen() || m_Player->IsGameModeSpectator())