diff --git a/src/API/EntityAPI.php b/src/API/EntityAPI.php index c24e4508b..a1407c46d 100644 --- a/src/API/EntityAPI.php +++ b/src/API/EntityAPI.php @@ -116,7 +116,7 @@ class EntityAPI{ public function spawnToAll(Entity $e){ foreach($this->server->api->player->getAll($e->level) as $player){ - if($player->eid !== false and $player->eid !== $e->eid){ + if($player->eid !== false and $player->eid !== $e->eid and $e->class !== ENTITY_PLAYER){ $e->spawn($player); } } @@ -162,7 +162,7 @@ class EntityAPI{ $entity->closed = true; $this->server->query("DELETE FROM entities WHERE EID = ".$eid.";"); if($entity->class === ENTITY_PLAYER){ - $this->server->api->player->broadcastPacket($this->server->api->player->getAll($entity->level), MC_REMOVE_PLAYER, array( + $this->server->api->player->broadcastPacket($this->server->api->player->getAll(), MC_REMOVE_PLAYER, array( "clientID" => 0, "eid" => $entity->eid, )); diff --git a/src/Player.php b/src/Player.php index 24577058b..5db8b5182 100644 --- a/src/Player.php +++ b/src/Player.php @@ -706,7 +706,9 @@ class Player{ return false; } + $newlevel = false; if($pos instanceof Position and $pos->level !== $this->level){ + $newLevel = true; if($this->server->api->dhandle("player.teleport.level", array("player" => $this, "origin" => $this->level, "target" => $pos->level)) === false){ $this->entity->check = true; return false; @@ -722,7 +724,7 @@ class Player{ "yaw" => 0, "pitch" => 0, )); - $player->dataPacket(MC_MOVE_ENTITY_POSROT, array( + $this->dataPacket(MC_MOVE_ENTITY_POSROT, array( "eid" => $e->eid, "x" => -256, "y" => 128, @@ -748,37 +750,40 @@ class Player{ "time" => $this->level->getTime(), )); $terrain = true; - foreach($this->server->api->player->getAll($this->level) as $player){ - $player->dataPacket(MC_MOVE_ENTITY_POSROT, array( - "eid" => $this->entity->eid, - "x" => $pos->x, - "y" => $pos->y, - "z" => $pos->z, - "yaw" => $yaw, - "pitch" => $pitch, - )); - $this->dataPacket(MC_MOVE_ENTITY_POSROT, array( - "eid" => $player->entity->eid, - "x" => $player->entity->x, - "y" => $player->entity->y, - "z" => $player->entity->z, - "yaw" => $player->entity->yaw, - "pitch" => $player->entity->pitch, - )); - $player->dataPacket(MC_PLAYER_EQUIPMENT, array( - "eid" => $this->eid, - "block" => $this->getSlot($this->slot)->getID(), - "meta" => $this->getSlot($this->slot)->getMetadata(), - "slot" => 0, - )); - $this->sendArmor($player); - $this->dataPacket(MC_PLAYER_EQUIPMENT, array( - "eid" => $player->eid, - "block" => $player->getSlot($player->slot)->getID(), - "meta" => $player->getSlot($player->slot)->getMetadata(), - "slot" => 0, - )); - $player->sendArmor($this); + + if($newLevel === true){ + foreach($this->server->api->player->getAll($this->level) as $player){ + $player->dataPacket(MC_MOVE_ENTITY_POSROT, array( + "eid" => $this->entity->eid, + "x" => $pos->x, + "y" => $pos->y, + "z" => $pos->z, + "yaw" => $yaw, + "pitch" => $pitch, + )); + $this->dataPacket(MC_MOVE_ENTITY_POSROT, array( + "eid" => $player->entity->eid, + "x" => $player->entity->x, + "y" => $player->entity->y, + "z" => $player->entity->z, + "yaw" => $player->entity->yaw, + "pitch" => $player->entity->pitch, + )); + $player->dataPacket(MC_PLAYER_EQUIPMENT, array( + "eid" => $this->eid, + "block" => $this->getSlot($this->slot)->getID(), + "meta" => $this->getSlot($this->slot)->getMetadata(), + "slot" => 0, + )); + $this->sendArmor($player); + $this->dataPacket(MC_PLAYER_EQUIPMENT, array( + "eid" => $player->eid, + "block" => $player->getSlot($player->slot)->getID(), + "meta" => $player->getSlot($player->slot)->getMetadata(), + "slot" => 0, + )); + $player->sendArmor($this); + } } } $this->lastCorrect = $pos; diff --git a/src/network/CustomPacketHandler.php b/src/network/CustomPacketHandler.php index b03821bb5..7a3dc9667 100644 --- a/src/network/CustomPacketHandler.php +++ b/src/network/CustomPacketHandler.php @@ -266,11 +266,11 @@ class CustomPacketHandler{ break; case MC_REMOVE_PLAYER: if($this->c === false){ - $this->data["clientID"] = Utils::readLong($this->get(8)); $this->data["eid"] = Utils::readInt($this->get(4)); + $this->data["clientID"] = Utils::readLong($this->get(8)); }else{ - $this->raw .= Utils::writeLong($this->data["clientID"]); $this->raw .= Utils::writeInt($this->data["eid"]); + $this->raw .= Utils::writeLong($this->data["clientID"]); } break; case MC_ADD_ENTITY: diff --git a/src/world/Entity.php b/src/world/Entity.php index a60295549..5d0bf93be 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -594,7 +594,7 @@ class Entity extends Position{ } switch($this->class){ case ENTITY_PLAYER: - if($this->player->connected !== true or $this->spawned === false){ + if($this->player->connected !== true or $this->player->spawned === false){ return false; } $player->dataPacket(MC_ADD_PLAYER, array(