Replace BlockLegacyIds usages with BlockTypeIds where possible

This commit is contained in:
Dylan K. Taylor 2022-06-05 21:17:10 +01:00
parent f97c22c341
commit d2613039ed
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
31 changed files with 65 additions and 64 deletions

View File

@ -124,7 +124,7 @@ abstract class BaseBanner extends Transparent{
abstract protected function getSupportingFace() : int;
public function onNearbyBlockChange() : void{
if($this->getSide($this->getSupportingFace())->getId() === BlockLegacyIds::AIR){
if($this->getSide($this->getSupportingFace())->getTypeId() === BlockTypeIds::AIR){
$this->position->getWorld()->useBreakOn($this->position);
}
}

View File

@ -85,7 +85,7 @@ abstract class BaseSign extends Transparent{
abstract protected function getSupportingFace() : int;
public function onNearbyBlockChange() : void{
if($this->getSide($this->getSupportingFace())->getId() === BlockLegacyIds::AIR){
if($this->getSide($this->getSupportingFace())->getTypeId() === BlockTypeIds::AIR){
$this->position->getWorld()->useBreakOn($this->position);
}
}

View File

@ -88,7 +88,7 @@ class Cactus extends Transparent{
public function onNearbyBlockChange() : void{
$down = $this->getSide(Facing::DOWN);
if($down->getId() !== BlockLegacyIds::SAND && !$down->isSameType($this)){
if($down->getTypeId() !== BlockTypeIds::SAND && $down->getTypeId() !== BlockTypeIds::RED_SAND && !$down->isSameType($this)){
$this->position->getWorld()->useBreakOn($this->position);
}else{
foreach(Facing::HORIZONTAL as $side){
@ -113,7 +113,7 @@ class Cactus extends Transparent{
break;
}
$b = $this->position->getWorld()->getBlockAt($this->position->x, $this->position->y + $y, $this->position->z);
if($b->getId() === BlockLegacyIds::AIR){
if($b->getTypeId() === BlockTypeIds::AIR){
$ev = new BlockGrowEvent($b, VanillaBlocks::CACTUS());
$ev->call();
if($ev->isCancelled()){
@ -135,7 +135,7 @@ class Cactus extends Transparent{
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$down = $this->getSide(Facing::DOWN);
if($down->getId() === BlockLegacyIds::SAND || $down->isSameType($this)){
if($down->getTypeId() === BlockTypeIds::SAND || $down->getTypeId() === BlockTypeIds::RED_SAND || $down->isSameType($this)){
foreach(Facing::HORIZONTAL as $side){
if($this->getSide($side)->isSolid()){
return false;

View File

@ -81,7 +81,7 @@ class Cake extends Transparent implements FoodSource{
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$down = $this->getSide(Facing::DOWN);
if($down->getId() !== BlockLegacyIds::AIR){
if($down->getTypeId() !== BlockTypeIds::AIR){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}
@ -89,7 +89,7 @@ class Cake extends Transparent implements FoodSource{
}
public function onNearbyBlockChange() : void{
if($this->getSide(Facing::DOWN)->getId() === BlockLegacyIds::AIR){ //Replace with common break method
if($this->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::AIR){ //Replace with common break method
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR());
}
}

View File

@ -53,7 +53,7 @@ class Carpet extends Flowable{
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$down = $this->getSide(Facing::DOWN);
if($down->getId() !== BlockLegacyIds::AIR){
if($down->getTypeId() !== BlockTypeIds::AIR){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}
@ -61,7 +61,7 @@ class Carpet extends Flowable{
}
public function onNearbyBlockChange() : void{
if($this->getSide(Facing::DOWN)->getId() === BlockLegacyIds::AIR){
if($this->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::AIR){
$this->position->getWorld()->useBreakOn($this->position);
}
}

View File

@ -62,7 +62,7 @@ abstract class Crops extends Flowable{
}
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($blockReplace->getSide(Facing::DOWN)->getId() === BlockLegacyIds::FARMLAND){
if($blockReplace->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::FARMLAND){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}
@ -91,7 +91,7 @@ abstract class Crops extends Flowable{
}
public function onNearbyBlockChange() : void{
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::FARMLAND){
if($this->getSide(Facing::DOWN)->getTypeId() !== BlockTypeIds::FARMLAND){
$this->position->getWorld()->useBreakOn($this->position);
}
}

View File

@ -54,8 +54,8 @@ class DoublePlant extends Flowable{
}
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$id = $blockReplace->getSide(Facing::DOWN)->getId();
if(($id === BlockLegacyIds::GRASS || $id === BlockLegacyIds::DIRT) && $blockReplace->getSide(Facing::UP)->canBeReplaced()){
$id = $blockReplace->getSide(Facing::DOWN)->getTypeId();
if(($id === BlockTypeIds::GRASS || $id === BlockTypeIds::DIRT) && $blockReplace->getSide(Facing::UP)->canBeReplaced()){
$top = clone $this;
$top->top = true;
$tx->addBlock($blockReplace->position, $this)->addBlock($blockReplace->position->getSide(Facing::UP), $top);

View File

@ -224,7 +224,7 @@ class Fire extends Flowable{
continue;
}
$block = $world->getBlockAt($targetX, $targetY, $targetZ);
if($block->getId() !== BlockLegacyIds::AIR){
if($block->getTypeId() !== BlockTypeIds::AIR){
continue;
}

View File

@ -33,7 +33,7 @@ class Flower extends Flowable{
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$down = $this->getSide(Facing::DOWN);
if($down->getId() === BlockLegacyIds::GRASS || $down->getId() === BlockLegacyIds::DIRT || $down->getId() === BlockLegacyIds::FARMLAND){
if($down->getTypeId() === BlockTypeIds::GRASS || $down->getTypeId() === BlockTypeIds::DIRT || $down->getTypeId() === BlockTypeIds::FARMLAND){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}

View File

@ -103,7 +103,7 @@ class Grass extends Opaque{
$this->position->getWorld()->setBlock($this->position, $newBlock);
return true;
}elseif($item instanceof Shovel && $this->getSide(Facing::UP)->getId() === BlockLegacyIds::AIR){
}elseif($item instanceof Shovel && $this->getSide(Facing::UP)->getTypeId() === BlockTypeIds::AIR){
$item->applyDamage(1);
$newBlock = VanillaBlocks::GRASS_PATH();
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));

View File

@ -97,7 +97,7 @@ class Leaves extends Transparent{
return true;
}
if($block->getId() === $this->getId() && $distance <= 4){
if($block instanceof Leaves && $distance <= 4){
foreach(Facing::ALL as $side){
if($this->findLog($pos->getSide($side), $visited, $distance + 1)){
return true;

View File

@ -348,7 +348,7 @@ abstract class Liquid extends Transparent{
$ev = new BlockSpreadEvent($block, $this, $new);
$ev->call();
if(!$ev->isCancelled()){
if($block->getId() !== BlockLegacyIds::AIR){
if($block->getTypeId() !== BlockTypeIds::AIR){
$this->position->getWorld()->useBreakOn($block->position);
}

View File

@ -62,7 +62,7 @@ class NetherWartPlant extends Flowable{
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$down = $this->getSide(Facing::DOWN);
if($down->getId() === BlockLegacyIds::SOUL_SAND){
if($down->getTypeId() === BlockTypeIds::SOUL_SAND){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}
@ -70,7 +70,7 @@ class NetherWartPlant extends Flowable{
}
public function onNearbyBlockChange() : void{
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::SOUL_SAND){
if($this->getSide(Facing::DOWN)->getTypeId() !== BlockTypeIds::SOUL_SAND){
$this->position->getWorld()->useBreakOn($this->position);
}
}

View File

@ -68,7 +68,7 @@ class Sapling extends Flowable{
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$down = $this->getSide(Facing::DOWN);
if($down->getId() === BlockLegacyIds::GRASS || $down->getId() === BlockLegacyIds::DIRT || $down->getId() === BlockLegacyIds::FARMLAND){
if($down->getTypeId() === BlockTypeIds::GRASS || $down->getTypeId() === BlockTypeIds::DIRT || $down->getTypeId() === BlockTypeIds::FARMLAND){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}

View File

@ -53,7 +53,7 @@ abstract class Stem extends Crops{
$side = $this->getSide(Facing::HORIZONTAL[array_rand(Facing::HORIZONTAL)]);
$d = $side->getSide(Facing::DOWN);
if($side->getId() === BlockLegacyIds::AIR && ($d->getId() === BlockLegacyIds::FARMLAND || $d->getId() === BlockLegacyIds::GRASS || $d->getId() === BlockLegacyIds::DIRT)){
if($side->getTypeId() === BlockTypeIds::AIR && ($d->getTypeId() === BlockTypeIds::FARMLAND || $d->getTypeId() === BlockTypeIds::GRASS || $d->getTypeId() === BlockTypeIds::DIRT)){
$ev = new BlockGrowEvent($side, $grow);
$ev->call();
if(!$ev->isCancelled()){

View File

@ -56,7 +56,7 @@ class Sugarcane extends Flowable{
break;
}
$b = $this->position->getWorld()->getBlockAt($this->position->x, $this->position->y + $y, $this->position->z);
if($b->getId() === BlockLegacyIds::AIR){
if($b->getTypeId() === BlockTypeIds::AIR){
$ev = new BlockGrowEvent($b, VanillaBlocks::SUGARCANE());
$ev->call();
if($ev->isCancelled()){
@ -122,7 +122,7 @@ class Sugarcane extends Flowable{
$down = $this->getSide(Facing::DOWN);
if($down->isSameType($this)){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}elseif($down->getId() === BlockLegacyIds::GRASS || $down->getId() === BlockLegacyIds::DIRT || $down->getId() === BlockLegacyIds::SAND || $down->getId() === BlockLegacyIds::PODZOL){
}elseif($down->getTypeId() === BlockTypeIds::GRASS || $down->getTypeId() === BlockTypeIds::DIRT || $down->getTypeId() === BlockTypeIds::SAND || $down->getTypeId() === BlockTypeIds::RED_SAND || $down->getTypeId() === BlockTypeIds::PODZOL){
foreach(Facing::HORIZONTAL as $side){
if($down->getSide($side) instanceof Water){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);

View File

@ -78,8 +78,8 @@ class SweetBerryBush extends Flowable{
}
protected function canBeSupportedBy(Block $block) : bool{
$id = $block->getId();
return $id === BlockLegacyIds::GRASS || $id === BlockLegacyIds::DIRT || $id === BlockLegacyIds::PODZOL;
$id = $block->getTypeId();
return $id === BlockTypeIds::GRASS || $id === BlockTypeIds::DIRT || $id === BlockTypeIds::PODZOL;
}
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -38,8 +38,8 @@ class TallGrass extends Flowable{
}
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$down = $this->getSide(Facing::DOWN)->getId();
if($down === BlockLegacyIds::GRASS || $down === BlockLegacyIds::DIRT){
$down = $this->getSide(Facing::DOWN)->getTypeId();
if($down === BlockTypeIds::GRASS || $down === BlockTypeIds::DIRT){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}

View File

@ -55,7 +55,7 @@ class Wall extends Transparent{
}
}
$up = $this->getSide(Facing::UP)->getId() !== BlockLegacyIds::AIR;
$up = $this->getSide(Facing::UP)->getTypeId() !== BlockTypeIds::AIR;
if($up !== $this->up){
$this->up = $up;
$changed++;

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\block\Block;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\Fire;
use pocketmine\block\Liquid;
use pocketmine\block\VanillaBlocks;
@ -50,7 +50,7 @@ trait FallableTrait{
public function onNearbyBlockChange() : void{
$pos = $this->getPosition();
$down = $pos->getWorld()->getBlock($pos->getSide(Facing::DOWN));
if($down->getId() === BlockLegacyIds::AIR || $down instanceof Liquid || $down instanceof Fire){
if($down->getTypeId() === BlockTypeIds::AIR || $down instanceof Liquid || $down instanceof Fire){
$pos->getWorld()->setBlock($pos, VanillaBlocks::AIR());
$block = $this;

View File

@ -23,7 +23,7 @@ declare(strict_types=1);
namespace pocketmine\command\defaults;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\color\Color;
use pocketmine\command\CommandSender;
use pocketmine\command\utils\InvalidCommandSyntaxException;
@ -190,7 +190,7 @@ class ParticleCommand extends VanillaCommand{
case "terrain":
if($data !== null){
$block = StringToItemParser::getInstance()->parse($data)?->getBlock();
if($block !== null && $block->getId() !== BlockLegacyIds::AIR){
if($block !== null && $block->getTypeId() !== BlockTypeIds::AIR){
return new TerrainParticle($block);
}
}
@ -217,7 +217,7 @@ class ParticleCommand extends VanillaCommand{
}
break;
case "blockcrack":
if($data !== null && ($block = StringToItemParser::getInstance()->parse($data)?->getBlock()) !== null && $block->getId() !== BlockLegacyIds::AIR){
if($data !== null && ($block = StringToItemParser::getInstance()->parse($data)?->getBlock()) !== null && $block->getTypeId() !== BlockTypeIds::AIR){
return new TerrainParticle($block);
}
break;

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace pocketmine\entity;
use pocketmine\block\Block;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\data\bedrock\EffectIdMap;
use pocketmine\entity\animation\DeathAnimation;
use pocketmine\entity\animation\HurtAnimation;
@ -346,7 +346,7 @@ abstract class Living extends Entity{
new EntityLongFallSound($this) :
new EntityShortFallSound($this)
);
}elseif($fallBlock->getId() !== BlockLegacyIds::AIR){
}elseif($fallBlock->getTypeId() !== BlockTypeIds::AIR){
$this->broadcastSound(new EntityLandSound($this, $fallBlock));
}
return $newVerticalVelocity;
@ -756,10 +756,10 @@ abstract class Living extends Entity{
--$nextIndex;
}
$id = $block->getId();
$id = $block->getTypeId();
if($transparent === null){
if($id !== BlockLegacyIds::AIR){
if($id !== BlockTypeIds::AIR){
break;
}
}else{

View File

@ -23,7 +23,7 @@ declare(strict_types=1);
namespace pocketmine\entity\projectile;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\color\Color;
use pocketmine\data\bedrock\PotionTypeIdMap;
@ -130,11 +130,11 @@ class SplashPotion extends Throwable{
}elseif($event instanceof ProjectileHitBlockEvent && $this->getPotionType()->equals(PotionType::WATER())){
$blockIn = $event->getBlockHit()->getSide($event->getRayTraceResult()->getHitFace());
if($blockIn->getId() === BlockLegacyIds::FIRE){
if($blockIn->getTypeId() === BlockTypeIds::FIRE){
$this->getWorld()->setBlock($blockIn->getPosition(), VanillaBlocks::AIR());
}
foreach($blockIn->getHorizontalSides() as $horizontalSide){
if($horizontalSide->getId() === BlockLegacyIds::FIRE){
if($horizontalSide->getTypeId() === BlockTypeIds::FIRE){
$this->getWorld()->setBlock($horizontalSide->getPosition(), VanillaBlocks::AIR());
}
}

View File

@ -23,7 +23,7 @@ declare(strict_types=1);
namespace pocketmine\event\player;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\entity\Living;
use pocketmine\event\entity\EntityDamageByBlockEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;
@ -138,7 +138,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
case EntityDamageEvent::CAUSE_CONTACT:
if($deathCause instanceof EntityDamageByBlockEvent){
if($deathCause->getDamager()->getId() === BlockLegacyIds::CACTUS){
if($deathCause->getDamager()->getTypeId() === BlockTypeIds::CACTUS){
return KnownTranslationFactory::death_attack_cactus($name);
}
}

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
@ -33,7 +33,7 @@ use pocketmine\world\sound\FlintSteelSound;
class FlintSteel extends Tool{
public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector) : ItemUseResult{
if($blockReplace->getId() === BlockLegacyIds::AIR){
if($blockReplace->getTypeId() === BlockTypeIds::AIR){
$world = $player->getWorld();
$world->setBlock($blockReplace->getPosition(), VanillaBlocks::FIRE());
$world->addSound($blockReplace->getPosition()->add(0.5, 0.5, 0.5), new FlintSteelSound());

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace pocketmine\player;
use pocketmine\block\Bed;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\UnknownBlock;
use pocketmine\block\VanillaBlocks;
use pocketmine\command\CommandSender;
@ -1613,7 +1613,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
}
$block = $target->getSide($face);
if($block->getId() === BlockLegacyIds::FIRE){
if($block->getTypeId() === BlockTypeIds::FIRE){
$this->getWorld()->setBlock($block->getPosition(), VanillaBlocks::AIR());
$this->getWorld()->addSound($block->getPosition()->add(0.5, 0.5, 0.5), new FireExtinguishSound());
return true;

View File

@ -29,7 +29,7 @@ namespace pocketmine\world;
use pocketmine\block\Air;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\tile\Spawnable;
use pocketmine\block\tile\Tile;
use pocketmine\block\tile\TileFactory;
@ -444,7 +444,7 @@ class World implements ChunkManager{
continue;
}
if($block->getId() !== BlockLegacyIds::AIR){
if($block->getTypeId() !== BlockTypeIds::AIR){
$dontTickBlocks[$block->getTypeId()] = $name;
}
}
@ -1776,7 +1776,7 @@ class World implements ChunkManager{
return false;
}
if($blockClicked->getId() === BlockLegacyIds::AIR){
if($blockClicked->getTypeId() === BlockTypeIds::AIR){
return false;
}
@ -2651,7 +2651,7 @@ class World implements ChunkManager{
$x = (int) $v->x;
$z = (int) $v->z;
$y = (int) min($max - 2, $v->y);
$wasAir = $this->getBlockAt($x, $y - 1, $z)->getId() === BlockLegacyIds::AIR; //TODO: bad hack, clean up
$wasAir = $this->getBlockAt($x, $y - 1, $z)->getTypeId() === BlockTypeIds::AIR; //TODO: bad hack, clean up
for(; $y > $this->minY; --$y){
if($this->getBlockAt($x, $y, $z)->isFullCube()){
if($wasAir){

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator\object;
use pocketmine\block\Block;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\VanillaBlocks;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;
@ -47,7 +47,7 @@ class TallGrass{
for($c = 0; $c < $count; ++$c){
$x = $random->nextRange($pos->x - $radius, $pos->x + $radius);
$z = $random->nextRange($pos->z - $radius, $pos->z + $radius);
if($world->getBlockAt($x, $pos->y + 1, $z)->getId() === BlockLegacyIds::AIR && $world->getBlockAt($x, $pos->y, $z)->getId() === BlockLegacyIds::GRASS){
if($world->getBlockAt($x, $pos->y + 1, $z)->getTypeId() === BlockTypeIds::AIR && $world->getBlockAt($x, $pos->y, $z)->getTypeId() === BlockTypeIds::GRASS){
$world->setBlockAt($x, $pos->y + 1, $z, $arr[$random->nextRange(0, $arrC)]);
}
}

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator\populator;
use pocketmine\block\BlockFactory;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\Liquid;
use pocketmine\utils\Random;
use pocketmine\world\biome\BiomeRegistry;
@ -60,7 +60,7 @@ class GroundCover implements Populator{
for($y = $startY; $y > $endY && $y >= 0; --$y){
$b = $cover[$startY - $y];
$id = $factory->fromFullBlock($chunk->getFullBlock($x, $y, $z));
if($id->getId() === BlockLegacyIds::AIR && $b->isSolid()){
if($id->getTypeId() === BlockTypeIds::AIR && $b->isSolid()){
break;
}
if($b->canBeFlowedInto() && $id instanceof Liquid){

View File

@ -23,7 +23,8 @@ declare(strict_types=1);
namespace pocketmine\world\generator\populator;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\Leaves;
use pocketmine\block\VanillaBlocks;
use pocketmine\utils\Random;
use pocketmine\world\ChunkManager;
@ -57,14 +58,14 @@ class TallGrass implements Populator{
}
private function canTallGrassStay(ChunkManager $world, int $x, int $y, int $z) : bool{
$b = $world->getBlockAt($x, $y, $z)->getId();
return ($b === BlockLegacyIds::AIR || $b === BlockLegacyIds::SNOW_LAYER) && $world->getBlockAt($x, $y - 1, $z)->getId() === BlockLegacyIds::GRASS;
$b = $world->getBlockAt($x, $y, $z)->getTypeId();
return ($b === BlockTypeIds::AIR || $b === BlockTypeIds::SNOW_LAYER) && $world->getBlockAt($x, $y - 1, $z)->getTypeId() === BlockTypeIds::GRASS;
}
private function getHighestWorkableBlock(ChunkManager $world, int $x, int $z) : int{
for($y = 127; $y >= 0; --$y){
$b = $world->getBlockAt($x, $y, $z)->getId();
if($b !== BlockLegacyIds::AIR && $b !== BlockLegacyIds::LEAVES && $b !== BlockLegacyIds::LEAVES2 && $b !== BlockLegacyIds::SNOW_LAYER){
$b = $world->getBlockAt($x, $y, $z);
if($b->getTypeId() !== BlockTypeIds::AIR && !($b instanceof Leaves) && $b->getTypeId() !== BlockTypeIds::SNOW_LAYER){
return $y + 1;
}
}

View File

@ -23,7 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\generator\populator;
use pocketmine\block\BlockLegacyIds;
use pocketmine\block\BlockTypeIds;
use pocketmine\block\utils\TreeType;
use pocketmine\utils\Random;
use pocketmine\world\ChunkManager;
@ -67,10 +67,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)->getId();
if($b === BlockLegacyIds::DIRT || $b === BlockLegacyIds::GRASS){
$b = $world->getBlockAt($x, $y, $z)->getTypeId();
if($b === BlockTypeIds::DIRT || $b === BlockTypeIds::GRASS){
return $y + 1;
}elseif($b !== BlockLegacyIds::AIR && $b !== BlockLegacyIds::SNOW_LAYER){
}elseif($b !== BlockTypeIds::AIR && $b !== BlockTypeIds::SNOW_LAYER){
return -1;
}
}