Move TreeType to generator package, added dedicated SaplingType enum

TreeType includes a bunch of stuff that don't have regular saplings associated with them, such as mangrove and azalea trees.
Mangrove has a dedicated propagule block with different behaviour than the others, and azalea trees are grown from azalea blocks, which are solid and have different behaviour to saplings.

We may also want to account for crimson and warped 'trees' in TreeType too, although I'm not sure if those belong there or not.
This commit is contained in:
Dylan K. Taylor
2023-05-04 16:54:10 +01:00
parent 299ff5d912
commit 2c81446e5b
10 changed files with 97 additions and 24 deletions

View File

@ -27,7 +27,7 @@ use pocketmine\block\BlockIdentifier as BID;
use pocketmine\block\BlockTypeIds as Ids;
use pocketmine\block\tile\Sign as TileSign;
use pocketmine\block\utils\LeavesType;
use pocketmine\block\utils\TreeType;
use pocketmine\block\utils\SaplingType;
use pocketmine\block\utils\WoodType;
use pocketmine\item\VanillaItems;
use pocketmine\utils\AssumptionFailedError;
@ -124,14 +124,14 @@ final class BlockLegacyIdHelper{
});
}
public static function getSaplingIdentifier(TreeType $treeType) : BID{
public static function getSaplingIdentifier(SaplingType $treeType) : BID{
return new BID(match($treeType->id()){
TreeType::OAK()->id() => Ids::OAK_SAPLING,
TreeType::SPRUCE()->id() => Ids::SPRUCE_SAPLING,
TreeType::BIRCH()->id() => Ids::BIRCH_SAPLING,
TreeType::JUNGLE()->id() => Ids::JUNGLE_SAPLING,
TreeType::ACACIA()->id() => Ids::ACACIA_SAPLING,
TreeType::DARK_OAK()->id() => Ids::DARK_OAK_SAPLING,
SaplingType::OAK()->id() => Ids::OAK_SAPLING,
SaplingType::SPRUCE()->id() => Ids::SPRUCE_SAPLING,
SaplingType::BIRCH()->id() => Ids::BIRCH_SAPLING,
SaplingType::JUNGLE()->id() => Ids::JUNGLE_SAPLING,
SaplingType::ACACIA()->id() => Ids::ACACIA_SAPLING,
SaplingType::DARK_OAK()->id() => Ids::DARK_OAK_SAPLING,
default => throw new AssumptionFailedError("All tree types should be covered")
});
}