Correct teleporting with the new player list handling

This commit is contained in:
Shoghi Cervantes 2013-08-20 02:06:14 +02:00
parent 7102787aa9
commit bf1b00f0e6
4 changed files with 42 additions and 37 deletions

View File

@ -116,7 +116,7 @@ class EntityAPI{
public function spawnToAll(Entity $e){ public function spawnToAll(Entity $e){
foreach($this->server->api->player->getAll($e->level) as $player){ 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); $e->spawn($player);
} }
} }
@ -162,7 +162,7 @@ class EntityAPI{
$entity->closed = true; $entity->closed = true;
$this->server->query("DELETE FROM entities WHERE EID = ".$eid.";"); $this->server->query("DELETE FROM entities WHERE EID = ".$eid.";");
if($entity->class === ENTITY_PLAYER){ 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, "clientID" => 0,
"eid" => $entity->eid, "eid" => $entity->eid,
)); ));

View File

@ -706,7 +706,9 @@ 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;
@ -722,7 +724,7 @@ class Player{
"yaw" => 0, "yaw" => 0,
"pitch" => 0, "pitch" => 0,
)); ));
$player->dataPacket(MC_MOVE_ENTITY_POSROT, array( $this->dataPacket(MC_MOVE_ENTITY_POSROT, array(
"eid" => $e->eid, "eid" => $e->eid,
"x" => -256, "x" => -256,
"y" => 128, "y" => 128,
@ -748,6 +750,8 @@ class Player{
"time" => $this->level->getTime(), "time" => $this->level->getTime(),
)); ));
$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( $player->dataPacket(MC_MOVE_ENTITY_POSROT, array(
"eid" => $this->entity->eid, "eid" => $this->entity->eid,
@ -781,6 +785,7 @@ class Player{
$player->sendArmor($this); $player->sendArmor($this);
} }
} }
}
$this->lastCorrect = $pos; $this->lastCorrect = $pos;
$this->entity->fallY = false; $this->entity->fallY = false;
$this->entity->fallStart = false; $this->entity->fallStart = false;

View File

@ -266,11 +266,11 @@ class CustomPacketHandler{
break; break;
case MC_REMOVE_PLAYER: case MC_REMOVE_PLAYER:
if($this->c === false){ if($this->c === false){
$this->data["clientID"] = Utils::readLong($this->get(8));
$this->data["eid"] = Utils::readInt($this->get(4)); $this->data["eid"] = Utils::readInt($this->get(4));
$this->data["clientID"] = Utils::readLong($this->get(8));
}else{ }else{
$this->raw .= Utils::writeLong($this->data["clientID"]);
$this->raw .= Utils::writeInt($this->data["eid"]); $this->raw .= Utils::writeInt($this->data["eid"]);
$this->raw .= Utils::writeLong($this->data["clientID"]);
} }
break; break;
case MC_ADD_ENTITY: case MC_ADD_ENTITY:

View File

@ -594,7 +594,7 @@ class Entity extends Position{
} }
switch($this->class){ switch($this->class){
case ENTITY_PLAYER: case ENTITY_PLAYER:
if($this->player->connected !== true or $this->spawned === false){ if($this->player->connected !== true or $this->player->spawned === false){
return false; return false;
} }
$player->dataPacket(MC_ADD_PLAYER, array( $player->dataPacket(MC_ADD_PLAYER, array(