First look at using (very) basic tags for dynamic block properties

this allows plugins to, for example, add their own custom dirt-like blocks which support having flowers placed on them.
This commit is contained in:
Dylan K. Taylor
2022-07-24 00:08:02 +01:00
parent 817591910b
commit d9b050fb68
17 changed files with 158 additions and 98 deletions

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator\populator;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\BlockTypeTags;
use pocketmine\block\utils\TreeType;
use pocketmine\utils\Random;
use pocketmine\world\ChunkManager;
@@ -67,10 +68,10 @@ class Tree implements Populator{
private function getHighestWorkableBlock(ChunkManager $world, int $x, int $z) : int{
for($y = 127; $y >= 0; --$y){
$b = $world->getBlockAt($x, $y, $z)->getTypeId();
if($b === BlockTypeIds::DIRT || $b === BlockTypeIds::GRASS){
$b = $world->getBlockAt($x, $y, $z);
if($b->hasTypeTag(BlockTypeTags::DIRT) || $b->hasTypeTag(BlockTypeTags::MUD)){
return $y + 1;
}elseif($b !== BlockTypeIds::AIR && $b !== BlockTypeIds::SNOW_LAYER){
}elseif($b->getTypeId() !== BlockTypeIds::AIR && $b->getTypeId() !== BlockTypeIds::SNOW_LAYER){
return -1;
}
}