From e9c46da7f094ce468697ebf71f62ac6faad15166 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 21 Jun 2017 11:27:20 +0100 Subject: [PATCH] Fixed glitching on respawn due to player 1.62 position offset --- src/pocketmine/Player.php | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index ee11ca180..7e5e8f46c 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -886,11 +886,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pos = $ev->getRespawnPosition(); - $pk = new RespawnPacket(); - $pk->x = $pos->x; - $pk->y = $pos->y; - $pk->z = $pos->z; - $this->dataPacket($pk); + $this->sendRespawnPacket($pos); $this->sendPlayStatus(PlayStatusPacket::PLAYER_SPAWN); @@ -930,17 +926,20 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } if($this->getHealth() <= 0){ - $pk = new RespawnPacket(); - $pos = $this->getSpawn(); - $pk->x = $pos->x; - $pk->y = $pos->y; - $pk->z = $pos->z; - $this->dataPacket($pk); + $this->sendRespawnPacket($this->getSpawn()); } $this->joined = true; } + protected function sendRespawnPacket(Vector3 $pos){ + $pk = new RespawnPacket(); + $pk->x = $pos->x; + $pk->y = $pos->y + $this->baseOffset; + $pk->z = $pos->z; + $this->dataPacket($pk); + } + protected function orderChunks(){ if($this->connected === false or $this->viewDistance === -1){ return false; @@ -3796,12 +3795,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade parent::kill(); - $pk = new RespawnPacket(); - $pos = $this->getSpawn(); - $pk->x = $pos->x; - $pk->y = $pos->y; - $pk->z = $pos->z; - $this->dataPacket($pk); + $this->sendRespawnPacket($this->getSpawn()); } protected function callDeathEvent(){