Skip to content

Commit 9946ea9

Browse files
committed
get rid of the old hack
1 parent 14b70c0 commit 9946ea9

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

src/network/mcpe/handler/InGamePacketHandler.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
use function json_decode;
117117
use function max;
118118
use function mb_strlen;
119-
use function microtime;
120119
use function sprintf;
121120
use function str_starts_with;
122121
use function strlen;
@@ -128,9 +127,6 @@
128127
class InGamePacketHandler extends PacketHandler{
129128
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
130129

131-
protected float $lastRightClickTime = 0.0;
132-
protected ?UseItemTransactionData $lastRightClickData = null;
133-
134130
protected ?Vector3 $lastPlayerAuthInputPosition = null;
135131
protected ?float $lastPlayerAuthInputYaw = null;
136132
protected ?float $lastPlayerAuthInputPitch = null;
@@ -471,27 +467,11 @@ private function handleUseItemTransaction(UseItemTransactionData $data) : bool{
471467

472468
switch($data->getActionType()){
473469
case UseItemTransactionData::ACTION_CLICK_BLOCK:
474-
//TODO: start hack for client spam bug
475-
$clickPos = $data->getClickPosition();
476-
$spamBug = ($this->lastRightClickData !== null &&
477-
microtime(true) - $this->lastRightClickTime < 0.1 && //100ms
478-
$this->lastRightClickData->getPlayerPosition()->distanceSquared($data->getPlayerPosition()) < 0.00001 &&
479-
$this->lastRightClickData->getBlockPosition()->equals($data->getBlockPosition()) &&
480-
$this->lastRightClickData->getClickPosition()->distanceSquared($clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error
481-
);
482-
//get rid of continued spam if the player clicks and holds right-click
483-
$this->lastRightClickData = $data;
484-
$this->lastRightClickTime = microtime(true);
485-
if($spamBug){
486-
return true;
487-
}
488-
//TODO: end hack for client spam bug
489-
490470
self::validateFacing($data->getFace());
491471

492472
$blockPos = $data->getBlockPosition();
493473
$vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
494-
$this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos);
474+
$this->player->interactBlock($vBlockPos, $data->getFace(), $data->getClickPosition());
495475
//always sync this in case plugins caused a different result than the client expected
496476
//we *could* try to enhance detection of plugin-altered behaviour, but this would require propagating
497477
//more information up the stack. For now I think this is good enough.

0 commit comments

Comments
 (0)