mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
and more typehints
This commit is contained in:
@ -70,7 +70,9 @@ abstract class Biome{
|
||||
/** @var Populator[] */
|
||||
private $populators = [];
|
||||
|
||||
/** @var int */
|
||||
private $minElevation;
|
||||
/** @var int */
|
||||
private $maxElevation;
|
||||
|
||||
private $groundCover = [];
|
||||
@ -78,9 +80,9 @@ abstract class Biome{
|
||||
protected $rainfall = 0.5;
|
||||
protected $temperature = 0.5;
|
||||
|
||||
protected static function register($id, Biome $biome){
|
||||
self::$biomes[(int) $id] = $biome;
|
||||
$biome->setId((int) $id);
|
||||
protected static function register(int $id, Biome $biome){
|
||||
self::$biomes[$id] = $biome;
|
||||
$biome->setId($id);
|
||||
}
|
||||
|
||||
public static function init(){
|
||||
@ -102,11 +104,11 @@ abstract class Biome{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param int $id
|
||||
*
|
||||
* @return Biome
|
||||
*/
|
||||
public static function getBiome($id){
|
||||
public static function getBiome(int $id) : Biome{
|
||||
return self::$biomes[$id] ?? self::$biomes[self::OCEAN];
|
||||
}
|
||||
|
||||
@ -118,38 +120,47 @@ abstract class Biome{
|
||||
$this->populators[] = $populator;
|
||||
}
|
||||
|
||||
public function populateChunk(ChunkManager $level, $chunkX, $chunkZ, Random $random){
|
||||
/**
|
||||
* @param ChunkManager $level
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Random $random
|
||||
*/
|
||||
public function populateChunk(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){
|
||||
foreach($this->populators as $populator){
|
||||
$populator->populate($level, $chunkX, $chunkZ, $random);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPopulators(){
|
||||
/**
|
||||
* @return Populator[]
|
||||
*/
|
||||
public function getPopulators() : array{
|
||||
return $this->populators;
|
||||
}
|
||||
|
||||
public function setId($id){
|
||||
public function setId(int $id){
|
||||
if(!$this->registered){
|
||||
$this->registered = true;
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
public function getId(){
|
||||
public function getId() : int{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
abstract public function getName();
|
||||
abstract public function getName() : string;
|
||||
|
||||
public function getMinElevation(){
|
||||
public function getMinElevation() : int{
|
||||
return $this->minElevation;
|
||||
}
|
||||
|
||||
public function getMaxElevation(){
|
||||
public function getMaxElevation() : int{
|
||||
return $this->maxElevation;
|
||||
}
|
||||
|
||||
public function setElevation($min, $max){
|
||||
public function setElevation(int $min, int $max){
|
||||
$this->minElevation = $min;
|
||||
$this->maxElevation = $max;
|
||||
}
|
||||
@ -157,7 +168,7 @@ abstract class Biome{
|
||||
/**
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getGroundCover(){
|
||||
public function getGroundCover() : array{
|
||||
return $this->groundCover;
|
||||
}
|
||||
|
||||
@ -168,11 +179,11 @@ abstract class Biome{
|
||||
$this->groundCover = $covers;
|
||||
}
|
||||
|
||||
public function getTemperature(){
|
||||
public function getTemperature() : float{
|
||||
return $this->temperature;
|
||||
}
|
||||
|
||||
public function getRainfall(){
|
||||
public function getRainfall() : float{
|
||||
return $this->rainfall;
|
||||
}
|
||||
}
|
@ -78,7 +78,7 @@ class BiomeSelector{
|
||||
*
|
||||
* @return Biome
|
||||
*/
|
||||
public function pickBiome($x, $z){
|
||||
public function pickBiome($x, $z) : Biome{
|
||||
$temperature = (int) ($this->getTemperature($x, $z) * 63);
|
||||
$rainfall = (int) ($this->getRainfall($x, $z) * 63);
|
||||
|
||||
|
Reference in New Issue
Block a user