From 31ab16d52b18df9ba2e687bb984356828fe38d0e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Feb 2022 14:22:26 +0000 Subject: ClientHandle: cancel multi-block placements correcty https://github.com/cuberite/cuberite/pull/5392#issuecomment-1032712796 --- src/ClientHandle.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 0bbb1bea9..24f1b3800 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1133,12 +1133,12 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB } if ( - ((Diff(m_Player->GetPosX(), static_cast(a_BlockX)) > 6) || + (Diff(m_Player->GetPosX(), static_cast(a_BlockX)) > 6) || (Diff(m_Player->GetPosY(), static_cast(a_BlockY)) > 6) || - (Diff(m_Player->GetPosZ(), static_cast(a_BlockZ)) > 6)) + (Diff(m_Player->GetPosZ(), static_cast(a_BlockZ)) > 6) ) { - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player); + m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2); return; } } @@ -1147,7 +1147,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB if (m_Player->IsFrozen() || PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, static_cast(a_Status))) { // A plugin doesn't agree with the action, replace the block on the client and quit: - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player); + m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2); SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side. return; } @@ -1288,7 +1288,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc (Diff(m_Player->GetPosZ(), static_cast(a_BlockZ)) > 6) ) { - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player); + m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2); return; } @@ -1365,8 +1365,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo { LOGD("Break progress of player %s was less than expected: %f < %f\n", m_Player->GetName().c_str(), m_BreakProgress * 100, FASTBREAK_PERCENTAGE * 100); // AntiFastBreak doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows: - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player); - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, *m_Player); // Strange bug with doors + m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2); SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side. m_Player->SendMessage("FastBreak?"); // TODO Anticheat hook return; @@ -1378,8 +1377,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, DugBlock, DugMeta)) { // A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows: - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player); - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, *m_Player); // Strange bug with doors + m_Player->SendBlocksAround(a_BlockX, a_BlockY, a_BlockZ, 2); SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side. return; } -- cgit v1.2.3