mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 22:45:28 +00:00
this is mostly working, but due to some issue with leaf decay, the edges of the larger canopy will decay within minutes. I don't know why this is yet, but it's likely some incorrect implementation of Leaves causing the problem. In addition, the secondary branch of acacia may generate next to the base block of the trunk, which I've never observed to happen in vanilla. This has a 2% chance of occurring, so I haven't been able to rule it out yet, but it probably shouldn't happen.
58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?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\generator\object;
|
|
|
|
use pocketmine\utils\Random;
|
|
|
|
final class TreeFactory{
|
|
|
|
/**
|
|
* @param TreeType|null $type default oak
|
|
*/
|
|
public static function get(Random $random, ?TreeType $type = null) : ?Tree{
|
|
$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{*/
|
|
|
|
//}
|
|
}elseif($type->equals(TreeType::ACACIA())){
|
|
return new AcaciaTree();
|
|
}
|
|
return null;
|
|
}
|
|
}
|