Reduce repeated block-change-event related code

the new helper code reveals even more repetition, but this is at least consistent now.
This commit is contained in:
Dylan K. Taylor
2023-08-02 13:40:12 +01:00
parent 6000bcccdd
commit 82f87cc2da
20 changed files with 166 additions and 158 deletions

View File

@ -23,11 +23,11 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\BlockEventHelper;
use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\Fallable;
use pocketmine\block\utils\FallableTrait;
use pocketmine\event\block\BlockFormEvent;
use pocketmine\math\Facing;
class ConcretePowder extends Opaque implements Fallable{
@ -43,11 +43,7 @@ class ConcretePowder extends Opaque implements Fallable{
public function onNearbyBlockChange() : void{
if(($water = $this->getAdjacentWater()) !== null){
$ev = new BlockFormEvent($this, VanillaBlocks::CONCRETE()->setColor($this->color), $water);
$ev->call();
if(!$ev->isCancelled()){
$this->position->getWorld()->setBlock($this->position, $ev->getNewState());
}
BlockEventHelper::form($this, VanillaBlocks::CONCRETE()->setColor($this->color), $water);
}else{
$this->startFalling();
}