From e5ec8fa60394d8f87cd17b24cb6434136e69dd0d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 24 Feb 2018 12:25:25 +0000 Subject: [PATCH] Entity: Use MoveEntityPacket teleport flag for teleporting fixes entities getting movement interpolation between origin and destination --- src/pocketmine/Player.php | 2 +- src/pocketmine/entity/Entity.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 1e681320e..6dbb4ebea 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1615,7 +1615,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return false; } - protected function updateMovement(){ + protected function updateMovement(bool $teleport = false){ } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 4ea2b0ab0..0236a62a4 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1085,13 +1085,13 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return true; } - protected function updateMovement(){ + protected function updateMovement(bool $teleport = false){ $diffPosition = ($this->x - $this->lastX) ** 2 + ($this->y - $this->lastY) ** 2 + ($this->z - $this->lastZ) ** 2; $diffRotation = ($this->yaw - $this->lastYaw) ** 2 + ($this->pitch - $this->lastPitch) ** 2; $diffMotion = ($this->motionX - $this->lastMotionX) ** 2 + ($this->motionY - $this->lastMotionY) ** 2 + ($this->motionZ - $this->lastMotionZ) ** 2; - if($diffPosition > 0.0001 or $diffRotation > 1.0){ + if($teleport or $diffPosition > 0.0001 or $diffRotation > 1.0){ $this->lastX = $this->x; $this->lastY = $this->y; $this->lastZ = $this->z; @@ -1099,7 +1099,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->lastYaw = $this->yaw; $this->lastPitch = $this->pitch; - $this->broadcastMovement(); + $this->broadcastMovement($teleport); } if($diffMotion > 0.0025 or ($diffMotion > 0.0001 and $this->getMotion()->lengthSquared() <= 0.0001)){ //0.05 ** 2 @@ -1115,7 +1115,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return new Vector3($vector3->x, $vector3->y + $this->baseOffset, $vector3->z); } - protected function broadcastMovement(){ + protected function broadcastMovement(bool $teleport = false){ if($this->chunk !== null){ $pk = new MoveEntityPacket(); $pk->entityRuntimeId = $this->id; @@ -1123,6 +1123,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->headYaw = $this->yaw; //TODO + $pk->teleported = $teleport; $this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk); } @@ -1846,7 +1847,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->resetFallDistance(); $this->onGround = true; - $this->updateMovement(); + $this->updateMovement(true); return true; }