AddPlayerPacket is sent directly now

This commit is contained in:
GameHerobrine 2024-06-08 06:35:38 +03:00
parent 2a47f92d9a
commit c3b09096b4
5 changed files with 13 additions and 9 deletions

View file

@ -1194,8 +1194,9 @@ class Player{
foreach($this->resendQueue as $count => $data){ foreach($this->resendQueue as $count => $data){
unset($this->resendQueue[$count]); unset($this->resendQueue[$count]);
$this->packetStats[1]++; $this->packetStats[1]++;
$this->lag[] = microtime(true) - $data->sendtime; $this->lag[] = $time - $data->sendtime;
$data->sendtime = microtime(true); $data->sendtime = $time;
$cnt = $this->send($data); $cnt = $this->send($data);
if(isset($this->chunkCount[$count])){ if(isset($this->chunkCount[$count])){
unset($this->chunkCount[$count]); unset($this->chunkCount[$count]);
@ -2649,13 +2650,14 @@ class Player{
public function handlePacket(RakNetPacket $packet){ public function handlePacket(RakNetPacket $packet){
if($this->connected === true){ if($this->connected === true){
$this->timeout = microtime(true) + 20; $time = microtime(true);
$this->timeout = $time + 20;
switch($packet->pid()){ switch($packet->pid()){
case RakNetInfo::NACK: case RakNetInfo::NACK:
foreach($packet->packets as $count){ foreach($packet->packets as $count){
if(isset($this->recoveryQueue[$count])){ if(isset($this->recoveryQueue[$count])){
$this->resendQueue[$count] =& $this->recoveryQueue[$count]; $this->resendQueue[$count] =& $this->recoveryQueue[$count];
$this->lag[] = microtime(true) - $this->recoveryQueue[$count]->sendtime; $this->lag[] = $time - $this->recoveryQueue[$count]->sendtime;
unset($this->recoveryQueue[$count]); unset($this->recoveryQueue[$count]);
} }
++$this->packetStats[1]; ++$this->packetStats[1];
@ -2665,7 +2667,7 @@ class Player{
case RakNetInfo::ACK: case RakNetInfo::ACK:
foreach($packet->packets as $count){ foreach($packet->packets as $count){
if(isset($this->recoveryQueue[$count])){ if(isset($this->recoveryQueue[$count])){
$this->lag[] = microtime(true) - $this->recoveryQueue[$count]->sendtime; $this->lag[] = $time - $this->recoveryQueue[$count]->sendtime;
unset($this->recoveryQueue[$count]); unset($this->recoveryQueue[$count]);
unset($this->resendQueue[$count]); unset($this->resendQueue[$count]);
} }

View file

@ -447,6 +447,7 @@ class PocketMinecraftServer{
if(!is_callable($callback)){ if(!is_callable($callback)){
return false; return false;
} }
$chcnt = $this->scheduleCnt++; $chcnt = $this->scheduleCnt++;
$this->schedule[$chcnt] = [$callback, $data, $eventName]; $this->schedule[$chcnt] = [$callback, $data, $eventName];
$this->query("INSERT INTO actions (ID, interval, last, repeat) VALUES(" . $chcnt . ", " . ($ticks / 20) . ", " . microtime(true) . ", " . (((bool) $repeat) === true ? 1 : 0) . ");"); $this->query("INSERT INTO actions (ID, interval, last, repeat) VALUES(" . $chcnt . ", " . ($ticks / 20) . ", " . microtime(true) . ", " . (((bool) $repeat) === true ? 1 : 0) . ");");
@ -604,7 +605,8 @@ class PocketMinecraftServer{
foreach($this->api->level->levels as $l){ foreach($this->api->level->levels as $l){
$l->onTick($this, $time); $l->onTick($this, $time);
} }
return $this->tickerFunction($time); $r = $this->tickerFunction($time);
return $r;
} }
return 0; return 0;
} }

View file

@ -1081,7 +1081,7 @@ class Entity extends Position
$pk->itemID = 0; $pk->itemID = 0;
$pk->itemAuxValue = 0; $pk->itemAuxValue = 0;
$pk->metadata = $this->getMetadata(); $pk->metadata = $this->getMetadata();
$player->dataPacket($pk); $player->directDataPacket($pk, 2, true);
$pk = new SetEntityMotionPacket(); $pk = new SetEntityMotionPacket();
$pk->eid = $this->eid; $pk->eid = $this->eid;

View file

@ -6,7 +6,7 @@ class AxisAlignedBB{
public $maxX; public $maxX;
public $maxY; public $maxY;
public $maxZ; public $maxZ;
public function __construct($minX, $minY, $minZ, $maxX, $maxY, $maxZ){ public function __construct($minX, $minY, $minZ, $maxX, $maxY, $maxZ){
$this->minX = $minX; $this->minX = $minX;
$this->minY = $minY; $this->minY = $minY;

View file

@ -2,7 +2,7 @@
class Vector3{ class Vector3{
public $x, $y, $z; public $x, $y, $z;
public function __construct($x = 0, $y = 0, $z = 0){ public function __construct($x = 0, $y = 0, $z = 0){
$this->x = $x; $this->x = $x;
$this->y = $y; $this->y = $y;