mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Apply more typehints to generator namespace
This commit is contained in:
parent
edb03e8a9b
commit
eb738d1d72
@ -46,7 +46,7 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
$this->worldHeight = $level->getWorldHeight();
|
||||
}
|
||||
|
||||
public function onRun(){
|
||||
public function onRun() : void{
|
||||
BlockFactory::init();
|
||||
Biome::init();
|
||||
$manager = new SimpleChunkManager($this->seed, $this->worldHeight);
|
||||
|
@ -34,7 +34,7 @@ class GeneratorUnregisterTask extends AsyncTask{
|
||||
$this->levelId = $level->getId();
|
||||
}
|
||||
|
||||
public function onRun(){
|
||||
public function onRun() : void{
|
||||
$this->removeFromThreadStore("generation.level{$this->levelId}.manager");
|
||||
$this->removeFromThreadStore("generation.level{$this->levelId}.generator");
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class PopulationTask extends AsyncTask{
|
||||
}
|
||||
}
|
||||
|
||||
public function onRun(){
|
||||
public function onRun() : void{
|
||||
/** @var SimpleChunkManager $manager */
|
||||
$manager = $this->getFromThreadStore("generation.level{$this->levelId}.manager");
|
||||
/** @var Generator $generator */
|
||||
@ -135,7 +135,7 @@ class PopulationTask extends AsyncTask{
|
||||
}
|
||||
}
|
||||
|
||||
public function onCompletion(Server $server){
|
||||
public function onCompletion(Server $server) : void{
|
||||
$level = $server->getLevel($this->levelId);
|
||||
if($level !== null){
|
||||
if(!$this->state){
|
||||
|
@ -52,7 +52,7 @@ abstract class BiomeSelector{
|
||||
*/
|
||||
abstract protected function lookup(float $temperature, float $rainfall) : int;
|
||||
|
||||
public function recalculate(){
|
||||
public function recalculate() : void{
|
||||
$this->map = new \SplFixedArray(64 * 64);
|
||||
|
||||
for($i = 0; $i < 64; ++$i){
|
||||
|
@ -39,7 +39,7 @@ class BirchTree extends Tree{
|
||||
$this->superBirch = $superBirch;
|
||||
}
|
||||
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random){
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random) : void{
|
||||
$this->treeHeight = $random->nextBoundedInt(3) + 5;
|
||||
if($this->superBirch){
|
||||
$this->treeHeight += 5;
|
||||
|
@ -36,7 +36,7 @@ class OakTree extends Tree{
|
||||
$this->type = Wood::OAK;
|
||||
}
|
||||
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random){
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random) : void{
|
||||
$this->treeHeight = $random->nextBoundedInt(3) + 4;
|
||||
parent::placeObject($level, $x, $y, $z, $random);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class Ore{
|
||||
return $level->getBlockIdAt($x, $y, $z) === Block::STONE;
|
||||
}
|
||||
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z){
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z) : void{
|
||||
$clusterSize = $this->type->clusterSize;
|
||||
$angle = $this->random->nextFloat() * M_PI;
|
||||
$offset = VectorMath::getDirection2D($angle)->multiply($clusterSize / 8);
|
||||
|
@ -38,7 +38,7 @@ class SpruceTree extends Tree{
|
||||
$this->treeHeight = 10;
|
||||
}
|
||||
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random){
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random) : void{
|
||||
$this->treeHeight = $random->nextBoundedInt(4) + 6;
|
||||
|
||||
$topSize = $this->treeHeight - (1 + $random->nextBoundedInt(2));
|
||||
|
@ -30,7 +30,7 @@ use pocketmine\utils\Random;
|
||||
|
||||
class TallGrass{
|
||||
|
||||
public static function growGrass(ChunkManager $level, Vector3 $pos, Random $random, int $count = 15, int $radius = 10){
|
||||
public static function growGrass(ChunkManager $level, Vector3 $pos, Random $random, int $count = 15, int $radius = 10) : void{
|
||||
$arr = [
|
||||
[Block::DANDELION, 0],
|
||||
[Block::POPPY, 0],
|
||||
|
@ -45,7 +45,7 @@ abstract class Tree{
|
||||
public $leafBlock = Block::LEAVES;
|
||||
public $treeHeight = 7;
|
||||
|
||||
public static function growTree(ChunkManager $level, int $x, int $y, int $z, Random $random, int $type = 0){
|
||||
public static function growTree(ChunkManager $level, int $x, int $y, int $z, Random $random, int $type = Sapling::OAK) : void{
|
||||
switch($type){
|
||||
case Sapling::SPRUCE:
|
||||
$tree = new SpruceTree();
|
||||
@ -96,8 +96,7 @@ abstract class Tree{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random){
|
||||
|
||||
public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random) : void{
|
||||
$this->placeTrunk($level, $x, $y, $z, $random, $this->treeHeight - 1);
|
||||
|
||||
for($yy = $y - 3 + $this->treeHeight; $yy <= $y + $this->treeHeight; ++$yy){
|
||||
@ -119,7 +118,7 @@ abstract class Tree{
|
||||
}
|
||||
}
|
||||
|
||||
protected function placeTrunk(ChunkManager $level, int $x, int $y, int $z, Random $random, int $trunkHeight){
|
||||
protected function placeTrunk(ChunkManager $level, int $x, int $y, int $z, Random $random, int $trunkHeight) : void{
|
||||
// The base dirt block
|
||||
$level->setBlockIdAt($x, $y - 1, $z, Block::DIRT);
|
||||
|
||||
|
@ -31,7 +31,7 @@ use pocketmine\utils\Random;
|
||||
|
||||
class GroundCover extends Populator{
|
||||
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random) : void{
|
||||
$chunk = $level->getChunk($chunkX, $chunkZ);
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
|
@ -32,7 +32,7 @@ class Ore extends Populator{
|
||||
/** @var OreType[] */
|
||||
private $oreTypes = [];
|
||||
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random) : void{
|
||||
foreach($this->oreTypes as $type){
|
||||
$ore = new ObjectOre($random, $type);
|
||||
for($i = 0; $i < $ore->type->clusterCount; ++$i){
|
||||
@ -49,7 +49,7 @@ class Ore extends Populator{
|
||||
/**
|
||||
* @param OreType[] $types
|
||||
*/
|
||||
public function setOreTypes(array $types){
|
||||
public function setOreTypes(array $types) : void{
|
||||
$this->oreTypes = $types;
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +33,9 @@ abstract class Populator{
|
||||
|
||||
/**
|
||||
* @param ChunkManager $level
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Random $random
|
||||
*
|
||||
* @return mixed
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Random $random
|
||||
*/
|
||||
abstract public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random);
|
||||
abstract public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random) : void;
|
||||
}
|
||||
|
@ -33,15 +33,15 @@ class TallGrass extends Populator{
|
||||
private $randomAmount;
|
||||
private $baseAmount;
|
||||
|
||||
public function setRandomAmount($amount){
|
||||
public function setRandomAmount(int $amount) : void{
|
||||
$this->randomAmount = $amount;
|
||||
}
|
||||
|
||||
public function setBaseAmount($amount){
|
||||
public function setBaseAmount(int $amount) : void{
|
||||
$this->baseAmount = $amount;
|
||||
}
|
||||
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random) : void{
|
||||
$this->level = $level;
|
||||
$amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
|
||||
for($i = 0; $i < $amount; ++$i){
|
||||
|
@ -37,19 +37,19 @@ class Tree extends Populator{
|
||||
|
||||
private $type;
|
||||
|
||||
public function __construct($type = Sapling::OAK){
|
||||
public function __construct(int $type = Sapling::OAK){
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function setRandomAmount($amount){
|
||||
public function setRandomAmount(int $amount) : void{
|
||||
$this->randomAmount = $amount;
|
||||
}
|
||||
|
||||
public function setBaseAmount($amount){
|
||||
public function setBaseAmount(int $amount) : void{
|
||||
$this->baseAmount = $amount;
|
||||
}
|
||||
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random) : void{
|
||||
$this->level = $level;
|
||||
$amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
|
||||
for($i = 0; $i < $amount; ++$i){
|
||||
|
Loading…
x
Reference in New Issue
Block a user