diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 97551224..ddd309d9 100755 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -505,8 +505,6 @@ class BlockAPI{ if($hand->isSolid === true && ($hand->getID() != BED_BLOCK && $hand->getID() != CARPET)){ $aabb = $hand->getAABB($block->level, $block->x, $block->y, $block->z); $playerbb = $player->entity->boundingBox; - //$aabb->intersectsWith($playerbb) is not good enough for this case - //minY+0.21 is used to stop sneaking from triggering action cancelling if(($aabb->maxX > $playerbb->minX && $aabb->minX < $playerbb->maxX) && ($aabb->maxY > ($playerbb->minY+0.21) && $aabb->minY < $playerbb->maxY) && ($aabb->maxZ > $playerbb->minZ && $aabb->minZ < $playerbb->maxZ)){ return $this->cancelAction($block, $player, false); //Entity in block } diff --git a/src/Player.php b/src/Player.php index b9493ced..fc8349d8 100755 --- a/src/Player.php +++ b/src/Player.php @@ -97,7 +97,7 @@ class Player{ */ public function __construct($clientID, $ip, $port, $MTU){ $this->bigCnt = 0; - $this->MTU = min($MTU, 1100); + $this->MTU = min($MTU, 1492); $this->server = ServerAPI::request(); $this->lastBreak = microtime(true); $this->clientID = $clientID; @@ -355,14 +355,16 @@ class Player{ if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY){ return; } - $packet->PROTOCOL = $this->PROTOCOL; + + $packet->PROTOCOL = $this->PROTOCOL; + $packet->encode(); $len = strlen($packet->buffer) + 1; $MTU = $this->MTU - 24; if($len > $MTU){ return $this->directBigRawPacket($packet); } - + if(($this->bufferLen + $len) >= $MTU){ $this->sendBuffer(); } @@ -1268,6 +1270,8 @@ class Player{ public function sendBlockUpdateQueue(){ if($this->blockUpdateQueueLength > 0 && $this->blockUpdateQueue instanceof RakNetPacket){ $this->blockUpdateQueue->seqNumber = $this->counter[0]++; + $this->recoveryQueue[$this->blockUpdateQueue->seqNumber] = $this->blockUpdateQueue; + $this->blockUpdateQueue->sendtime = microtime(true); $this->send($this->blockUpdateQueue); } $this->blockUpdateQueueLength = 0; @@ -2982,13 +2986,13 @@ class Player{ switch($packet->pid()){ case RakNetInfo::NACK: foreach($packet->packets as $count){ - if(isset($this->recoveryQueue[$count])){ $this->resendQueue[$count] =& $this->recoveryQueue[$count]; $this->lag[] = $time - $this->recoveryQueue[$count]->sendtime; unset($this->recoveryQueue[$count]); + }else{ + ++$this->packetStats[1]; //lost and wont be recovered } - ++$this->packetStats[1]; } break; diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 1938e61d..0e2aca03 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -590,10 +590,10 @@ class PocketMinecraftServer{ break; } - $this->clients[$CID] = new Player($packet->clientID, $packet->ip, $packet->port, $packet->mtuSize); //New Session! + $this->clients[$CID] = $c = new Player($packet->clientID, $packet->ip, $packet->port, $packet->mtuSize); //New Session! $pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_2); $pk->serverID = $this->serverID; - $pk->mtuSize = $packet->mtuSize; + $pk->mtuSize = $c->MTU; $pk->ip = $packet->ip; $pk->port = $packet->port; $this->send($pk); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index c9b794be..e4f5383c 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1421,7 +1421,6 @@ class Entity extends Position $this->player->directDataPacket($pk, 0); } $this->knockbackTime = 10; - } return $ret; diff --git a/src/network/protocol/packet/UnknownPacket.php b/src/network/protocol/packet/UnknownPacket.php index d183dce1..08b89139 100644 --- a/src/network/protocol/packet/UnknownPacket.php +++ b/src/network/protocol/packet/UnknownPacket.php @@ -3,6 +3,10 @@ class UnknownPacket extends RakNetDataPacket{ public $packetID = -1; + public function __construct($pid = -1){ + $this->packetID = $pid; + } + public function pid(){ return $this->packetID; }