From bac57c159f83a21945f41cae07c4f4fee673fd7b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 27 Jan 2021 00:09:55 +0000 Subject: [PATCH] Player: fix bridging, towering and various other fast building bugs clickPos is relative to the base block position, so if you keep aiming at the same spot on the block and jump, it thinks you're still spamming. closes #2730 --- src/pocketmine/Player.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 066041b70..bc228f9af 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -408,8 +408,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** @var float */ protected $lastRightClickTime = 0.0; - /** @var Vector3|null */ - protected $lastRightClickPos = null; + /** @var \stdClass|null */ + protected $lastRightClickData = null; /** * @return TranslationContainer|string @@ -2495,12 +2495,16 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ switch($type){ case InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK: //TODO: start hack for client spam bug - $spamBug = ($this->lastRightClickPos !== null and + $spamBug = ($this->lastRightClickData !== null and microtime(true) - $this->lastRightClickTime < 0.1 and //100ms - $this->lastRightClickPos->distanceSquared($packet->trData->clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error + $this->lastRightClickData->playerPos->distanceSquared($packet->trData->playerPos) < 0.00001 and + $this->lastRightClickData->x === $packet->trData->x and + $this->lastRightClickData->y === $packet->trData->y and + $this->lastRightClickData->z === $packet->trData->z and + $this->lastRightClickData->clickPos->distanceSquared($packet->trData->clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error ); //get rid of continued spam if the player clicks and holds right-click - $this->lastRightClickPos = clone $packet->trData->clickPos; + $this->lastRightClickData = $packet->trData; $this->lastRightClickTime = microtime(true); if($spamBug){ return true;