From 2858b43748a5f03ccfe4c632c92ca72d1c717536 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sun, 2 Jul 2023 19:08:40 +0300 Subject: [PATCH] player is spawned after 1st MOVE_PACKET is sent --- src/Player.php | 15 +++++++-------- src/entity/Entity.php | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Player.php b/src/Player.php index fe4a9783..264147d0 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1490,8 +1490,8 @@ class Player{ $this->server->api->entity->spawnAll($this); $this->server->api->entity->spawnToAll($this->entity); - $this->server->schedule(5, [$this->entity, "update"], [], true); - $this->server->schedule(2, [$this->entity, "updateMovement"], [], true); + //$this->server->schedule(5, [$this->entity, "update"], [], true); + //$this->server->schedule(2, [$this->entity, "updateMovement"], [], true); //$this->sendArmor(); $array = explode("@n", (string)$this->server->motd); foreach($array as $msg){ @@ -1507,11 +1507,6 @@ class Player{ //$this->loadAllChunks(); $this->blocked = false; - $this->spawned = true; - $this->server->handle("player.spawn", $this); - $this->server->api->chat->broadcast($this->username." joined the game"); - $this->server->api->player->spawnAllPlayers($this); - $this->server->api->player->spawnToAllPlayers($this); break; case ProtocolInfo::ROTATE_HEAD_PACKET: if($this->spawned === false){ @@ -1529,7 +1524,11 @@ class Player{ break; case ProtocolInfo::MOVE_PLAYER_PACKET: if($this->spawned === false){ - break; + $this->spawned = true; + $this->server->handle("player.spawn", $this); + $this->server->api->chat->broadcast($this->username." joined the game"); + $this->server->api->player->spawnAllPlayers($this); + $this->server->api->player->spawnToAllPlayers($this); } if(($this->entity instanceof Entity) and $packet->messageIndex > $this->lastMovement){ $this->lastMovement = $packet->messageIndex; diff --git a/src/entity/Entity.php b/src/entity/Entity.php index e8faa0d9..e4e1f7e2 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -715,6 +715,8 @@ class Entity extends Position if($this->speed <= 9 or ($this->speed <= 20 and ($this->player->gamemode & 0x01) === 0x01)){ $this->player->lastCorrect = new Vector3($this->last[0], $this->last[1], $this->last[2]); } + + $hasUpdate = true; } } if($this->knockbackTime > 0){