readded limit to resendQueue, MovePlayerPacket will be sent after AddPlayerPacket to fix AddPlayerPacket bug

This commit is contained in:
GameHerobrine 2025-07-01 09:47:04 +03:00
parent 31ae786748
commit 00c03d8bf0
2 changed files with 19 additions and 11 deletions

View file

@ -1621,7 +1621,9 @@ class Player{
} }
if(($resendCnt = count($this->resendQueue)) > 0){ if(($resendCnt = count($this->resendQueue)) > 0){
$limit = 25;
foreach($this->resendQueue as $count => $data){ foreach($this->resendQueue as $count => $data){
if(!--$limit) break;
unset($this->resendQueue[$count]); unset($this->resendQueue[$count]);
$this->packetStats[1]++; $this->packetStats[1]++;
$this->lag[] = $time - $data->sendtime; $this->lag[] = $time - $data->sendtime;

View file

@ -1153,27 +1153,33 @@ class Entity extends Position
$player->addEntity($this); $player->addEntity($this);
if($this->level != $player->entity->level || $this->player->gamemode === SPECTATOR) $this->player->setInvisibleFor($player, true, send:false); if($this->level != $player->entity->level || $this->player->gamemode === SPECTATOR) $this->player->setInvisibleFor($player, true, send:false);
$pk = new AddPlayerPacket(); $pk = new AddPlayerPacket();
$pkm = new MovePlayerPacket();
$pk->clientID = 0; // $this->player->clientID; $pk->clientID = 0; // $this->player->clientID;
$pk->username = $this->player->username; $pk->username = $this->player->username;
$pk->eid = $this->eid; $pkm->eid = $pk->eid = $this->eid;
if($this->player->isInvisibleFor($player)){ if($this->player->isInvisibleFor($player)){
$pk->x = -256; $pkm->x = $pk->x = -256;
$pk->y = 128; $pkm->y = $pk->y = 128;
$pk->z = -256; $pkm->z = $pk->z = -256;
$pk->yaw = 0; $pkm->yaw = $pk->yaw = 0;
$pk->pitch = 0; $pkm->pitch = $pk->pitch = 0;
$pkm->bodyYaw = 0;
}else{ }else{
$pk->x = $this->x; $pkm->x = $pk->x = $this->x;
$pk->y = $this->y; $pkm->y = $pk->y = $this->y;
$pk->z = $this->z; $pkm->z = $pk->z = $this->z;
$pk->yaw = $this->yaw; $pkm->yaw = $pk->yaw = $this->yaw;
$pk->pitch = $this->pitch; $pkm->pitch = $pk->pitch = $this->pitch;
$pkm->bodyYaw = $this->headYaw;
} }
$pk->itemID = 0; $pk->itemID = 0;
$pk->itemAuxValue = 0; $pk->itemAuxValue = 0;
$pk->metadata = $this->getMetadata(); $pk->metadata = $this->getMetadata();
$player->entityQueueDataPacket($pk); $player->entityQueueDataPacket($pk);
//AddPlayerPacket doesnt read yaw correctly in vanilla(uses PacketUtil::Rot_degreesToChar instead of PacketUtil::Rot_charToDegrees)
$player->entityQueueDataPacket($pkm);
$pk = new PlayerEquipmentPacket(); $pk = new PlayerEquipmentPacket();
$pk->eid = $this->eid; $pk->eid = $this->eid;