mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 17:59:41 +00:00
Fixed some issues with world generation and not creating chunks, closes #3008
This commit is contained in:
parent
de0f653027
commit
aa38a4885f
@ -1880,7 +1880,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
public function getChunk($x, $z, $create = false){
|
public function getChunk($x, $z, $create = false){
|
||||||
if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){
|
if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){
|
||||||
return $this->chunks[$index];
|
return $this->chunks[$index];
|
||||||
}elseif($this->loadChunk($x, $z, $create) and $this->chunks[$index] !== null){
|
}elseif($this->loadChunk($x, $z, $create)){
|
||||||
return $this->chunks[$index];
|
return $this->chunks[$index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2159,21 +2159,16 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$this->cancelUnloadChunkRequest($x, $z);
|
$this->cancelUnloadChunkRequest($x, $z);
|
||||||
|
|
||||||
$chunk = $this->provider->getChunk($x, $z, $generate);
|
$chunk = $this->provider->getChunk($x, $z, $generate);
|
||||||
if($chunk !== null){
|
if($chunk === null){
|
||||||
$this->chunks[$index] = $chunk;
|
if($generate){
|
||||||
$chunk->initChunk();
|
throw new \InvalidStateException("Could not create new Chunk");
|
||||||
}else{
|
|
||||||
$this->provider->loadChunk($x, $z, $generate);
|
|
||||||
|
|
||||||
if(($chunk = $this->provider->getChunk($x, $z)) !== null){
|
|
||||||
$this->chunks[$index] = $chunk;
|
|
||||||
$chunk->initChunk();
|
|
||||||
}else{
|
|
||||||
$this->timings->syncChunkLoadTimer->stopTiming();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->chunks[$index] = $chunk;
|
||||||
|
$chunk->initChunk();
|
||||||
|
|
||||||
if($chunk->getProvider() !== null){
|
if($chunk->getProvider() !== null){
|
||||||
$this->server->getPluginManager()->callEvent(new ChunkLoadEvent($chunk, !$chunk->isGenerated()));
|
$this->server->getPluginManager()->callEvent(new ChunkLoadEvent($chunk, !$chunk->isGenerated()));
|
||||||
}else{
|
}else{
|
||||||
|
@ -120,7 +120,7 @@ class Anvil extends McRegion{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function isChunkGenerated($chunkX, $chunkZ){
|
public function isChunkGenerated($chunkX, $chunkZ){
|
||||||
if(($region = $this->getRegion($chunkX >> 5, $chunkZ >> 5)) instanceof RegionLoader){
|
if(($region = $this->getRegion($chunkX >> 5, $chunkZ >> 5)) !== null){
|
||||||
return $region->chunkExists($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32) and $this->getChunk($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32, true)->isGenerated();
|
return $region->chunkExists($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32) and $this->getChunk($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32, true)->isGenerated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ class McRegion extends BaseLevelProvider{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function isChunkGenerated($chunkX, $chunkZ){
|
public function isChunkGenerated($chunkX, $chunkZ){
|
||||||
if(($region = $this->getRegion($chunkX >> 5, $chunkZ >> 5)) instanceof RegionLoader){
|
if(($region = $this->getRegion($chunkX >> 5, $chunkZ >> 5)) !== null){
|
||||||
return $region->chunkExists($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32) and $this->getChunk($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32, true)->isGenerated();
|
return $region->chunkExists($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32) and $this->getChunk($chunkX - $region->getX() * 32, $chunkZ - $region->getZ() * 32, true)->isGenerated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ class McRegion extends BaseLevelProvider{
|
|||||||
|
|
||||||
public function isChunkPopulated($chunkX, $chunkZ){
|
public function isChunkPopulated($chunkX, $chunkZ){
|
||||||
$chunk = $this->getChunk($chunkX, $chunkZ);
|
$chunk = $this->getChunk($chunkX, $chunkZ);
|
||||||
if($chunk instanceof FullChunk){
|
if($chunk !== null){
|
||||||
return $chunk->isPopulated();
|
return $chunk->isPopulated();
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
@ -67,7 +67,7 @@ class GenerationTask extends AsyncTask{
|
|||||||
$generator->generateChunk($chunk->getX(), $chunk->getZ());
|
$generator->generateChunk($chunk->getX(), $chunk->getZ());
|
||||||
|
|
||||||
$chunk = $manager->getChunk($chunk->getX(), $chunk->getZ());
|
$chunk = $manager->getChunk($chunk->getX(), $chunk->getZ());
|
||||||
$chunk->setGenerated(true);
|
$chunk->setGenerated();
|
||||||
$this->chunk = $chunk->toFastBinary();
|
$this->chunk = $chunk->toFastBinary();
|
||||||
|
|
||||||
$manager->setChunk($chunk->getX(), $chunk->getZ(), null);
|
$manager->setChunk($chunk->getX(), $chunk->getZ(), null);
|
||||||
|
@ -112,6 +112,7 @@ class PopulationTask extends AsyncTask{
|
|||||||
$manager->setChunk($c->getX(), $c->getZ(), $c);
|
$manager->setChunk($c->getX(), $c->getZ(), $c);
|
||||||
if(!$c->isGenerated()){
|
if(!$c->isGenerated()){
|
||||||
$generator->generateChunk($c->getX(), $c->getZ());
|
$generator->generateChunk($c->getX(), $c->getZ());
|
||||||
|
$c = $manager->getChunk($c->getX(), $c->getZ());
|
||||||
$c->setGenerated();
|
$c->setGenerated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +176,7 @@ class PopulationTask extends AsyncTask{
|
|||||||
}
|
}
|
||||||
$c = $this->{"chunk$i"};
|
$c = $this->{"chunk$i"};
|
||||||
if($c !== null){
|
if($c !== null){
|
||||||
$c = $chunkC::fromFastBinary($c);
|
$c = $chunkC::fromFastBinary($c, $level->getProvider());
|
||||||
$level->generateChunkCallback($c->getX(), $c->getZ(), $c);
|
$level->generateChunkCallback($c->getX(), $c->getZ(), $c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user