diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index eb663445c..d9ec1dfeb 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1361,9 +1361,9 @@ class Server{ LevelProviderManager::addProvider($this, "pocketmine\\level\\format\\anvil\\Anvil"); - //Generator::addGenerator("pocketmine\\level\\generator\\Flat", "flat"); - //Generator::addGenerator("pocketmine\\level\\generator\\Normal", "normal"); - //Generator::addGenerator("pocketmine\\level\\generator\\Normal", "default"); + Generator::addGenerator("pocketmine\\level\\generator\\Flat", "flat"); + Generator::addGenerator("pocketmine\\level\\generator\\Normal", "normal"); + Generator::addGenerator("pocketmine\\level\\generator\\Normal", "default"); if($this->getDefaultLevel() === null){ $default = $this->getConfigString("level-name", "world"); diff --git a/src/pocketmine/level/generator/GenerationChunkManager.php b/src/pocketmine/level/generator/GenerationChunkManager.php index ee7e56671..2e4a348ab 100644 --- a/src/pocketmine/level/generator/GenerationChunkManager.php +++ b/src/pocketmine/level/generator/GenerationChunkManager.php @@ -122,9 +122,11 @@ class GenerationChunkManager implements ChunkManager{ protected function requestChunk($chunkX, $chunkZ){ $chunk = $this->manager->requestChunk($this->levelID, $chunkX, $chunkZ); - $this->chunks[Level::chunkHash($chunkX, $chunkZ)] = $chunk; - - return $chunk; + $this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)] = $chunk; + if(!$chunk->isGenerated()){ + $this->generateChunk($chunkX, $chunkZ); + } + return $this->chunks[$index]; } /** diff --git a/src/pocketmine/level/generator/Generator.php b/src/pocketmine/level/generator/Generator.php index 8541d405e..38a524a10 100644 --- a/src/pocketmine/level/generator/Generator.php +++ b/src/pocketmine/level/generator/Generator.php @@ -44,8 +44,7 @@ abstract class Generator{ return Generator::$list[$name]; } - //return "pocketmine\\level\\generator\\Normal"; - return "pocketmine\\level\\generator\\Flat"; + return "pocketmine\\level\\generator\\Normal"; } public static function getGeneratorName($class){ diff --git a/src/pocketmine/level/generator/Normal.php b/src/pocketmine/level/generator/Normal.php index 729ddf39e..f68339b73 100644 --- a/src/pocketmine/level/generator/Normal.php +++ b/src/pocketmine/level/generator/Normal.php @@ -29,6 +29,7 @@ use pocketmine\block\Gravel; use pocketmine\block\IronOre; use pocketmine\block\LapisOre; use pocketmine\block\RedstoneOre; +use pocketmine\item\Block; use pocketmine\level\generator\noise\Simplex; use pocketmine\level\generator\object\OreType; use pocketmine\level\generator\populator\Ore; @@ -119,8 +120,9 @@ class Normal extends Generator{ } } + $chunk = $this->level->getChunk($chunkX, $chunkZ); + for($chunkY = 0; $chunkY < 8; ++$chunkY){ - $chunk = ""; $startY = $chunkY << 4; $endY = $startY + 16; for($z = 0; $z < 16; ++$z){ @@ -132,47 +134,44 @@ class Normal extends Generator{ for($y = $startY; $y < $endY; ++$y){ $diff = $height - $y; if($y <= 4 and ($y === 0 or $this->random->nextFloat() < 0.75)){ - $chunk .= "\x07"; //bedrock + $chunk->setBlockId($x, $y, $z, Block::BEDROCK); }elseif($diff > 2){ - $chunk .= "\x01"; //stone + $chunk->setBlockId($x, $y, $z, Block::STONE); }elseif($diff > 0){ if($patches[$i] > 0.7){ - $chunk .= "\x01"; //stone + $chunk->setBlockId($x, $y, $z, Block::STONE); }elseif($patches[$i] < -0.8){ - $chunk .= "\x0d"; //gravel + $chunk->setBlockId($x, $y, $z, Block::GRAVEL); }else{ - $chunk .= "\x03"; //dirt + $chunk->setBlockId($x, $y, $z, Block::DIRT); } }elseif($y <= $this->waterHeight){ if(($this->waterHeight - $y) <= 1 and $diff === 0){ - $chunk .= "\x0c"; //sand + $chunk->setBlockId($x, $y, $z, Block::SAND); }elseif($diff === 0){ if($patchesSmall[$i] > 0.3){ - $chunk .= "\x0d"; //gravel + $chunk->setBlockId($x, $y, $z, Block::GRAVEL); }elseif($patchesSmall[$i] < -0.45){ - $chunk .= "\x0c"; //sand + $chunk->setBlockId($x, $y, $z, Block::SAND); }else{ - $chunk .= "\x03"; //dirt + $chunk->setBlockId($x, $y, $z, Block::DIRT); } }else{ - $chunk .= "\x09"; //still_water + $chunk->setBlockId($x, $y, $z, Block::STILL_WATER); } }elseif($diff === 0){ if($patches[$i] > 0.7){ - $chunk .= "\x01"; //stone + $chunk->setBlockId($x, $y, $z, Block::STONE); }elseif($patches[$i] < -0.8){ - $chunk .= "\x0d"; //gravel + $chunk->setBlockId($x, $y, $z, Block::GRAVEL); }else{ - $chunk .= "\x02"; //grass + $chunk->setBlockId($x, $y, $z, Block::GRASS); } - }else{ - $chunk .= "\x00"; } } - $chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + } } - $this->level->setMiniChunk($chunkX, $chunkZ, $chunkY, $chunk); } } diff --git a/src/pocketmine/level/generator/object/Ore.php b/src/pocketmine/level/generator/object/Ore.php index 6f1c81f29..5fd611b9c 100644 --- a/src/pocketmine/level/generator/object/Ore.php +++ b/src/pocketmine/level/generator/object/Ore.php @@ -80,7 +80,8 @@ class Ore{ $sizeZ *= $sizeZ; if(($sizeX + $sizeY + $sizeZ) < 1 and $level->getBlockIdAt($x, $y, $z) === 1){ - $level->setBlockIdAt($x, $y, $z, $this->type->material); + $level->setBlockIdAt($x, $y, $z, $this->type->material->getID()); + $level->setBlockDataAt($x, $y, $z, $this->type->material->getDamage()); } } }