From d2613039ed1226779282c6c12dfae19521014958 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 5 Jun 2022 21:17:10 +0100 Subject: [PATCH] Replace BlockLegacyIds usages with BlockTypeIds where possible --- src/block/BaseBanner.php | 2 +- src/block/BaseSign.php | 2 +- src/block/Cactus.php | 6 +++--- src/block/Cake.php | 4 ++-- src/block/Carpet.php | 4 ++-- src/block/Crops.php | 4 ++-- src/block/DoublePlant.php | 4 ++-- src/block/Fire.php | 2 +- src/block/Flower.php | 2 +- src/block/Grass.php | 2 +- src/block/Leaves.php | 2 +- src/block/Liquid.php | 2 +- src/block/NetherWartPlant.php | 4 ++-- src/block/Sapling.php | 2 +- src/block/Stem.php | 2 +- src/block/Sugarcane.php | 4 ++-- src/block/SweetBerryBush.php | 4 ++-- src/block/TallGrass.php | 4 ++-- src/block/Wall.php | 2 +- src/block/utils/FallableTrait.php | 4 ++-- src/command/defaults/ParticleCommand.php | 6 +++--- src/entity/Living.php | 8 ++++---- src/entity/projectile/SplashPotion.php | 6 +++--- src/event/player/PlayerDeathEvent.php | 4 ++-- src/item/FlintSteel.php | 4 ++-- src/player/Player.php | 4 ++-- src/world/World.php | 8 ++++---- src/world/generator/object/TallGrass.php | 4 ++-- src/world/generator/populator/GroundCover.php | 4 ++-- src/world/generator/populator/TallGrass.php | 11 ++++++----- src/world/generator/populator/Tree.php | 8 ++++---- 31 files changed, 65 insertions(+), 64 deletions(-) diff --git a/src/block/BaseBanner.php b/src/block/BaseBanner.php index 708254afd..f318c16df 100644 --- a/src/block/BaseBanner.php +++ b/src/block/BaseBanner.php @@ -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); } } diff --git a/src/block/BaseSign.php b/src/block/BaseSign.php index e201a2d72..7fcdc0e9a 100644 --- a/src/block/BaseSign.php +++ b/src/block/BaseSign.php @@ -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); } } diff --git a/src/block/Cactus.php b/src/block/Cactus.php index 5ed929db6..5e7cc7cbf 100644 --- a/src/block/Cactus.php +++ b/src/block/Cactus.php @@ -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; diff --git a/src/block/Cake.php b/src/block/Cake.php index ebde23012..fe341cf40 100644 --- a/src/block/Cake.php +++ b/src/block/Cake.php @@ -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()); } } diff --git a/src/block/Carpet.php b/src/block/Carpet.php index 54a1b4abe..a4e1855c0 100644 --- a/src/block/Carpet.php +++ b/src/block/Carpet.php @@ -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); } } diff --git a/src/block/Crops.php b/src/block/Crops.php index 1979ce31f..425711ce8 100644 --- a/src/block/Crops.php +++ b/src/block/Crops.php @@ -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); } } diff --git a/src/block/DoublePlant.php b/src/block/DoublePlant.php index 155a8e59d..9b5160fa0 100644 --- a/src/block/DoublePlant.php +++ b/src/block/DoublePlant.php @@ -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); diff --git a/src/block/Fire.php b/src/block/Fire.php index b31151c37..114379d8a 100644 --- a/src/block/Fire.php +++ b/src/block/Fire.php @@ -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; } diff --git a/src/block/Flower.php b/src/block/Flower.php index ff2d0344b..e2a318863 100644 --- a/src/block/Flower.php +++ b/src/block/Flower.php @@ -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); } diff --git a/src/block/Grass.php b/src/block/Grass.php index 82d42c55f..478a0755e 100644 --- a/src/block/Grass.php +++ b/src/block/Grass.php @@ -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)); diff --git a/src/block/Leaves.php b/src/block/Leaves.php index 8d00611c7..b8468d0d8 100644 --- a/src/block/Leaves.php +++ b/src/block/Leaves.php @@ -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; diff --git a/src/block/Liquid.php b/src/block/Liquid.php index 8aed66253..eb553ff2a 100644 --- a/src/block/Liquid.php +++ b/src/block/Liquid.php @@ -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); } diff --git a/src/block/NetherWartPlant.php b/src/block/NetherWartPlant.php index 0a809c950..f7d2f992d 100644 --- a/src/block/NetherWartPlant.php +++ b/src/block/NetherWartPlant.php @@ -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); } } diff --git a/src/block/Sapling.php b/src/block/Sapling.php index 9709032c5..83dc41d19 100644 --- a/src/block/Sapling.php +++ b/src/block/Sapling.php @@ -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); } diff --git a/src/block/Stem.php b/src/block/Stem.php index c7fd444af..6ffb39604 100644 --- a/src/block/Stem.php +++ b/src/block/Stem.php @@ -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()){ diff --git a/src/block/Sugarcane.php b/src/block/Sugarcane.php index b90efa77e..f6d42d61c 100644 --- a/src/block/Sugarcane.php +++ b/src/block/Sugarcane.php @@ -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); diff --git a/src/block/SweetBerryBush.php b/src/block/SweetBerryBush.php index 2de41cd11..22f510e7f 100644 --- a/src/block/SweetBerryBush.php +++ b/src/block/SweetBerryBush.php @@ -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{ diff --git a/src/block/TallGrass.php b/src/block/TallGrass.php index b77a828fe..2fed7ca7f 100644 --- a/src/block/TallGrass.php +++ b/src/block/TallGrass.php @@ -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); } diff --git a/src/block/Wall.php b/src/block/Wall.php index 17af1f137..90ff17d84 100644 --- a/src/block/Wall.php +++ b/src/block/Wall.php @@ -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++; diff --git a/src/block/utils/FallableTrait.php b/src/block/utils/FallableTrait.php index 6afcc52bf..0aa1971d2 100644 --- a/src/block/utils/FallableTrait.php +++ b/src/block/utils/FallableTrait.php @@ -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; diff --git a/src/command/defaults/ParticleCommand.php b/src/command/defaults/ParticleCommand.php index 9abe965ff..a898e1939 100644 --- a/src/command/defaults/ParticleCommand.php +++ b/src/command/defaults/ParticleCommand.php @@ -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; diff --git a/src/entity/Living.php b/src/entity/Living.php index 52dc02dbc..c8010ab0f 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -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{ diff --git a/src/entity/projectile/SplashPotion.php b/src/entity/projectile/SplashPotion.php index 555a8d755..952f0d1f6 100644 --- a/src/entity/projectile/SplashPotion.php +++ b/src/entity/projectile/SplashPotion.php @@ -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()); } } diff --git a/src/event/player/PlayerDeathEvent.php b/src/event/player/PlayerDeathEvent.php index 01358dd87..487be1f30 100644 --- a/src/event/player/PlayerDeathEvent.php +++ b/src/event/player/PlayerDeathEvent.php @@ -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); } } diff --git a/src/item/FlintSteel.php b/src/item/FlintSteel.php index ee387f4e6..e55e48e95 100644 --- a/src/item/FlintSteel.php +++ b/src/item/FlintSteel.php @@ -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()); diff --git a/src/player/Player.php b/src/player/Player.php index a120231e1..da3467592 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -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; diff --git a/src/world/World.php b/src/world/World.php index 004a4fd38..4efe550f3 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -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){ diff --git a/src/world/generator/object/TallGrass.php b/src/world/generator/object/TallGrass.php index 8fe70e0c8..0790f0bd8 100644 --- a/src/world/generator/object/TallGrass.php +++ b/src/world/generator/object/TallGrass.php @@ -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)]); } } diff --git a/src/world/generator/populator/GroundCover.php b/src/world/generator/populator/GroundCover.php index 7a72e021c..d2e553bc0 100644 --- a/src/world/generator/populator/GroundCover.php +++ b/src/world/generator/populator/GroundCover.php @@ -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){ diff --git a/src/world/generator/populator/TallGrass.php b/src/world/generator/populator/TallGrass.php index de8d0b675..a441f3e5c 100644 --- a/src/world/generator/populator/TallGrass.php +++ b/src/world/generator/populator/TallGrass.php @@ -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; } } diff --git a/src/world/generator/populator/Tree.php b/src/world/generator/populator/Tree.php index b0a2214b8..99b1171f0 100644 --- a/src/world/generator/populator/Tree.php +++ b/src/world/generator/populator/Tree.php @@ -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; } }