mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Merge branch 'stable'
This commit is contained in:
@ -121,9 +121,9 @@ class Flat extends Generator{
|
||||
|
||||
protected function parsePreset() : void{
|
||||
$preset = explode(";", $this->preset);
|
||||
$blocks = (string) ($preset[1] ?? "");
|
||||
$blocks = $preset[1] ?? "";
|
||||
$this->biome = (int) ($preset[2] ?? 1);
|
||||
$options = (string) ($preset[3] ?? "");
|
||||
$options = $preset[3] ?? "";
|
||||
$this->structure = self::parseLayers($blocks);
|
||||
|
||||
$this->floorLevel = count($this->structure);
|
||||
|
@ -105,48 +105,26 @@ class PopulationTask extends AsyncTask{
|
||||
}
|
||||
|
||||
foreach($chunks as $c){
|
||||
if($c !== null){
|
||||
$manager->setChunk($c->getX(), $c->getZ(), $c);
|
||||
if(!$c->isGenerated()){
|
||||
$generator->generateChunk($c->getX(), $c->getZ());
|
||||
$c = $manager->getChunk($c->getX(), $c->getZ());
|
||||
$c->setGenerated();
|
||||
}
|
||||
$manager->setChunk($c->getX(), $c->getZ(), $c);
|
||||
if(!$c->isGenerated()){
|
||||
$generator->generateChunk($c->getX(), $c->getZ());
|
||||
$c->setGenerated();
|
||||
}
|
||||
}
|
||||
|
||||
$generator->populateChunk($chunk->getX(), $chunk->getZ());
|
||||
|
||||
$chunk = $manager->getChunk($chunk->getX(), $chunk->getZ());
|
||||
$chunk->recalculateHeightMap();
|
||||
$chunk->populateSkyLight();
|
||||
$chunk->setLightPopulated();
|
||||
$chunk->setPopulated();
|
||||
$this->chunk = FastChunkSerializer::serialize($chunk);
|
||||
|
||||
$manager->setChunk($chunk->getX(), $chunk->getZ(), null);
|
||||
|
||||
foreach($chunks as $i => $c){
|
||||
if($c !== null){
|
||||
$c = $chunks[$i] = $manager->getChunk($c->getX(), $c->getZ());
|
||||
if(!$c->isDirty()){
|
||||
$chunks[$i] = null;
|
||||
}
|
||||
}else{
|
||||
//This way non-changed chunks are not set
|
||||
$chunks[$i] = null;
|
||||
}
|
||||
$this->{"chunk$i"} = $c->isDirty() ? FastChunkSerializer::serialize($c) : null;
|
||||
}
|
||||
|
||||
$manager->cleanChunks();
|
||||
|
||||
for($i = 0; $i < 9; ++$i){
|
||||
if($i === 4){
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->{"chunk$i"} = $chunks[$i] !== null ? FastChunkSerializer::serialize($chunks[$i]) : null;
|
||||
}
|
||||
}
|
||||
|
||||
public function onCompletion() : void{
|
||||
|
@ -34,7 +34,10 @@ abstract class BiomeSelector{
|
||||
/** @var Simplex */
|
||||
private $rainfall;
|
||||
|
||||
/** @var Biome[]|\SplFixedArray */
|
||||
/**
|
||||
* @var Biome[]|\SplFixedArray
|
||||
* @phpstan-var \SplFixedArray<Biome>
|
||||
*/
|
||||
private $map = null;
|
||||
|
||||
public function __construct(Random $random){
|
||||
|
@ -203,6 +203,10 @@ abstract class Noise{
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \SplFixedArray|float[]
|
||||
* @phpstan-return \SplFixedArray<float>
|
||||
*/
|
||||
public function getFastNoise1D(int $xSize, int $samplingRate, int $x, int $y, int $z) : \SplFixedArray{
|
||||
if($samplingRate === 0){
|
||||
throw new \InvalidArgumentException("samplingRate cannot be 0");
|
||||
@ -227,6 +231,10 @@ abstract class Noise{
|
||||
return $noiseArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \SplFixedArray|float[][]
|
||||
* @phpstan-return \SplFixedArray<\SplFixedArray<float>>
|
||||
*/
|
||||
public function getFastNoise2D(int $xSize, int $zSize, int $samplingRate, int $x, int $y, int $z) : \SplFixedArray{
|
||||
assert($samplingRate !== 0, new \InvalidArgumentException("samplingRate cannot be 0"));
|
||||
|
||||
|
@ -72,22 +72,22 @@ class Ore{
|
||||
$endY = (int) ($seedY + $size);
|
||||
$endZ = (int) ($seedZ + $size);
|
||||
|
||||
for($x = $startX; $x <= $endX; ++$x){
|
||||
$sizeX = ($x + 0.5 - $seedX) / $size;
|
||||
for($xx = $startX; $xx <= $endX; ++$xx){
|
||||
$sizeX = ($xx + 0.5 - $seedX) / $size;
|
||||
$sizeX *= $sizeX;
|
||||
|
||||
if($sizeX < 1){
|
||||
for($y = $startY; $y <= $endY; ++$y){
|
||||
$sizeY = ($y + 0.5 - $seedY) / $size;
|
||||
for($yy = $startY; $yy <= $endY; ++$yy){
|
||||
$sizeY = ($yy + 0.5 - $seedY) / $size;
|
||||
$sizeY *= $sizeY;
|
||||
|
||||
if($y > 0 and ($sizeX + $sizeY) < 1){
|
||||
for($z = $startZ; $z <= $endZ; ++$z){
|
||||
$sizeZ = ($z + 0.5 - $seedZ) / $size;
|
||||
if($yy > 0 and ($sizeX + $sizeY) < 1){
|
||||
for($zz = $startZ; $zz <= $endZ; ++$zz){
|
||||
$sizeZ = ($zz + 0.5 - $seedZ) / $size;
|
||||
$sizeZ *= $sizeZ;
|
||||
|
||||
if(($sizeX + $sizeY + $sizeZ) < 1 and $world->getBlockAt($x, $y, $z)->getId() === BlockLegacyIds::STONE){
|
||||
$world->setBlockAt($x, $y, $z, $this->type->material);
|
||||
if(($sizeX + $sizeY + $sizeZ) < 1 and $world->getBlockAt($xx, $yy, $zz)->getId() === BlockLegacyIds::STONE){
|
||||
$world->setBlockAt($xx, $yy, $zz, $this->type->material);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,12 +46,13 @@ class GroundCover extends Populator{
|
||||
$diffY = 1;
|
||||
}
|
||||
|
||||
for($y = 127; $y > 0; --$y){
|
||||
if(!BlockFactory::fromFullBlock($chunk->getFullBlock($x, $y, $z))->isTransparent()){
|
||||
$startY = 127;
|
||||
for(; $startY > 0; --$startY){
|
||||
if(!BlockFactory::fromFullBlock($chunk->getFullBlock($x, $startY, $z))->isTransparent()){
|
||||
break;
|
||||
}
|
||||
}
|
||||
$startY = min(127, $y + $diffY);
|
||||
$startY = min(127, $startY + $diffY);
|
||||
$endY = $startY - count($cover);
|
||||
for($y = $startY; $y > $endY and $y >= 0; --$y){
|
||||
$b = $cover[$startY - $y];
|
||||
|
@ -69,10 +69,10 @@ class TallGrass extends Populator{
|
||||
for($y = 127; $y >= 0; --$y){
|
||||
$b = $this->world->getBlockAt($x, $y, $z)->getId();
|
||||
if($b !== BlockLegacyIds::AIR and $b !== BlockLegacyIds::LEAVES and $b !== BlockLegacyIds::LEAVES2 and $b !== BlockLegacyIds::SNOW_LAYER){
|
||||
break;
|
||||
return $y + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $y === 0 ? -1 : ++$y;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -70,15 +70,15 @@ class Tree extends Populator{
|
||||
}
|
||||
|
||||
private function getHighestWorkableBlock(int $x, int $z) : int{
|
||||
for($y = 127; $y > 0; --$y){
|
||||
for($y = 127; $y >= 0; --$y){
|
||||
$b = $this->world->getBlockAt($x, $y, $z)->getId();
|
||||
if($b === BlockLegacyIds::DIRT or $b === BlockLegacyIds::GRASS){
|
||||
break;
|
||||
return $y + 1;
|
||||
}elseif($b !== BlockLegacyIds::AIR and $b !== BlockLegacyIds::SNOW_LAYER){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return ++$y;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user