Rewrote a bit of Player::teleport()

This commit is contained in:
Shoghi Cervantes 2013-08-21 14:57:13 +02:00
parent f7abb6f909
commit e0390d0f54

View File

@ -718,13 +718,12 @@ class Player{
return false; return false;
} }
$newlevel = false;
if($pos instanceof Position and $pos->level !== $this->level){ 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){ if($this->server->api->dhandle("player.teleport.level", array("player" => $this, "origin" => $this->level, "target" => $pos->level)) === false){
$this->entity->check = true; $this->entity->check = true;
return false; return false;
} }
foreach($this->server->api->entity->getAll($this->level) as $e){ foreach($this->server->api->entity->getAll($this->level) as $e){
if($e !== $this->entity){ if($e !== $this->entity){
if($e->player instanceof Player){ if($e->player instanceof Player){
@ -763,16 +762,8 @@ class Player{
)); ));
$terrain = true; $terrain = true;
if($newLevel === true){
foreach($this->server->api->player->getAll($this->level) as $player){ foreach($this->server->api->player->getAll($this->level) as $player){
$player->dataPacket(MC_MOVE_ENTITY_POSROT, array( if($player !== $this and $player->entity instanceof Entity){
"eid" => $this->entity->eid,
"x" => $pos->x,
"y" => $pos->y,
"z" => $pos->z,
"yaw" => $yaw,
"pitch" => $pitch,
));
$this->dataPacket(MC_MOVE_ENTITY_POSROT, array( $this->dataPacket(MC_MOVE_ENTITY_POSROT, array(
"eid" => $player->entity->eid, "eid" => $player->entity->eid,
"x" => $player->entity->x, "x" => $player->entity->x,
@ -798,6 +789,7 @@ class Player{
} }
} }
} }
$this->lastCorrect = $pos; $this->lastCorrect = $pos;
$this->entity->fallY = false; $this->entity->fallY = false;
$this->entity->fallStart = false; $this->entity->fallStart = false;