/place testing and fixed players on join

This commit is contained in:
ArkQuark 2023-03-08 00:16:12 +03:00
parent 1d6f5be6dc
commit 0518df4484
3 changed files with 11 additions and 3 deletions

View file

@ -18,6 +18,7 @@ class LevelAPI{
$this->server->api->console->register("save-on", "", [$this, "commandHandler"]);
$this->server->api->console->register("save-off", "", [$this, "commandHandler"]);
$this->server->api->console->register("setwspawn", "Set the spawn position for your current world. ", [$this, "commandHandler"]);
$this->server->api->console->register("place", "", [$this, "commandHandler"]);
$this->default = $this->server->api->getProperty("level-name");
if($this->loadLevel($this->default) === false){
$this->generateLevel($this->default, $this->server->seed);
@ -160,6 +161,11 @@ class LevelAPI{
public function commandHandler($cmd, $params, $issuer, $alias){
$output = "";
switch($cmd){
case "place":
if(!isset($params[0]) or $params[0] == "") return "/$cmd <feature class>";
$class = $params[0];
(new $class())->build($issuer->entity->level, $issuer->entity->x, $issuer->entity->y, $issuer->entity->z);
break;
case "setwspawn":
if(!($issuer instanceof Player)){
return ("Please run this command in-game. ");

View file

@ -1482,11 +1482,10 @@ class Player{
//$this->server->schedule(20, array($this, "teleport"), $pos);
//$this->teleport($pos, isset($pData["yaw"]) ? $pData["yaw"] : false, isset($pData["pitch"]) ? $pData["pitch"] : false, true, true);
$this->entity->setHealth($this->data->get("health"), "spawn", true);
$this->server->api->player->spawnAllPlayers($this);
$this->server->api->player->spawnToAllPlayers($this);
$this->server->api->chat->broadcast($this->username." joined the game");
$this->server->api->entity->spawnAll($this);
$this->server->api->entity->spawnToAll($this->entity);
$this->server->api->chat->broadcast($this->username." joined the game");
$this->server->schedule(5, [$this->entity, "update"], [], true);
$this->server->schedule(2, [$this->entity, "updateMovement"], [], true);
@ -1507,6 +1506,8 @@ class Player{
$this->blocked = false;
$this->spawned = true;
$this->server->handle("player.spawn", $this);
$this->server->api->player->spawnAllPlayers($this);
$this->server->api->player->spawnToAllPlayers($this);
break;
case ProtocolInfo::ROTATE_HEAD_PACKET:
if($this->spawned === false){

View file

@ -123,6 +123,7 @@ abstract class Structure{
}
$offsetZ = 0;
}
console("builded! ".$this->name);
}
}