From 9946ea9e8a46c073108575e6e22b39d3931d72e6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 28 May 2025 23:07:02 +0100 Subject: [PATCH] get rid of the old hack --- .../mcpe/handler/InGamePacketHandler.php | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/network/mcpe/handler/InGamePacketHandler.php b/src/network/mcpe/handler/InGamePacketHandler.php index eec200e4b..d8a79acb2 100644 --- a/src/network/mcpe/handler/InGamePacketHandler.php +++ b/src/network/mcpe/handler/InGamePacketHandler.php @@ -116,7 +116,6 @@ use function is_nan; use function json_decode; use function max; use function mb_strlen; -use function microtime; use function sprintf; use function str_starts_with; use function strlen; @@ -128,9 +127,6 @@ use const JSON_THROW_ON_ERROR; class InGamePacketHandler extends PacketHandler{ private const MAX_FORM_RESPONSE_DEPTH = 2; //modal/simple will be 1, custom forms 2 - they will never contain anything other than string|int|float|bool|null - protected float $lastRightClickTime = 0.0; - protected ?UseItemTransactionData $lastRightClickData = null; - protected ?Vector3 $lastPlayerAuthInputPosition = null; protected ?float $lastPlayerAuthInputYaw = null; protected ?float $lastPlayerAuthInputPitch = null; @@ -471,27 +467,11 @@ class InGamePacketHandler extends PacketHandler{ switch($data->getActionType()){ case UseItemTransactionData::ACTION_CLICK_BLOCK: - //TODO: start hack for client spam bug - $clickPos = $data->getClickPosition(); - $spamBug = ($this->lastRightClickData !== null && - microtime(true) - $this->lastRightClickTime < 0.1 && //100ms - $this->lastRightClickData->getPlayerPosition()->distanceSquared($data->getPlayerPosition()) < 0.00001 && - $this->lastRightClickData->getBlockPosition()->equals($data->getBlockPosition()) && - $this->lastRightClickData->getClickPosition()->distanceSquared($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->lastRightClickData = $data; - $this->lastRightClickTime = microtime(true); - if($spamBug){ - return true; - } - //TODO: end hack for client spam bug - self::validateFacing($data->getFace()); $blockPos = $data->getBlockPosition(); $vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ()); - $this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos); + $this->player->interactBlock($vBlockPos, $data->getFace(), $data->getClickPosition()); //always sync this in case plugins caused a different result than the client expected //we *could* try to enhance detection of plugin-altered behaviour, but this would require propagating //more information up the stack. For now I think this is good enough.