Merge pull request #2 from yefengeeeeeeeeeee/multiversion

This commit is contained in:
yefengeeeeeeeeeee 2025-04-14 20:42:26 +08:00 • committed by GitHub
commit 60b802ba6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 10 deletions

View file

@ -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
}

View file

@ -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;

View file

@ -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);

View file

@ -1421,7 +1421,6 @@ class Entity extends Position
$this->player->directDataPacket($pk, 0);
}
$this->knockbackTime = 10;
}
return $ret;

View file

@ -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;
}