mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
some infinite chunk loading tweaks
This commit is contained in:
parent
16ba004fd6
commit
844caa3687
4 changed files with 16 additions and 11 deletions
|
|
@ -6,6 +6,9 @@ class Player{
|
||||||
public $data;
|
public $data;
|
||||||
/** @var Entity */
|
/** @var Entity */
|
||||||
public $entity = false;
|
public $entity = false;
|
||||||
|
|
||||||
|
private $generator = 0; //TODO modify in config?
|
||||||
|
|
||||||
public $auth = false;
|
public $auth = false;
|
||||||
public $CID;
|
public $CID;
|
||||||
public $MTU;
|
public $MTU;
|
||||||
|
|
@ -402,8 +405,12 @@ class Player{
|
||||||
$X = $this->entity->x >> 4;
|
$X = $this->entity->x >> 4;
|
||||||
$Z = $this->entity->z >> 4;
|
$Z = $this->entity->z >> 4;
|
||||||
$this->chunksOrder = [];
|
$this->chunksOrder = [];
|
||||||
for($x = 0; $x < 16; ++$x){
|
$startX = $this->generator === 1 ? $X - 4 : 0;
|
||||||
for($z = 0; $z < 16; ++$z){
|
$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;
|
$d = $x . ":" . $z;
|
||||||
//if($x < 0 || $x > 15 || $z < 0 || $z > 15) continue; //TODO infinite worlds
|
//if($x < 0 || $x > 15 || $z < 0 || $z > 15) continue; //TODO infinite worlds
|
||||||
if(!isset($this->chunksLoaded[$d])){
|
if(!isset($this->chunksLoaded[$d])){
|
||||||
|
|
@ -496,7 +503,6 @@ class Player{
|
||||||
$z = $Z << 4;
|
$z = $Z << 4;
|
||||||
$this->level->useChunk($X, $Z, $this);
|
$this->level->useChunk($X, $Z, $this);
|
||||||
$this->chunksLoaded["$X:$Z"] = true;
|
$this->chunksLoaded["$X:$Z"] = true;
|
||||||
console("chunk upd nxt $X:$Z");
|
|
||||||
$pk = new FullChunkDataPacket;
|
$pk = new FullChunkDataPacket;
|
||||||
$pk->chunkX = $X;
|
$pk->chunkX = $X;
|
||||||
$pk->chunkZ = $Z;
|
$pk->chunkZ = $Z;
|
||||||
|
|
@ -945,7 +951,7 @@ class Player{
|
||||||
$pk->spawnX = $spwnPos->x;
|
$pk->spawnX = $spwnPos->x;
|
||||||
$pk->spawnY = $spwnPos->y;
|
$pk->spawnY = $spwnPos->y;
|
||||||
$pk->spawnZ = $spwnPos->z;
|
$pk->spawnZ = $spwnPos->z;
|
||||||
$pk->generator = 0; //TODO multiple generators
|
$pk->generator = $this->generator;
|
||||||
$pk->gamemode = $this->gamemode & 0x01;
|
$pk->gamemode = $this->gamemode & 0x01;
|
||||||
$pk->eid = 0;
|
$pk->eid = 0;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
|
|
@ -1410,13 +1416,13 @@ class Player{
|
||||||
$pk->spawnY = (int) $spawnPos->y;
|
$pk->spawnY = (int) $spawnPos->y;
|
||||||
$pk->spawnZ = (int) $spawnPos->z;
|
$pk->spawnZ = (int) $spawnPos->z;
|
||||||
$pk->x = (int) $this->entity->x;
|
$pk->x = (int) $this->entity->x;
|
||||||
$pk->y = (int) $this->entity->x;
|
$pk->y = (int) $this->entity->y;
|
||||||
$pk->z = (int) $this->entity->x;
|
$pk->z = (int) $this->entity->z;
|
||||||
$pk->generator = 0; //1 - inf, 0 - old, 2 - flat
|
$pk->generator = $this->generator; //1 - inf, 0 - old, 2 - flat
|
||||||
$pk->gamemode = $this->gamemode & 0x01;
|
$pk->gamemode = $this->gamemode & 0x01;
|
||||||
$pk->eid = 0;
|
$pk->eid = 0;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
$this->entity->check = false;
|
//$this->entity->check = false; whaT?
|
||||||
$this->entity->setName($this->username);
|
$this->entity->setName($this->username);
|
||||||
$this->entity->data["CID"] = $this->CID;
|
$this->entity->data["CID"] = $this->CID;
|
||||||
$this->evid[] = $this->server->event("server.chat", [$this, "eventHandler"]);
|
$this->evid[] = $this->server->event("server.chat", [$this, "eventHandler"]);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class PocketMinecraftServer{
|
||||||
|
|
||||||
private function load(){
|
private function load(){
|
||||||
global $dolog;
|
global $dolog;
|
||||||
|
|
||||||
$this->version = new VersionString();
|
$this->version = new VersionString();
|
||||||
/*if(defined("DEBUG") and DEBUG >= 0){
|
/*if(defined("DEBUG") and DEBUG >= 0){
|
||||||
@cli_set_process_title("NostalgiaCore ".MAJOR_VERSION);
|
@cli_set_process_title("NostalgiaCore ".MAJOR_VERSION);
|
||||||
|
|
|
||||||
|
|
@ -492,12 +492,12 @@ class Entity extends Position
|
||||||
if($this->closed === true){
|
if($this->closed === true){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$now = microtime(true);
|
$now = microtime(true);
|
||||||
if($this->check === false){
|
if($this->check === false){
|
||||||
$this->lastUpdate = $now;
|
$this->lastUpdate = $now;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tdiff = $now - $this->lastUpdate;
|
$tdiff = $now - $this->lastUpdate;
|
||||||
if($this->tickCounter === 0){
|
if($this->tickCounter === 0){
|
||||||
$this->tickCounter = 1;
|
$this->tickCounter = 1;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ class StartGamePacket extends RakNetDataPacket{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function decode(){
|
public function decode(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function encode(){
|
public function encode(){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue