mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
Normal: make gaussian non-static
this allows each generator to (potentially) have a different gaussian curve for biome blending, as well as fixing a few phpstan level 7 errors.
This commit is contained in:
parent
db8e094d11
commit
5a56f68991
@ -52,8 +52,8 @@ class Normal extends Generator{
|
|||||||
/** @var BiomeSelector */
|
/** @var BiomeSelector */
|
||||||
private $selector;
|
private $selector;
|
||||||
|
|
||||||
/** @var Gaussian|null */
|
/** @var Gaussian */
|
||||||
private static $GAUSSIAN_KERNEL = null;
|
private $gaussian;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed[] $options
|
* @param mixed[] $options
|
||||||
@ -63,9 +63,8 @@ class Normal extends Generator{
|
|||||||
*/
|
*/
|
||||||
public function __construct(ChunkManager $world, int $seed, array $options = []){
|
public function __construct(ChunkManager $world, int $seed, array $options = []){
|
||||||
parent::__construct($world, $seed, $options);
|
parent::__construct($world, $seed, $options);
|
||||||
if(self::$GAUSSIAN_KERNEL === null){
|
|
||||||
self::$GAUSSIAN_KERNEL = new Gaussian(2);
|
$this->gaussian = new Gaussian(2);
|
||||||
}
|
|
||||||
|
|
||||||
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
|
$this->noiseBase = new Simplex($this->random, 4, 1 / 4, 1 / 32);
|
||||||
$this->random->setSeed($this->seed);
|
$this->random->setSeed($this->seed);
|
||||||
@ -167,10 +166,10 @@ class Normal extends Generator{
|
|||||||
$biome = $this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z);
|
$biome = $this->pickBiome($chunkX * 16 + $x, $chunkZ * 16 + $z);
|
||||||
$chunk->setBiomeId($x, $z, $biome->getId());
|
$chunk->setBiomeId($x, $z, $biome->getId());
|
||||||
|
|
||||||
for($sx = -self::$GAUSSIAN_KERNEL->smoothSize; $sx <= self::$GAUSSIAN_KERNEL->smoothSize; ++$sx){
|
for($sx = -$this->gaussian->smoothSize; $sx <= $this->gaussian->smoothSize; ++$sx){
|
||||||
for($sz = -self::$GAUSSIAN_KERNEL->smoothSize; $sz <= self::$GAUSSIAN_KERNEL->smoothSize; ++$sz){
|
for($sz = -$this->gaussian->smoothSize; $sz <= $this->gaussian->smoothSize; ++$sz){
|
||||||
|
|
||||||
$weight = self::$GAUSSIAN_KERNEL->kernel[$sx + self::$GAUSSIAN_KERNEL->smoothSize][$sz + self::$GAUSSIAN_KERNEL->smoothSize];
|
$weight = $this->gaussian->kernel[$sx + $this->gaussian->smoothSize][$sz + $this->gaussian->smoothSize];
|
||||||
|
|
||||||
if($sx === 0 and $sz === 0){
|
if($sx === 0 and $sz === 0){
|
||||||
$adjacent = $biome;
|
$adjacent = $biome;
|
||||||
|
@ -1040,16 +1040,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/world/generator/normal/Normal.php
|
path: ../../../src/world/generator/normal/Normal.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot access property \\$smoothSize on pocketmine\\\\world\\\\generator\\\\Gaussian\\|null\\.$#"
|
|
||||||
count: 6
|
|
||||||
path: ../../../src/world/generator/normal/Normal.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot access property \\$kernel on pocketmine\\\\world\\\\generator\\\\Gaussian\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/generator/normal/Normal.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot call method setFullBlock\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#"
|
message: "#^Cannot call method setFullBlock\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#"
|
||||||
count: 3
|
count: 3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user