mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
fixed world generation
This commit is contained in:
parent
1a9ce30f1a
commit
ffdeba98a7
1 changed files with 32 additions and 24 deletions
|
|
@ -37,22 +37,23 @@ class PMFLevel extends PMF{
|
||||||
private function createBlank(){
|
private function createBlank(){
|
||||||
$this->saveData(false);
|
$this->saveData(false);
|
||||||
$this->locationTable = [];
|
$this->locationTable = [];
|
||||||
$cnt = pow($this->levelData["width"], 2);
|
//$cnt = pow($this->levelData["width"], 2);
|
||||||
$dirname = dirname($this->file) . "/chunks/";
|
$dirname = dirname($this->file) . "/chunks/";
|
||||||
if(!is_dir($dirname)){
|
if(!is_dir($dirname)){
|
||||||
@mkdir($dirname , 0755);
|
@mkdir($dirname , 0755);
|
||||||
}
|
}
|
||||||
|
|
||||||
for($index = 0; $index < $cnt; ++$index){
|
for($X = 0; $X < 16; ++$X){
|
||||||
$this->chunks[$index] = false;
|
for($Z = 0; $Z < 16; ++$Z){
|
||||||
$this->chunkChange[$index] = false;
|
$index = $this->getIndex($X, $Z);
|
||||||
$this->locationTable[$index] = [
|
$this->chunks[$index] = false;
|
||||||
0 => 0,
|
$this->chunkChange[$index] = false;
|
||||||
];
|
$this->locationTable[$index] = [0 => 0,];
|
||||||
$this->write(Utils::writeShort(0));
|
$this->write(Utils::writeShort(0));
|
||||||
$X = $Z = null;
|
//$X = $Z = null;
|
||||||
$this->getXZ($index, $X, $Z);
|
//$this->getXZ($index, $X, $Z);
|
||||||
@file_put_contents($this->getChunkPath($X, $Z), gzdeflate("", PMF_LEVEL_DEFLATE_LEVEL));
|
@file_put_contents($this->getChunkPath($X, $Z), gzdeflate("", PMF_LEVEL_DEFLATE_LEVEL));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(!file_exists(dirname($this->file) . "/entities.yml")){
|
if(!file_exists(dirname($this->file) . "/entities.yml")){
|
||||||
$entities = new Config(dirname($this->file) . "/entities.yml", CONFIG_YAML);
|
$entities = new Config(dirname($this->file) . "/entities.yml", CONFIG_YAML);
|
||||||
|
|
@ -88,11 +89,13 @@ class PMFLevel extends PMF{
|
||||||
}
|
}
|
||||||
|
|
||||||
private function writeLocationTable(){
|
private function writeLocationTable(){
|
||||||
$cnt = pow($this->levelData["width"], 2);
|
//$cnt = pow($this->levelData["width"], 2);
|
||||||
@ftruncate($this->fp, $this->payloadOffset);
|
@ftruncate($this->fp, $this->payloadOffset);
|
||||||
$this->seek($this->payloadOffset);
|
$this->seek($this->payloadOffset);
|
||||||
for($index = 0; $index < $cnt; ++$index){
|
for($X = 0; $X < 16; ++$X){
|
||||||
$this->write(Utils::writeShort($this->locationTable[$index][0]));
|
for($Z = 0; $Z < 16; ++$Z){
|
||||||
|
$this->write(Utils::writeShort($this->locationTable[$this->getIndex($X, $Z)][0]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,9 +138,11 @@ class PMFLevel extends PMF{
|
||||||
$this->write(Utils::writeShort(strlen($c)) . $c);
|
$this->write(Utils::writeShort(strlen($c)) . $c);
|
||||||
$this->payloadOffset = ftell($this->fp);
|
$this->payloadOffset = ftell($this->fp);
|
||||||
$this->levelData["extra"] = "";
|
$this->levelData["extra"] = "";
|
||||||
$cnt = pow($this->levelData["width"], 2);
|
//$cnt = pow($this->levelData["width"], 2);
|
||||||
for($index = 0; $index < $cnt; ++$index){
|
for($X = 0; $X < 16; ++$X){
|
||||||
$this->write("\x00\xFF"); //Force index recreation
|
for($Z = 0; $Z < 16; ++$Z){
|
||||||
|
$this->write("\x00\xFF"); //Force index recreation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fseek($this->fp, $this->payloadOffset);
|
fseek($this->fp, $this->payloadOffset);
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -148,14 +153,17 @@ class PMFLevel extends PMF{
|
||||||
|
|
||||||
private function readLocationTable(){
|
private function readLocationTable(){
|
||||||
$this->locationTable = [];
|
$this->locationTable = [];
|
||||||
$cnt = pow($this->levelData["width"], 2);
|
//$cnt = pow($this->levelData["width"], 2);
|
||||||
$this->seek($this->payloadOffset);
|
$this->seek($this->payloadOffset);
|
||||||
for($index = 0; $index < $cnt; ++$index){
|
for($X = 0; $X < 16; ++$X){
|
||||||
$this->chunks[$index] = false;
|
for($Z = 0; $Z < 16; ++$Z){
|
||||||
$this->chunkChange[$index] = false;
|
$index = $this->getIndex($X, $Z);
|
||||||
$this->locationTable[$index] = [
|
$this->chunks[$index] = false;
|
||||||
0 => Utils::readShort($this->read(2)), //16 bit flags
|
$this->chunkChange[$index] = false;
|
||||||
];
|
$this->locationTable[$index] = [
|
||||||
|
0 => Utils::readShort($this->read(2)), //16 bit flags
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue