From cbeae906e1ae0f593c495c43e8d0584cfea7439c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 12 Jan 2023 21:34:44 +0000 Subject: [PATCH] Torch: remove unused variable --- src/block/Torch.php | 1 - src/block/WaterLily.php | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/block/Torch.php b/src/block/Torch.php index 77046867a..768c21223 100644 --- a/src/block/Torch.php +++ b/src/block/Torch.php @@ -65,7 +65,6 @@ class Torch extends Flowable{ } public function onNearbyBlockChange() : void{ - $below = $this->getSide(Facing::DOWN); $face = Facing::opposite($this->facing); if(!$this->canBeSupportedBy($this->getSide($face), $this->facing)){ diff --git a/src/block/WaterLily.php b/src/block/WaterLily.php index 25af0a8b0..8263330f6 100644 --- a/src/block/WaterLily.php +++ b/src/block/WaterLily.php @@ -23,9 +23,12 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\item\Item; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use pocketmine\math\Vector3; +use pocketmine\player\Player; +use pocketmine\world\BlockTransaction; class WaterLily extends Flowable{ @@ -40,8 +43,19 @@ class WaterLily extends Flowable{ return !$blockReplace instanceof Water && parent::canBePlacedAt($blockReplace, $clickVector, $face, $isClickedBlock); } + private function canBeSupportedBy(Block $block) : bool{ + return $block instanceof Water; + } + + public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ + if(!$this->canBeSupportedBy($blockReplace->getSide(Facing::DOWN))){ + return false; + } + return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); + } + public function onNearbyBlockChange() : void{ - if(!($this->getSide(Facing::DOWN) instanceof Water)){ + if(!$this->canBeSupportedBy($this->getSide(Facing::DOWN))){ $this->position->getWorld()->useBreakOn($this->position); } }