|
116 | 116 | use function json_decode;
|
117 | 117 | use function max;
|
118 | 118 | use function mb_strlen;
|
119 |
| -use function microtime; |
120 | 119 | use function sprintf;
|
121 | 120 | use function str_starts_with;
|
122 | 121 | use function strlen;
|
|
128 | 127 | class InGamePacketHandler extends PacketHandler{
|
129 | 128 | 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
|
130 | 129 |
|
131 |
| - protected float $lastRightClickTime = 0.0; |
132 |
| - protected ?UseItemTransactionData $lastRightClickData = null; |
133 |
| - |
134 | 130 | protected ?Vector3 $lastPlayerAuthInputPosition = null;
|
135 | 131 | protected ?float $lastPlayerAuthInputYaw = null;
|
136 | 132 | protected ?float $lastPlayerAuthInputPitch = null;
|
@@ -471,27 +467,11 @@ private function handleUseItemTransaction(UseItemTransactionData $data) : bool{
|
471 | 467 |
|
472 | 468 | switch($data->getActionType()){
|
473 | 469 | 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 |
| - |
490 | 470 | self::validateFacing($data->getFace());
|
491 | 471 |
|
492 | 472 | $blockPos = $data->getBlockPosition();
|
493 | 473 | $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()); |
495 | 475 | //always sync this in case plugins caused a different result than the client expected
|
496 | 476 | //we *could* try to enhance detection of plugin-altered behaviour, but this would require propagating
|
497 | 477 | //more information up the stack. For now I think this is good enough.
|
|
0 commit comments