Remove circular dependency between Tree and its children

This commit is contained in:
Dylan K. Taylor
2021-08-27 20:25:21 +01:00
parent 4778c1483a
commit beba0ffe15
3 changed files with 58 additions and 29 deletions

View File

@ -26,7 +26,6 @@ namespace pocketmine\world\generator\object;
use pocketmine\block\Block;
use pocketmine\block\Leaves;
use pocketmine\block\Sapling;
use pocketmine\block\utils\TreeType;
use pocketmine\block\VanillaBlocks;
use pocketmine\utils\Random;
use pocketmine\world\BlockTransaction;
@ -49,32 +48,6 @@ abstract class Tree{
$this->treeHeight = $treeHeight;
}
/**
* @param TreeType|null $type default oak
*/
public static function get(Random $random, ?TreeType $type = null) : ?self{
$type = $type ?? TreeType::OAK();
if($type->equals(TreeType::SPRUCE())){
return new SpruceTree();
}elseif($type->equals(TreeType::BIRCH())){
if($random->nextBoundedInt(39) === 0){
return new BirchTree(true);
}else{
return new BirchTree();
}
}elseif($type->equals(TreeType::JUNGLE())){
return new JungleTree();
}elseif($type->equals(TreeType::OAK())){ //default
return new OakTree();
/*if($random->nextRange(0, 9) === 0){
$tree = new BigTree();
}else{*/
//}
}
return null;
}
public function canPlaceObject(ChunkManager $world, int $x, int $y, int $z, Random $random) : bool{
$radiusToCheck = 0;
for($yy = 0; $yy < $this->treeHeight + 3; ++$yy){