diff --git a/src/Player.php b/src/Player.php index 5c68f789..e7948c9b 100755 --- a/src/Player.php +++ b/src/Player.php @@ -6,6 +6,9 @@ class Player{ public $data; /** @var Entity */ public $entity = false; + + private $generator = 0; //TODO modify in config? + public $auth = false; public $CID; public $MTU; @@ -402,8 +405,12 @@ class Player{ $X = $this->entity->x >> 4; $Z = $this->entity->z >> 4; $this->chunksOrder = []; - for($x = 0; $x < 16; ++$x){ - for($z = 0; $z < 16; ++$z){ + $startX = $this->generator === 1 ? $X - 4 : 0; + $stopX = $this->generator === 1 ? $X + 4 : 15; + $startZ = $this->generator === 1 ? $X - 4 : 0; + $stopZ = $this->generator === 1 ? $X + 4 : 15; + for($x = $startX; $x <= $stopX; ++$x){ + for($z = $startZ; $z <= $stopZ; ++$z){ $d = $x . ":" . $z; //if($x < 0 || $x > 15 || $z < 0 || $z > 15) continue; //TODO infinite worlds if(!isset($this->chunksLoaded[$d])){ @@ -496,7 +503,6 @@ class Player{ $z = $Z << 4; $this->level->useChunk($X, $Z, $this); $this->chunksLoaded["$X:$Z"] = true; - console("chunk upd nxt $X:$Z"); $pk = new FullChunkDataPacket; $pk->chunkX = $X; $pk->chunkZ = $Z; @@ -945,7 +951,7 @@ class Player{ $pk->spawnX = $spwnPos->x; $pk->spawnY = $spwnPos->y; $pk->spawnZ = $spwnPos->z; - $pk->generator = 0; //TODO multiple generators + $pk->generator = $this->generator; $pk->gamemode = $this->gamemode & 0x01; $pk->eid = 0; $this->dataPacket($pk); @@ -1410,13 +1416,13 @@ class Player{ $pk->spawnY = (int) $spawnPos->y; $pk->spawnZ = (int) $spawnPos->z; $pk->x = (int) $this->entity->x; - $pk->y = (int) $this->entity->x; - $pk->z = (int) $this->entity->x; - $pk->generator = 0; //1 - inf, 0 - old, 2 - flat + $pk->y = (int) $this->entity->y; + $pk->z = (int) $this->entity->z; + $pk->generator = $this->generator; //1 - inf, 0 - old, 2 - flat $pk->gamemode = $this->gamemode & 0x01; $pk->eid = 0; $this->dataPacket($pk); - $this->entity->check = false; + //$this->entity->check = false; whaT? $this->entity->setName($this->username); $this->entity->data["CID"] = $this->CID; $this->evid[] = $this->server->event("server.chat", [$this, "eventHandler"]); diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index a9a3965d..102738d3 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -24,7 +24,7 @@ class PocketMinecraftServer{ private function load(){ global $dolog; - + $this->version = new VersionString(); /*if(defined("DEBUG") and DEBUG >= 0){ @cli_set_process_title("NostalgiaCore ".MAJOR_VERSION); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 60e9ba22..59208c70 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -492,12 +492,12 @@ class Entity extends Position if($this->closed === true){ return false; } + $now = microtime(true); if($this->check === false){ $this->lastUpdate = $now; return; } - $tdiff = $now - $this->lastUpdate; if($this->tickCounter === 0){ $this->tickCounter = 1; diff --git a/src/network/protocol/packet/StartGamePacket.php b/src/network/protocol/packet/StartGamePacket.php index e617ad9a..7a198007 100644 --- a/src/network/protocol/packet/StartGamePacket.php +++ b/src/network/protocol/packet/StartGamePacket.php @@ -12,7 +12,6 @@ class StartGamePacket extends RakNetDataPacket{ } public function decode(){ - } public function encode(){