mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
Correct teleporting with the new player list handling
This commit is contained in:
parent
7102787aa9
commit
bf1b00f0e6
@ -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,
|
||||
));
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user