Improved biome generation, get grass color from gradient interpolation, improved performance of generation, try to recreate grass colors from imported chunks, closes #2845, closes #1792

This commit is contained in:
Shoghi Cervantes
2015-06-07 15:17:02 +02:00
parent d881dbf1a2
commit cbb1c55a06
23 changed files with 142 additions and 126 deletions

View File

@ -25,6 +25,7 @@ use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\level\format\FullChunk;
use pocketmine\level\format\LevelProvider;
use pocketmine\level\generator\biome\Biome;
use pocketmine\nbt\tag\Compound;
use pocketmine\Player;
use pocketmine\tile\Tile;
@ -94,7 +95,7 @@ abstract class BaseFullChunk implements FullChunk{
if(count($biomeColors) === 256){
$this->biomeColors = $biomeColors;
}else{
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x01\x85\xb2\x4a"));
$this->biomeColors = array_fill(0, 256, Binary::readInt("\xff\x00\x00\x00\x00"));
}
if(count($heightMap) === 256){
@ -107,6 +108,21 @@ abstract class BaseFullChunk implements FullChunk{
$this->NBTentities = $entities;
}
protected function checkOldBiomes($data){
if(strlen($data) !== 256){
return;
}
for($x = 0; $x < 16; ++$x){
for($z = 0; $z < 16; ++$z){
$biome = Biome::getBiome(ord($data{($z << 4) + $x}));
$this->setBiomeId($x, $z, $biome->getId());
$c = $biome->getColor();
$this->setBiomeColor($x, $z, $c >> 16, ($c >> 8) & 0xff, $c & 0xff);
}
}
}
public function initChunk(){
if($this->getProvider() instanceof LevelProvider and !$this->isInit){
$changed = false;