mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 15:35:31 +00:00
Added Player::setSpawn(Vector3 $pos) method
This commit is contained in:
parent
9a4c3f8c9f
commit
38950969dd
@ -321,6 +321,11 @@ class PlayerAPI{
|
|||||||
"y" => $this->server->spawn["y"],
|
"y" => $this->server->spawn["y"],
|
||||||
"z" => $this->server->spawn["z"],
|
"z" => $this->server->spawn["z"],
|
||||||
),
|
),
|
||||||
|
"spawn" => array(
|
||||||
|
"x" => $this->server->spawn["x"],
|
||||||
|
"y" => $this->server->spawn["y"],
|
||||||
|
"z" => $this->server->spawn["z"],
|
||||||
|
),
|
||||||
"inventory" => array_fill(0, 36, array(AIR, 0, 0)),
|
"inventory" => array_fill(0, 36, array(AIR, 0, 0)),
|
||||||
"armor" => array_fill(0, 4, array(AIR, 0, 0)),
|
"armor" => array_fill(0, 4, array(AIR, 0, 0)),
|
||||||
"gamemode" => $this->server->gamemode,
|
"gamemode" => $this->server->gamemode,
|
||||||
|
@ -61,6 +61,7 @@ class Player{
|
|||||||
private $chunksLoaded = array();
|
private $chunksLoaded = array();
|
||||||
private $chunksOrder = array();
|
private $chunksOrder = array();
|
||||||
private $lag = array(0, 0);
|
private $lag = array(0, 0);
|
||||||
|
private $spawnPosition;
|
||||||
public $itemEnforcement;
|
public $itemEnforcement;
|
||||||
public $lastCorrect;
|
public $lastCorrect;
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ class Player{
|
|||||||
$this->ip = $ip;
|
$this->ip = $ip;
|
||||||
$this->port = $port;
|
$this->port = $port;
|
||||||
$this->itemEnforcement = $this->server->api->getProperty("item-enforcement");
|
$this->itemEnforcement = $this->server->api->getProperty("item-enforcement");
|
||||||
|
$this->spawnPosition = new Vector3($this->server->spawn["x"], $this->server->spawn["y"], $this->server->spawn["z"]);
|
||||||
$this->timeout = microtime(true) + 20;
|
$this->timeout = microtime(true) + 20;
|
||||||
$this->inventory = array_fill(0, 36, array(AIR, 0, 0));
|
$this->inventory = array_fill(0, 36, array(AIR, 0, 0));
|
||||||
$this->armor = array_fill(0, 4, array(AIR, 0, 0));
|
$this->armor = array_fill(0, 4, array(AIR, 0, 0));
|
||||||
@ -91,6 +93,15 @@ class Player{
|
|||||||
console("[DEBUG] New Session started with ".$ip.":".$port.". MTU ".$this->MTU.", Client ID ".$this->clientID, true, true, 2);
|
console("[DEBUG] New Session started with ".$ip.":".$port.". MTU ".$this->MTU.", Client ID ".$this->clientID, true, true, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setSpawn(Vector3 $pos){
|
||||||
|
$this->spawnPosition = $pos;
|
||||||
|
$this->dataPacket(MC_SET_SPAWN_POSITION, array(
|
||||||
|
"x" => (int) $this->spawnPosition->x,
|
||||||
|
"y" => (int) $this->spawnPosition->y,
|
||||||
|
"z" => (int) $this->spawnPosition->z,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public function orderChunks(){
|
public function orderChunks(){
|
||||||
if(!($this->entity instanceof Entity)){
|
if(!($this->entity instanceof Entity)){
|
||||||
return false;
|
return false;
|
||||||
@ -190,6 +201,11 @@ class Player{
|
|||||||
"y" => $this->entity->y,
|
"y" => $this->entity->y,
|
||||||
"z" => $this->entity->z,
|
"z" => $this->entity->z,
|
||||||
));
|
));
|
||||||
|
$this->data->set("spawn", array(
|
||||||
|
"x" => $this->spawnPosition->x,
|
||||||
|
"y" => $this->spawnPosition->y,
|
||||||
|
"z" => $this->spawnPosition->z,
|
||||||
|
));
|
||||||
$this->data->set("inventory", $this->inventory);
|
$this->data->set("inventory", $this->inventory);
|
||||||
$this->data->set("armor", $this->armor);
|
$this->data->set("armor", $this->armor);
|
||||||
$this->data->set("gamemode", $this->gamemode);
|
$this->data->set("gamemode", $this->gamemode);
|
||||||
@ -865,11 +881,7 @@ class Player{
|
|||||||
$this->server->schedule(50, array($this, "orderChunks"), array(), true);
|
$this->server->schedule(50, array($this, "orderChunks"), array(), true);
|
||||||
$this->blocked = false;
|
$this->blocked = false;
|
||||||
$this->teleport(new Vector3($this->data->get("position")["x"], $this->data->get("position")["y"], $this->data->get("position")["z"]));
|
$this->teleport(new Vector3($this->data->get("position")["x"], $this->data->get("position")["y"], $this->data->get("position")["z"]));
|
||||||
$this->dataPacket(MC_SET_SPAWN_POSITION, array(
|
$this->setSpawn(new Vector3($this->data->get("spawn")["x"], $this->data->get("spawn")["y"], $this->data->get("spawn")["z"]));
|
||||||
"x" => (int) $this->server->spawn["x"],
|
|
||||||
"y" => (int) $this->server->spawn["y"],
|
|
||||||
"z" => (int) $this->server->spawn["z"],
|
|
||||||
));
|
|
||||||
break;
|
break;
|
||||||
case 2://Chunk loaded?
|
case 2://Chunk loaded?
|
||||||
break;
|
break;
|
||||||
@ -1035,7 +1047,7 @@ class Player{
|
|||||||
$this->entity->setHealth(20, "respawn");
|
$this->entity->setHealth(20, "respawn");
|
||||||
$this->entity->updateMetadata();
|
$this->entity->updateMetadata();
|
||||||
$this->sendInventory();
|
$this->sendInventory();
|
||||||
$this->teleport(new Vector3($this->server->spawn["x"], $this->server->spawn["y"], $this->server->spawn["z"]));
|
$this->teleport($this->spawnPosition);
|
||||||
break;
|
break;
|
||||||
case MC_SET_HEALTH:
|
case MC_SET_HEALTH:
|
||||||
if($this->spawned === false){
|
if($this->spawned === false){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user