Removed pocketmine subdirectory, map PSR-4 style

This commit is contained in:
Dylan K. Taylor
2019-07-30 19:14:57 +01:00
parent 7a77d3dc30
commit 5499ac620c
1044 changed files with 3 additions and 3 deletions

191
src/world/biome/Biome.php Normal file
View File

@ -0,0 +1,191 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\block\Block;
use pocketmine\block\utils\TreeType;
use pocketmine\utils\Random;
use pocketmine\world\ChunkManager;
use pocketmine\world\generator\populator\Populator;
abstract class Biome{
public const OCEAN = 0;
public const PLAINS = 1;
public const DESERT = 2;
public const MOUNTAINS = 3;
public const FOREST = 4;
public const TAIGA = 5;
public const SWAMP = 6;
public const RIVER = 7;
public const HELL = 8;
public const ICE_PLAINS = 12;
public const SMALL_MOUNTAINS = 20;
public const BIRCH_FOREST = 27;
public const MAX_BIOMES = 256;
/** @var Biome[]|\SplFixedArray */
private static $biomes;
/** @var int */
private $id;
/** @var bool */
private $registered = false;
/** @var Populator[] */
private $populators = [];
/** @var int */
private $minElevation;
/** @var int */
private $maxElevation;
/** @var Block[] */
private $groundCover = [];
/** @var float */
protected $rainfall = 0.5;
/** @var float */
protected $temperature = 0.5;
protected static function register(int $id, Biome $biome) : void{
self::$biomes[$id] = $biome;
$biome->setId($id);
}
public static function init() : void{
self::$biomes = new \SplFixedArray(self::MAX_BIOMES);
self::register(self::OCEAN, new OceanBiome());
self::register(self::PLAINS, new PlainBiome());
self::register(self::DESERT, new DesertBiome());
self::register(self::MOUNTAINS, new MountainsBiome());
self::register(self::FOREST, new ForestBiome());
self::register(self::TAIGA, new TaigaBiome());
self::register(self::SWAMP, new SwampBiome());
self::register(self::RIVER, new RiverBiome());
self::register(self::ICE_PLAINS, new IcePlainsBiome());
self::register(self::SMALL_MOUNTAINS, new SmallMountainsBiome());
self::register(self::BIRCH_FOREST, new ForestBiome(TreeType::BIRCH()));
}
/**
* @param int $id
*
* @return Biome
*/
public static function getBiome(int $id) : Biome{
if(self::$biomes[$id] === null){
self::register($id, new UnknownBiome());
}
return self::$biomes[$id];
}
public function clearPopulators() : void{
$this->populators = [];
}
public function addPopulator(Populator $populator) : void{
$this->populators[] = $populator;
}
/**
* @param ChunkManager $world
* @param int $chunkX
* @param int $chunkZ
* @param Random $random
*/
public function populateChunk(ChunkManager $world, int $chunkX, int $chunkZ, Random $random) : void{
foreach($this->populators as $populator){
$populator->populate($world, $chunkX, $chunkZ, $random);
}
}
/**
* @return Populator[]
*/
public function getPopulators() : array{
return $this->populators;
}
public function setId(int $id) : void{
if(!$this->registered){
$this->registered = true;
$this->id = $id;
}
}
public function getId() : int{
return $this->id;
}
abstract public function getName() : string;
public function getMinElevation() : int{
return $this->minElevation;
}
public function getMaxElevation() : int{
return $this->maxElevation;
}
public function setElevation(int $min, int $max) : void{
$this->minElevation = $min;
$this->maxElevation = $max;
}
/**
* @return Block[]
*/
public function getGroundCover() : array{
return $this->groundCover;
}
/**
* @param Block[] $covers
*/
public function setGroundCover(array $covers) : void{
$this->groundCover = $covers;
}
public function getTemperature() : float{
return $this->temperature;
}
public function getRainfall() : float{
return $this->rainfall;
}
}

View File

@ -0,0 +1,40 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
class DesertBiome extends SandyBiome{
public function __construct(){
parent::__construct();
$this->setElevation(63, 74);
$this->temperature = 2;
$this->rainfall = 0;
}
public function getName() : string{
return "Desert";
}
}

View File

@ -0,0 +1,63 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\block\utils\TreeType;
use pocketmine\world\generator\populator\TallGrass;
use pocketmine\world\generator\populator\Tree;
class ForestBiome extends GrassyBiome{
/** @var TreeType */
private $type;
public function __construct(?TreeType $type = null){
parent::__construct();
$this->type = $type ?? TreeType::OAK();
$trees = new Tree($type);
$trees->setBaseAmount(5);
$this->addPopulator($trees);
$tallGrass = new TallGrass();
$tallGrass->setBaseAmount(3);
$this->addPopulator($tallGrass);
$this->setElevation(63, 81);
if($this->type->equals(TreeType::BIRCH())){
$this->temperature = 0.6;
$this->rainfall = 0.5;
}else{
$this->temperature = 0.7;
$this->rainfall = 0.8;
}
}
public function getName() : string{
return $this->type->getDisplayName() . " Forest";
}
}

View File

@ -0,0 +1,39 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\block\VanillaBlocks;
abstract class GrassyBiome extends Biome{
public function __construct(){
$this->setGroundCover([
VanillaBlocks::GRASS(),
VanillaBlocks::DIRT(),
VanillaBlocks::DIRT(),
VanillaBlocks::DIRT(),
VanillaBlocks::DIRT()
]);
}
}

View File

@ -0,0 +1,31 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
class HellBiome extends Biome{
public function getName() : string{
return "Hell";
}
}

View File

@ -0,0 +1,47 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\world\generator\populator\TallGrass;
class IcePlainsBiome extends SnowyBiome{
public function __construct(){
parent::__construct();
$tallGrass = new TallGrass();
$tallGrass->setBaseAmount(5);
$this->addPopulator($tallGrass);
$this->setElevation(63, 74);
$this->temperature = 0.05;
$this->rainfall = 0.8;
}
public function getName() : string{
return "Ice Plains";
}
}

View File

@ -0,0 +1,54 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\world\generator\populator\TallGrass;
use pocketmine\world\generator\populator\Tree;
class MountainsBiome extends GrassyBiome{
public function __construct(){
parent::__construct();
$trees = new Tree();
$trees->setBaseAmount(1);
$this->addPopulator($trees);
$tallGrass = new TallGrass();
$tallGrass->setBaseAmount(1);
$this->addPopulator($tallGrass);
//TODO: add emerald
$this->setElevation(63, 127);
$this->temperature = 0.4;
$this->rainfall = 0.5;
}
public function getName() : string{
return "Mountains";
}
}

View File

@ -0,0 +1,54 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\block\VanillaBlocks;
use pocketmine\world\generator\populator\TallGrass;
class OceanBiome extends Biome{
public function __construct(){
$this->setGroundCover([
VanillaBlocks::GRAVEL(),
VanillaBlocks::GRAVEL(),
VanillaBlocks::GRAVEL(),
VanillaBlocks::GRAVEL(),
VanillaBlocks::GRAVEL()
]);
$tallGrass = new TallGrass();
$tallGrass->setBaseAmount(5);
$this->addPopulator($tallGrass);
$this->setElevation(46, 58);
$this->temperature = 0.5;
$this->rainfall = 0.5;
}
public function getName() : string{
return "Ocean";
}
}

View File

@ -0,0 +1,47 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\world\generator\populator\TallGrass;
class PlainBiome extends GrassyBiome{
public function __construct(){
parent::__construct();
$tallGrass = new TallGrass();
$tallGrass->setBaseAmount(12);
$this->addPopulator($tallGrass);
$this->setElevation(63, 68);
$this->temperature = 0.8;
$this->rainfall = 0.4;
}
public function getName() : string{
return "Plains";
}
}

View File

@ -0,0 +1,54 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\block\VanillaBlocks;
use pocketmine\world\generator\populator\TallGrass;
class RiverBiome extends Biome{
public function __construct(){
$this->setGroundCover([
VanillaBlocks::DIRT(),
VanillaBlocks::DIRT(),
VanillaBlocks::DIRT(),
VanillaBlocks::DIRT(),
VanillaBlocks::DIRT()
]);
$tallGrass = new TallGrass();
$tallGrass->setBaseAmount(5);
$this->addPopulator($tallGrass);
$this->setElevation(58, 62);
$this->temperature = 0.5;
$this->rainfall = 0.7;
}
public function getName() : string{
return "River";
}
}

View File

@ -0,0 +1,39 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\block\VanillaBlocks;
abstract class SandyBiome extends Biome{
public function __construct(){
$this->setGroundCover([
VanillaBlocks::SAND(),
VanillaBlocks::SAND(),
VanillaBlocks::SANDSTONE(),
VanillaBlocks::SANDSTONE(),
VanillaBlocks::SANDSTONE()
]);
}
}

View File

@ -0,0 +1,38 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
class SmallMountainsBiome extends MountainsBiome{
public function __construct(){
parent::__construct();
$this->setElevation(63, 97);
}
public function getName() : string{
return "Small Mountains";
}
}

View File

@ -0,0 +1,39 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\block\VanillaBlocks;
abstract class SnowyBiome extends Biome{
public function __construct(){
$this->setGroundCover([
VanillaBlocks::SNOW_LAYER(),
VanillaBlocks::GRASS(),
VanillaBlocks::DIRT(),
VanillaBlocks::DIRT(),
VanillaBlocks::DIRT()
]);
}
}

View File

@ -0,0 +1,40 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
class SwampBiome extends GrassyBiome{
public function __construct(){
parent::__construct();
$this->setElevation(62, 63);
$this->temperature = 0.8;
$this->rainfall = 0.9;
}
public function getName() : string{
return "Swamp";
}
}

View File

@ -0,0 +1,53 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
use pocketmine\block\utils\TreeType;
use pocketmine\world\generator\populator\TallGrass;
use pocketmine\world\generator\populator\Tree;
class TaigaBiome extends SnowyBiome{
public function __construct(){
parent::__construct();
$trees = new Tree(TreeType::SPRUCE());
$trees->setBaseAmount(10);
$this->addPopulator($trees);
$tallGrass = new TallGrass();
$tallGrass->setBaseAmount(1);
$this->addPopulator($tallGrass);
$this->setElevation(63, 81);
$this->temperature = 0.05;
$this->rainfall = 0.8;
}
public function getName() : string{
return "Taiga";
}
}

View File

@ -0,0 +1,34 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\biome;
/**
* Polyfill class for biomes that are unknown to PocketMine-MP
*/
class UnknownBiome extends Biome{
public function getName() : string{
return "Unknown";
}
}