From 47c862bc38b08543be51b502aa15d5234a594b1a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 23 Jun 2018 12:57:13 +0100 Subject: [PATCH] Projectile: check for blockhit change on nearby blockupdate --- src/pocketmine/entity/projectile/Projectile.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pocketmine/entity/projectile/Projectile.php b/src/pocketmine/entity/projectile/Projectile.php index 768334c05..66c0a1433 100644 --- a/src/pocketmine/entity/projectile/Projectile.php +++ b/src/pocketmine/entity/projectile/Projectile.php @@ -162,17 +162,19 @@ abstract class Projectile extends Entity{ return true; } - public function hasMovementUpdate() : bool{ - $parent = parent::hasMovementUpdate(); - if($parent and $this->blockHit !== null){ + public function onNearbyBlockChange() : void{ + if($this->blockHit !== null){ $blockIn = $this->level->getBlockAt($this->blockHit->x, $this->blockHit->y, $this->blockHit->z); - - if($blockIn->getId() === $this->blockHitId and $blockIn->getDamage() === $this->blockHitData){ - return false; + if($blockIn->getId() !== $this->blockHitId or $blockIn->getDamage() !== $this->blockHitData){ + $this->blockHit = $this->blockHitId = $this->blockHitData = null; } } - return $parent; + parent::onNearbyBlockChange(); + } + + public function hasMovementUpdate() : bool{ + return $this->blockHit === null and parent::hasMovementUpdate(); } public function move(float $dx, float $dy, float $dz) : void{