mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
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
This commit is contained in:
parent
38b2d83799
commit
bac57c159f
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user