diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index cb53dedd6..69d11fe7b 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1237,8 +1237,8 @@ class Server{ $order = []; - for($X = -4; $X <= 4; ++$X){ - for($Z = -4; $Z <= 4; ++$Z){ + for($X = -3; $X <= 3; ++$X){ + for($Z = -3; $Z <= 3; ++$Z){ $distance = $X ** 2 + $Z ** 2; $chunkX = $X + $centerX; $chunkZ = $Z + $centerZ; @@ -1251,7 +1251,7 @@ class Server{ foreach($order as $index => $distance){ Level::getXZ($index, $chunkX, $chunkZ); - $level->generateChunk($chunkX, $chunkZ, true); + $level->populateChunk($chunkX, $chunkZ, true); } return true; diff --git a/src/pocketmine/level/format/anvil/Chunk.php b/src/pocketmine/level/format/anvil/Chunk.php index f6e64e57d..5458e03b8 100644 --- a/src/pocketmine/level/format/anvil/Chunk.php +++ b/src/pocketmine/level/format/anvil/Chunk.php @@ -94,6 +94,11 @@ class Chunk extends BaseChunk{ parent::__construct($level, (int) $this->nbt["xPos"], (int) $this->nbt["zPos"], $sections, $this->nbt->BiomeColors->getValue(), $this->nbt->HeightMap->getValue(), $this->nbt->Entities->getValue(), $this->nbt->TileEntities->getValue()); + if(isset($this->nbt->Biomes)){ + $this->checkOldBiomes($this->nbt->Biomes->getValue()); + unset($this->nbt->Biomes); + } + unset($this->nbt->Sections); } diff --git a/src/pocketmine/level/format/generic/BaseChunk.php b/src/pocketmine/level/format/generic/BaseChunk.php index c2f71de18..1b54b1603 100644 --- a/src/pocketmine/level/format/generic/BaseChunk.php +++ b/src/pocketmine/level/format/generic/BaseChunk.php @@ -64,7 +64,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ 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")); } if(count($heightMap) === 256){ diff --git a/src/pocketmine/level/format/generic/BaseFullChunk.php b/src/pocketmine/level/format/generic/BaseFullChunk.php index 1854b6f34..eca67d6f1 100644 --- a/src/pocketmine/level/format/generic/BaseFullChunk.php +++ b/src/pocketmine/level/format/generic/BaseFullChunk.php @@ -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; diff --git a/src/pocketmine/level/format/mcregion/Chunk.php b/src/pocketmine/level/format/mcregion/Chunk.php index 6236c2af9..9eed48087 100644 --- a/src/pocketmine/level/format/mcregion/Chunk.php +++ b/src/pocketmine/level/format/mcregion/Chunk.php @@ -88,6 +88,12 @@ class Chunk extends BaseFullChunk{ } parent::__construct($level, $this->nbt["xPos"], $this->nbt["zPos"], $this->nbt->Blocks->getValue(), $this->nbt->Data->getValue(), $this->nbt->SkyLight->getValue(), $this->nbt->BlockLight->getValue(), $this->nbt->BiomeColors->getValue(), $this->nbt->HeightMap->getValue(), $this->nbt->Entities->getValue(), $this->nbt->TileEntities->getValue()); + + if(isset($this->nbt->Biomes)){ + $this->checkOldBiomes($this->nbt->Biomes->getValue()); + unset($this->nbt->Biomes); + } + unset($this->nbt->Blocks); unset($this->nbt->Data); unset($this->nbt->SkyLight); diff --git a/src/pocketmine/level/generator/Generator.php b/src/pocketmine/level/generator/Generator.php index b0dc9613c..bd7e6c432 100644 --- a/src/pocketmine/level/generator/Generator.php +++ b/src/pocketmine/level/generator/Generator.php @@ -197,7 +197,7 @@ abstract class Generator{ for($xx = 0; $xx <= $xSize; $xx += $xSamplingRate){ for($zz = 0; $zz <= $zSize; $zz += $zSamplingRate){ for($yy = 0; $yy <= $ySize; $yy += $ySamplingRate){ - $noiseArray[$xx][$zz][$yy] = $noise->noise3D($x + $xx, $y + $yy, $z + $zz); + $noiseArray[$xx][$zz][$yy] = $noise->noise3D($x + $xx, $y + $yy, $z + $zz, true); } } } diff --git a/src/pocketmine/level/generator/biome/Biome.php b/src/pocketmine/level/generator/biome/Biome.php index e4a1891f4..a4d5e1caf 100644 --- a/src/pocketmine/level/generator/biome/Biome.php +++ b/src/pocketmine/level/generator/biome/Biome.php @@ -73,10 +73,12 @@ abstract class Biome{ protected $rainfall = 0.5; protected $temperature = 0.5; + protected $grassColor = 0; protected static function register($id, Biome $biome){ self::$biomes[(int) $id] = $biome; $biome->setId((int) $id); + $biome->grassColor = self::generateBiomeColor($biome->getTemperature(), $biome->getRainfall()); } public static function init(){ @@ -173,9 +175,29 @@ abstract class Biome{ return $this->rainfall; } + private static function generateBiomeColor($temperature, $rainfall){ + $x = (1 - $temperature) * 255; + $z = (1 - $rainfall * $temperature) * 255; + $c = self::interpolateColor(256, $x, $z, [0x47, 0xd0, 0x33], [0x6c, 0xb4, 0x93], [0xbf, 0xb6, 0x55], [0x80, 0xb4, 0x97]); + return ((int) ($c[0] << 16)) | (int) (($c[1] << 8)) | (int) ($c[2]); + } + + + private static function interpolateColor($size, $x, $z, $c1, $c2, $c3, $c4){ + $l1 = self::lerpColor($c1, $c2, $x / $size); + $l2 = self::lerpColor($c3, $c4, $x / $size); + + return self::lerpColor($l1, $l2, $z / $size); + } + + private static function lerpColor($a, $b, $s){ + $invs = 1 - $s; + return [$a[0] * $invs + $b[0] * $s, $a[1] * $invs + $b[1] * $s, $a[2] * $invs + $b[2] * $s]; + } + /** - * @return int (randomness|Red|Green|Blue) + * @return int (Red|Green|Blue) */ abstract public function getColor(); } \ No newline at end of file diff --git a/src/pocketmine/level/generator/biome/BiomeSelector.php b/src/pocketmine/level/generator/biome/BiomeSelector.php index a60fdd08d..68da75484 100644 --- a/src/pocketmine/level/generator/biome/BiomeSelector.php +++ b/src/pocketmine/level/generator/biome/BiomeSelector.php @@ -44,8 +44,8 @@ class BiomeSelector{ public function __construct(Random $random, callable $lookup, Biome $fallback){ $this->fallback = $fallback; $this->lookup = $lookup; - $this->temperature = new Simplex($random, 1, 0.001, 1, 1); - $this->rainfall = new Simplex($random, 1, 0.001, 1, 1); + $this->temperature = new Simplex($random, 2, 1 / 16, 1 / 512); + $this->rainfall = new Simplex($random, 2, 1 / 16, 1 / 512); } public function recalculate(){ diff --git a/src/pocketmine/level/generator/noise/Noise.php b/src/pocketmine/level/generator/noise/Noise.php index 2c5a36483..72cd16248 100644 --- a/src/pocketmine/level/generator/noise/Noise.php +++ b/src/pocketmine/level/generator/noise/Noise.php @@ -21,9 +21,6 @@ /** * Different noise generators for level generation - * - * WARNING: This class is available on the PocketMine-MP Zephir project. - * If this class is modified, remember to modify the PHP C extension. */ namespace pocketmine\level\generator\noise; @@ -34,16 +31,15 @@ abstract class Noise{ protected $offsetY = 0; protected $offsetZ = 0; protected $octaves = 8; - protected $frequency; - protected $lacunarity; - protected $amplitude; + protected $persistence; + protected $expansion; public static function floor($x){ return $x >= 0 ? (int) $x : (int) ($x - 1); } public static function fade($x){ - return $x ** 3 * ($x * ($x * 6 - 15) + 10); + return $x * $x * $x * ($x * ($x * 6 - 15) + 10); } public static function lerp($x, $y, $z){ @@ -101,18 +97,19 @@ abstract class Noise{ public function noise2D($x, $z, $normalized = false){ $result = 0; $amp = 1; - $laq = 1; + $freq = 1; $max = 0; - $x *= $this->frequency; - $z *= $this->frequency; + $x *= $this->expansion; + $z *= $this->expansion; for($i = 0; $i < $this->octaves; ++$i){ - $result += $this->getNoise2D($x * $laq, $z * $laq) * $amp; + $result += $this->getNoise2D($x * $freq, $z * $freq) * $amp; $max += $amp; - $laq *= $this->lacunarity; - $amp *= $this->amplitude; + $freq *= 2; + $amp *= $this->persistence; } + if($normalized === true){ $result /= $max; } @@ -123,19 +120,20 @@ abstract class Noise{ public function noise3D($x, $y, $z, $normalized = false){ $result = 0; $amp = 1; - $laq = 1; + $freq = 1; $max = 0; - $x *= $this->frequency; - $y *= $this->frequency; - $z *= $this->frequency; + $x *= $this->expansion; + $y *= $this->expansion; + $z *= $this->expansion; for($i = 0; $i < $this->octaves; ++$i){ - $result += $this->getNoise3D($x * $laq, $y * $laq, $z * $laq) * $amp; + $result += $this->getNoise3D($x * $freq, $y * $freq, $z * $freq) * $amp; $max += $amp; - $laq *= $this->lacunarity; - $amp *= $this->amplitude; + $freq *= 2; + $amp *= $this->persistence; } + if($normalized === true){ $result /= $max; } diff --git a/src/pocketmine/level/generator/noise/Perlin.php b/src/pocketmine/level/generator/noise/Perlin.php index 6b9c76ed9..1b6f5fcf0 100644 --- a/src/pocketmine/level/generator/noise/Perlin.php +++ b/src/pocketmine/level/generator/noise/Perlin.php @@ -31,11 +31,10 @@ class Perlin extends Noise{ ]; - public function __construct(Random $random, $octaves, $frequency, $amplitude, $lacunarity){ + public function __construct(Random $random, $octaves, $persistence, $expansion = 1){ $this->octaves = $octaves; - $this->frequency = $frequency; - $this->lacunarity = $lacunarity; - $this->amplitude = $amplitude; + $this->persistence = $persistence; + $this->expansion = $expansion; $this->offsetX = $random->nextFloat() * 256; $this->offsetY = $random->nextFloat() * 256; $this->offsetZ = $random->nextFloat() * 256; @@ -80,9 +79,9 @@ class Perlin extends Noise{ //$fX = self::fade($x); //$fY = self::fade($y); //$fZ = self::fade($z); - $fX = $x ** 3 * ($x * ($x * 6 - 15) + 10); - $fY = $y ** 3 * ($y * ($y * 6 - 15) + 10); - $fZ = $z ** 3 * ($z * ($z * 6 - 15) + 10); + $fX = $x * $x * $x * ($x * ($x * 6 - 15) + 10); + $fY = $y * $y * $y * ($y * ($y * 6 - 15) + 10); + $fZ = $z * $z * $z * ($z * ($z * 6 - 15) + 10); //Cube corners $A = $this->perm[$X] + $Y; diff --git a/src/pocketmine/level/generator/noise/Simplex.php b/src/pocketmine/level/generator/noise/Simplex.php index 3266d4dd0..936a730f1 100644 --- a/src/pocketmine/level/generator/noise/Simplex.php +++ b/src/pocketmine/level/generator/noise/Simplex.php @@ -63,8 +63,8 @@ class Simplex extends Perlin{ protected $offsetW; - public function __construct(Random $random, $octaves, $frequency, $amplitude, $lacunarity){ - parent::__construct($random, $octaves, $frequency, $amplitude, $lacunarity); + public function __construct(Random $random, $octaves, $persistence, $expansion = 1){ + parent::__construct($random, $octaves, $persistence, $expansion); $this->offsetW = $random->nextFloat() * 256; self::$SQRT_3 = sqrt(3); self::$SQRT_5 = sqrt(5); @@ -187,28 +187,28 @@ class Simplex extends Perlin{ $n = 0; // Calculate the contribution from the four corners - $t0 = 0.6 - $x0 ** 2 - $y0 ** 2 - $z0 ** 2; + $t0 = 0.6 - $x0 * $x0 - $y0 * $y0 - $z0 * $z0; if($t0 > 0){ $gi0 = self::$grad3[$this->perm[$ii + $this->perm[$jj + $this->perm[$kk]]] % 12]; - $n += $t0 ** 4 * ($gi0[0] * $x0 + $gi0[1] * $y0 + $gi0[2] * $z0); + $n += $t0 * $t0 * $t0 * $t0 * ($gi0[0] * $x0 + $gi0[1] * $y0 + $gi0[2] * $z0); } - $t1 = 0.6 - $x1 ** 2 - $y1 ** 2 - $z1 ** 2; + $t1 = 0.6 - $x1 * $x1 - $y1 * $y1 - $z1 * $z1; if($t1 > 0){ $gi1 = self::$grad3[$this->perm[$ii + $i1 + $this->perm[$jj + $j1 + $this->perm[$kk + $k1]]] % 12]; - $n += $t1 ** 4 * ($gi1[0] * $x1 + $gi1[1] * $y1 + $gi1[2] * $z1); + $n += $t1 * $t1 * $t1 * $t1 * ($gi1[0] * $x1 + $gi1[1] * $y1 + $gi1[2] * $z1); } - $t2 = 0.6 - $x2 ** 2 - $y2 ** 2 - $z2 ** 2; + $t2 = 0.6 - $x2 * $x2 - $y2 * $y2 - $z2 * $z2; if($t2 > 0){ $gi2 = self::$grad3[$this->perm[$ii + $i2 + $this->perm[$jj + $j2 + $this->perm[$kk + $k2]]] % 12]; - $n += $t2 ** 4 * ($gi2[0] * $x2 + $gi2[1] * $y2 + $gi2[2] * $z2); + $n += $t2 * $t2 * $t2 * $t2 * ($gi2[0] * $x2 + $gi2[1] * $y2 + $gi2[2] * $z2); } - $t3 = 0.6 - $x3 ** 2 - $y3 ** 2 - $z3 ** 2; + $t3 = 0.6 - $x3 * $x3 - $y3 * $y3 - $z3 * $z3; if($t3 > 0){ $gi3 = self::$grad3[$this->perm[$ii + 1 + $this->perm[$jj + 1 + $this->perm[$kk + 1]]] % 12]; - $n += $t3 ** 4 * ($gi3[0] * $x3 + $gi3[1] * $y3 + $gi3[2] * $z3); + $n += $t3 * $t3 * $t3 * $t3 * ($gi3[0] * $x3 + $gi3[1] * $y3 + $gi3[2] * $z3); } // Add contributions from each corner to get the noise value. @@ -258,22 +258,22 @@ class Simplex extends Perlin{ $n = 0; // Calculate the contribution from the three corners - $t0 = 0.5 - $x0 ** 2 - $y0 ** 2; + $t0 = 0.5 - $x0 * $x0 - $y0 * $y0; if($t0 > 0){ $gi0 = self::$grad3[$this->perm[$ii + $this->perm[$jj]] % 12]; - $n += $t0 ** 4 * ($gi0[0] * $x0 + $gi0[1] * $y0); // (x,y) of grad3 used for 2D gradient + $n += $t0 * $t0 * $t0 * $t0 * ($gi0[0] * $x0 + $gi0[1] * $y0); // (x,y) of grad3 used for 2D gradient } - $t1 = 0.5 - $x1 ** 2 - $y1 ** 2; + $t1 = 0.5 - $x1 * $x1 - $y1 * $y1; if($t1 > 0){ $gi1 = self::$grad3[$this->perm[$ii + $i1 + $this->perm[$jj + $j1]] % 12]; - $n += $t1 ** 4 * ($gi1[0] * $x1 + $gi1[1] * $y1); + $n += $t1 * $t1 * $t1 * $t1 * ($gi1[0] * $x1 + $gi1[1] * $y1); } - $t2 = 0.5 - $x2 ** 2 - $y2 ** 2; + $t2 = 0.5 - $x2 * $x2 - $y2 * $y2; if($t2 > 0){ $gi2 = self::$grad3[$this->perm[$ii + 1 + $this->perm[$jj + 1]] % 12]; - $n += $t2 ** 4 * ($gi2[0] * $x2 + $gi2[1] * $y2); + $n += $t2 * $t2 * $t2 * $t2 * ($gi2[0] * $x2 + $gi2[1] * $y2); } // Add contributions from each corner to get the noise value. diff --git a/src/pocketmine/level/generator/normal/Normal.php b/src/pocketmine/level/generator/normal/Normal.php index 804d1d95d..e7bbcb087 100644 --- a/src/pocketmine/level/generator/normal/Normal.php +++ b/src/pocketmine/level/generator/normal/Normal.php @@ -121,21 +121,10 @@ class Normal extends Generator{ $this->level = $level; $this->random = $random; $this->random->setSeed($this->level->getSeed()); - $this->noiseBase = new Simplex($this->random, 16, 0.01, 0.5, 2); + $this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32); $this->random->setSeed($this->level->getSeed()); $this->selector = new BiomeSelector($this->random, function($temperature, $rainfall){ - $rainfall *= $temperature; - if($temperature < 0.10){ - return Biome::ICE_PLAINS; - }elseif($rainfall < 0.20){ - if($temperature < 0.50){ - return Biome::ICE_PLAINS; - }elseif($temperature < 0.95){ - return Biome::PLAINS; - }else{ - return Biome::DESERT; - } - }elseif($rainfall > 0.5 and $temperature < 0.7){ + if($rainfall < 0.25){ if($rainfall < 0.7){ return Biome::OCEAN; }elseif($rainfall < 0.85){ @@ -143,24 +132,30 @@ class Normal extends Generator{ }else{ return Biome::SWAMP; } - }elseif($temperature < 0.50){ - return Biome::TAIGA; - }elseif($temperature < 0.97){ - if($rainfall < 0.25){ - return Biome::MOUNTAINS; - }elseif($rainfall < 0.35){ - return Biome::SMALL_MOUNTAINS; + }elseif($rainfall < 0.60){ + if($temperature < 0.25){ + return Biome::ICE_PLAINS; + }elseif($temperature < 0.75){ + return Biome::PLAINS; }else{ - return Biome::PLAINS; + return Biome::DESERT; } - }else{ - if($rainfall < 0.45){ - return Biome::PLAINS; - }elseif($rainfall < 0.90){ + }elseif($rainfall < 0.80){ + if($temperature < 0.25){ + return Biome::TAIGA; + }elseif($temperature < 0.75){ return Biome::FOREST; }else{ return Biome::BIRCH_FOREST; } + }else{ + if($rainfall < 0.25){ + return Biome::MOUNTAINS; + }elseif($rainfall < 0.70){ + return Biome::SMALL_MOUNTAINS; + }else{ + return Biome::RIVER; + } } }, Biome::getBiome(Biome::OCEAN)); @@ -212,8 +207,7 @@ class Normal extends Generator{ $biome = $this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z); $chunk->setBiomeId($x, $z, $biome->getId()); - $color = $biome->getColor(); - $chunk->setBiomeColor($x, $z, $color >> 16, ($color >> 8) & 0xff, $color & 0xff); + $color = [0, 0, 0]; for($sx = -self::$SMOOTH_SIZE; $sx <= self::$SMOOTH_SIZE; ++$sx){ for($sz = -self::$SMOOTH_SIZE; $sz <= self::$SMOOTH_SIZE; ++$sz){ @@ -231,8 +225,13 @@ class Normal extends Generator{ } } - $minSum += $adjacent->getMinElevation() * $weight; + $minSum += ($adjacent->getMinElevation() - 1) * $weight; $maxSum += $adjacent->getMaxElevation() * $weight; + $bColor = $adjacent->getColor(); + $color[0] += (($bColor >> 16) ** 2) * $weight; + $color[1] += ((($bColor >> 8) & 0xff) ** 2) * $weight; + $color[2] += (($bColor & 0xff) ** 2) * $weight; + $weightSum += $weight; } } @@ -240,6 +239,8 @@ class Normal extends Generator{ $minSum /= $weightSum; $maxSum /= $weightSum; + $chunk->setBiomeColor($x, $z, sqrt($color[0] / $weightSum), sqrt($color[1] / $weightSum), sqrt($color[2] / $weightSum)); + $smoothHeight = ($maxSum - $minSum) / 2; for($y = 0; $y < 128; ++$y){ @@ -249,19 +250,11 @@ class Normal extends Generator{ } $noiseValue = $noise[$x][$z][$y] - 1 / $smoothHeight * ($y - $smoothHeight - $minSum); - if($noiseValue >= 0){ + if($noiseValue > 0){ $chunk->setBlockId($x, $y, $z, Block::STONE); - }/*else{ - if($y <= $this->waterHeight){ - $chunk->setBlockId($x, $y, $z, Block::STILL_WATER); - $lightValue = 15 - ($this->waterHeight - $y) * 2; - if($lightValue > 0){ - $chunk->setBlockSkyLight($x, $y, $z, $lightValue); - } - }else{ - $chunk->setBlockSkyLight($x, $y, $z, 15); - } - }*/ + }elseif($y <= $this->waterHeight){ + $chunk->setBlockId($x, $y, $z, Block::STILL_WATER); + } } } } diff --git a/src/pocketmine/level/generator/normal/biome/ForestBiome.php b/src/pocketmine/level/generator/normal/biome/ForestBiome.php index 2291297e9..2c0b5a3e4 100644 --- a/src/pocketmine/level/generator/normal/biome/ForestBiome.php +++ b/src/pocketmine/level/generator/normal/biome/ForestBiome.php @@ -60,8 +60,4 @@ class ForestBiome extends GrassyBiome{ public function getName(){ return $this->type === self::TYPE_BIRCH ? "Birch Forest" : "Forest"; } - - public function getColor(){ - return 0x056621; - } } \ No newline at end of file diff --git a/src/pocketmine/level/generator/normal/biome/IcePlainsBiome.php b/src/pocketmine/level/generator/normal/biome/IcePlainsBiome.php index 5bd79fda9..de7fb79a3 100644 --- a/src/pocketmine/level/generator/normal/biome/IcePlainsBiome.php +++ b/src/pocketmine/level/generator/normal/biome/IcePlainsBiome.php @@ -42,8 +42,4 @@ class IcePlainsBiome extends SnowyBiome{ public function getName(){ return "Ice Plains"; } - - public function getColor(){ - return 0x163933; - } } \ No newline at end of file diff --git a/src/pocketmine/level/generator/normal/biome/NormalBiome.php b/src/pocketmine/level/generator/normal/biome/NormalBiome.php index 207f8ae9f..5e023a70a 100644 --- a/src/pocketmine/level/generator/normal/biome/NormalBiome.php +++ b/src/pocketmine/level/generator/normal/biome/NormalBiome.php @@ -24,7 +24,8 @@ namespace pocketmine\level\generator\normal\biome; use pocketmine\level\generator\biome\Biome; abstract class NormalBiome extends Biome{ + public function getColor(){ - return 0xffb360; //Detect wrong biomes + return $this->grassColor; } } diff --git a/src/pocketmine/level/generator/normal/biome/OceanBiome.php b/src/pocketmine/level/generator/normal/biome/OceanBiome.php index 8449386b1..8834f84a0 100644 --- a/src/pocketmine/level/generator/normal/biome/OceanBiome.php +++ b/src/pocketmine/level/generator/normal/biome/OceanBiome.php @@ -42,8 +42,4 @@ class OceanBiome extends GrassyBiome{ public function getName(){ return "Ocean"; } - - public function getColor(){ - return 0x8da360; - } } \ No newline at end of file diff --git a/src/pocketmine/level/generator/normal/biome/PlainBiome.php b/src/pocketmine/level/generator/normal/biome/PlainBiome.php index 625646009..d9ea85ac5 100644 --- a/src/pocketmine/level/generator/normal/biome/PlainBiome.php +++ b/src/pocketmine/level/generator/normal/biome/PlainBiome.php @@ -42,8 +42,4 @@ class PlainBiome extends GrassyBiome{ public function getName(){ return "Plains"; } - - public function getColor(){ - return 0x8db360; - } } \ No newline at end of file diff --git a/src/pocketmine/level/generator/normal/biome/RiverBiome.php b/src/pocketmine/level/generator/normal/biome/RiverBiome.php index 72621b114..a878657c8 100644 --- a/src/pocketmine/level/generator/normal/biome/RiverBiome.php +++ b/src/pocketmine/level/generator/normal/biome/RiverBiome.php @@ -42,8 +42,4 @@ class RiverBiome extends GrassyBiome{ public function getName(){ return "River"; } - - public function getColor(){ - return 0x8dc360; - } } \ No newline at end of file diff --git a/src/pocketmine/level/generator/normal/biome/SwampBiome.php b/src/pocketmine/level/generator/normal/biome/SwampBiome.php index 2613ce3da..990bfd98e 100644 --- a/src/pocketmine/level/generator/normal/biome/SwampBiome.php +++ b/src/pocketmine/level/generator/normal/biome/SwampBiome.php @@ -37,6 +37,6 @@ class SwampBiome extends GrassyBiome{ } public function getColor(){ - return 0x07f9b2; + return 0x6a7039; } } \ No newline at end of file diff --git a/src/pocketmine/level/generator/normal/biome/TaigaBiome.php b/src/pocketmine/level/generator/normal/biome/TaigaBiome.php index 9bbb5307c..1f2bad725 100644 --- a/src/pocketmine/level/generator/normal/biome/TaigaBiome.php +++ b/src/pocketmine/level/generator/normal/biome/TaigaBiome.php @@ -48,8 +48,4 @@ class TaigaBiome extends SnowyBiome{ public function getName(){ return "Taiga"; } - - public function getColor(){ - return 0x0b6659; - } } \ No newline at end of file diff --git a/src/pocketmine/level/generator/object/Ore.php b/src/pocketmine/level/generator/object/Ore.php index 0bb4d5f61..38446e51b 100644 --- a/src/pocketmine/level/generator/object/Ore.php +++ b/src/pocketmine/level/generator/object/Ore.php @@ -67,17 +67,17 @@ class Ore{ for($x = $startX; $x <= $endX; ++$x){ $sizeX = ($x + 0.5 - $seedX) / $size; - $sizeX **= 2; + $sizeX *= $sizeX; if($sizeX < 1){ for($y = $startY; $y <= $endY; ++$y){ $sizeY = ($y + 0.5 - $seedY) / $size; - $sizeY **= 2; + $sizeY *= $sizeY; if($y > 0 and ($sizeX + $sizeY) < 1){ for($z = $startZ; $z <= $endZ; ++$z){ $sizeZ = ($z + 0.5 - $seedZ) / $size; - $sizeZ **= 2; + $sizeZ *= $sizeZ; if(($sizeX + $sizeY + $sizeZ) < 1 and $level->getBlockIdAt($x, $y, $z) === 1){ $level->setBlockIdAt($x, $y, $z, $this->type->material->getId()); diff --git a/src/pocketmine/level/generator/populator/TallGrass.php b/src/pocketmine/level/generator/populator/TallGrass.php index 03438b5c7..96b843806 100644 --- a/src/pocketmine/level/generator/populator/TallGrass.php +++ b/src/pocketmine/level/generator/populator/TallGrass.php @@ -62,7 +62,7 @@ class TallGrass extends Populator{ private function getHighestWorkableBlock($x, $z){ for($y = 127; $y >= 0; --$y){ $b = $this->level->getBlockIdAt($x, $y, $z); - if($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::SNOW_LAYER){ + if($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2 and $b !== Block::SNOW_LAYER){ break; } } diff --git a/src/pocketmine/math/Vector3.php b/src/pocketmine/math/Vector3.php index 46c131bb4..32a92ebda 100644 --- a/src/pocketmine/math/Vector3.php +++ b/src/pocketmine/math/Vector3.php @@ -199,7 +199,7 @@ class Vector3{ } public function lengthSquared(){ - return $this->x ** 2 + $this->y ** 2 + $this->z ** 2; + return $this->x * $this->x + $this->y * $this->y + $this->z * $this->z; } /** @@ -244,7 +244,7 @@ class Vector3{ $yDiff = $v->y - $this->y; $zDiff = $v->z - $this->z; - if(($xDiff ** 2) < 0.0000001){ + if(($xDiff * $xDiff) < 0.0000001){ return null; } @@ -271,7 +271,7 @@ class Vector3{ $yDiff = $v->y - $this->y; $zDiff = $v->z - $this->z; - if(($yDiff ** 2) < 0.0000001){ + if(($yDiff * $yDiff) < 0.0000001){ return null; } @@ -298,7 +298,7 @@ class Vector3{ $yDiff = $v->y - $this->y; $zDiff = $v->z - $this->z; - if(($zDiff ** 2) < 0.0000001){ + if(($zDiff * $zDiff) < 0.0000001){ return null; }