Merge branch 'release/3.5'

This commit is contained in:
Dylan K. Taylor
2018-12-31 21:52:48 +00:00
3 changed files with 20 additions and 3 deletions

View File

@ -77,6 +77,11 @@ class SimpleSessionHandler extends SessionHandler{
/** @var CraftingTransaction|null */
protected $craftingTransaction = null;
/** @var float */
protected $lastRightClickTime = 0.0;
/** @var Vector3|null */
protected $lastRightClickPos = null;
public function __construct(Player $player){
$this->player = $player;
}
@ -184,6 +189,18 @@ class SimpleSessionHandler extends SessionHandler{
$type = $packet->trData->actionType;
switch($type){
case InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK:
//TODO: start hack for client spam bug
$spamBug = ($this->lastRightClickPos !== 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
);
//get rid of continued spam if the player clicks and holds right-click
$this->lastRightClickPos = clone $packet->trData->clickPos;
$this->lastRightClickTime = microtime(true);
if($spamBug){
return true;
}
//TODO: end hack for client spam bug
$this->player->interactBlock($blockVector, $face, $packet->trData->clickPos);
return true;
case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK: