Block: Replace Color and WoodType magic numbers with type-safe objects

this provides automatic type safety without the need for magic number value checking everywhere.
This commit is contained in:
Dylan K. Taylor
2019-02-12 13:52:59 +00:00
parent 18440f612f
commit 7b3993730a
25 changed files with 422 additions and 250 deletions

View File

@ -23,11 +23,25 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\TreeType;
class Wood extends Solid{
public const OAK = 0;
public const SPRUCE = 1;
public const BIRCH = 2;
public const JUNGLE = 3;
/** @var TreeType */
private $treeType;
public function __construct(int $id, int $variant, TreeType $treeType, ?string $name = null, int $itemId = null){
parent::__construct($id, $variant, $name, $itemId);
$this->treeType = $treeType;
}
/**
* TODO: this is ad hoc, but add an interface for this to all tree-related blocks
* @return TreeType
*/
public function getTreeType() : TreeType{
return $this->treeType;
}
public function getHardness() : float{
return 2;