Updated Normal generator

This commit is contained in:
Shoghi Cervantes 2014-06-11 00:29:01 +02:00
parent 109b6dbf44
commit b6ef52e89c
5 changed files with 28 additions and 27 deletions

View File

@ -1361,9 +1361,9 @@ class Server{
LevelProviderManager::addProvider($this, "pocketmine\\level\\format\\anvil\\Anvil"); LevelProviderManager::addProvider($this, "pocketmine\\level\\format\\anvil\\Anvil");
//Generator::addGenerator("pocketmine\\level\\generator\\Flat", "flat"); Generator::addGenerator("pocketmine\\level\\generator\\Flat", "flat");
//Generator::addGenerator("pocketmine\\level\\generator\\Normal", "normal"); Generator::addGenerator("pocketmine\\level\\generator\\Normal", "normal");
//Generator::addGenerator("pocketmine\\level\\generator\\Normal", "default"); Generator::addGenerator("pocketmine\\level\\generator\\Normal", "default");
if($this->getDefaultLevel() === null){ if($this->getDefaultLevel() === null){
$default = $this->getConfigString("level-name", "world"); $default = $this->getConfigString("level-name", "world");

View File

@ -122,9 +122,11 @@ class GenerationChunkManager implements ChunkManager{
protected function requestChunk($chunkX, $chunkZ){ protected function requestChunk($chunkX, $chunkZ){
$chunk = $this->manager->requestChunk($this->levelID, $chunkX, $chunkZ); $chunk = $this->manager->requestChunk($this->levelID, $chunkX, $chunkZ);
$this->chunks[Level::chunkHash($chunkX, $chunkZ)] = $chunk; $this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)] = $chunk;
if(!$chunk->isGenerated()){
return $chunk; $this->generateChunk($chunkX, $chunkZ);
}
return $this->chunks[$index];
} }
/** /**

View File

@ -44,8 +44,7 @@ abstract class Generator{
return Generator::$list[$name]; return Generator::$list[$name];
} }
//return "pocketmine\\level\\generator\\Normal"; return "pocketmine\\level\\generator\\Normal";
return "pocketmine\\level\\generator\\Flat";
} }
public static function getGeneratorName($class){ public static function getGeneratorName($class){

View File

@ -29,6 +29,7 @@ use pocketmine\block\Gravel;
use pocketmine\block\IronOre; use pocketmine\block\IronOre;
use pocketmine\block\LapisOre; use pocketmine\block\LapisOre;
use pocketmine\block\RedstoneOre; use pocketmine\block\RedstoneOre;
use pocketmine\item\Block;
use pocketmine\level\generator\noise\Simplex; use pocketmine\level\generator\noise\Simplex;
use pocketmine\level\generator\object\OreType; use pocketmine\level\generator\object\OreType;
use pocketmine\level\generator\populator\Ore; 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){ for($chunkY = 0; $chunkY < 8; ++$chunkY){
$chunk = "";
$startY = $chunkY << 4; $startY = $chunkY << 4;
$endY = $startY + 16; $endY = $startY + 16;
for($z = 0; $z < 16; ++$z){ for($z = 0; $z < 16; ++$z){
@ -132,47 +134,44 @@ class Normal extends Generator{
for($y = $startY; $y < $endY; ++$y){ for($y = $startY; $y < $endY; ++$y){
$diff = $height - $y; $diff = $height - $y;
if($y <= 4 and ($y === 0 or $this->random->nextFloat() < 0.75)){ 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){ }elseif($diff > 2){
$chunk .= "\x01"; //stone $chunk->setBlockId($x, $y, $z, Block::STONE);
}elseif($diff > 0){ }elseif($diff > 0){
if($patches[$i] > 0.7){ if($patches[$i] > 0.7){
$chunk .= "\x01"; //stone $chunk->setBlockId($x, $y, $z, Block::STONE);
}elseif($patches[$i] < -0.8){ }elseif($patches[$i] < -0.8){
$chunk .= "\x0d"; //gravel $chunk->setBlockId($x, $y, $z, Block::GRAVEL);
}else{ }else{
$chunk .= "\x03"; //dirt $chunk->setBlockId($x, $y, $z, Block::DIRT);
} }
}elseif($y <= $this->waterHeight){ }elseif($y <= $this->waterHeight){
if(($this->waterHeight - $y) <= 1 and $diff === 0){ if(($this->waterHeight - $y) <= 1 and $diff === 0){
$chunk .= "\x0c"; //sand $chunk->setBlockId($x, $y, $z, Block::SAND);
}elseif($diff === 0){ }elseif($diff === 0){
if($patchesSmall[$i] > 0.3){ if($patchesSmall[$i] > 0.3){
$chunk .= "\x0d"; //gravel $chunk->setBlockId($x, $y, $z, Block::GRAVEL);
}elseif($patchesSmall[$i] < -0.45){ }elseif($patchesSmall[$i] < -0.45){
$chunk .= "\x0c"; //sand $chunk->setBlockId($x, $y, $z, Block::SAND);
}else{ }else{
$chunk .= "\x03"; //dirt $chunk->setBlockId($x, $y, $z, Block::DIRT);
} }
}else{ }else{
$chunk .= "\x09"; //still_water $chunk->setBlockId($x, $y, $z, Block::STILL_WATER);
} }
}elseif($diff === 0){ }elseif($diff === 0){
if($patches[$i] > 0.7){ if($patches[$i] > 0.7){
$chunk .= "\x01"; //stone $chunk->setBlockId($x, $y, $z, Block::STONE);
}elseif($patches[$i] < -0.8){ }elseif($patches[$i] < -0.8){
$chunk .= "\x0d"; //gravel $chunk->setBlockId($x, $y, $z, Block::GRAVEL);
}else{ }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);
} }
} }

View File

@ -80,7 +80,8 @@ class Ore{
$sizeZ *= $sizeZ; $sizeZ *= $sizeZ;
if(($sizeX + $sizeY + $sizeZ) < 1 and $level->getBlockIdAt($x, $y, $z) === 1){ 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());
} }
} }
} }