From 1d5978df9804f56545ad2b3815ce98bf08abe0bc Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 30 Mar 2018 12:20:59 +0100 Subject: [PATCH] Fixed falling blocks getting moved by currents, closes #2080 --- src/pocketmine/block/Liquid.php | 10 ++++++---- src/pocketmine/entity/Entity.php | 9 +++++++++ src/pocketmine/entity/object/FallingBlock.php | 4 ++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/block/Liquid.php b/src/pocketmine/block/Liquid.php index 9d78a746e..16cfc1633 100644 --- a/src/pocketmine/block/Liquid.php +++ b/src/pocketmine/block/Liquid.php @@ -189,10 +189,12 @@ abstract class Liquid extends Transparent{ } public function addVelocityToEntity(Entity $entity, Vector3 $vector) : void{ - $flow = $this->getFlowVector(); - $vector->x += $flow->x; - $vector->y += $flow->y; - $vector->z += $flow->z; + if($entity->canBeMovedByCurrents()){ + $flow = $this->getFlowVector(); + $vector->x += $flow->x; + $vector->y += $flow->y; + $vector->z += $flow->z; + } } abstract public function tickRate() : int; diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index cfec599be..8239c7d34 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -1698,6 +1698,15 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ return $this->blocksAround; } + /** + * Returns whether this entity can be moved by currents in liquids. + * + * @return bool + */ + public function canBeMovedByCurrents() : bool{ + return true; + } + protected function checkBlockCollision(){ $vector = new Vector3(0, 0, 0); diff --git a/src/pocketmine/entity/object/FallingBlock.php b/src/pocketmine/entity/object/FallingBlock.php index 982c63ab5..44a7a55d3 100644 --- a/src/pocketmine/entity/object/FallingBlock.php +++ b/src/pocketmine/entity/object/FallingBlock.php @@ -79,6 +79,10 @@ class FallingBlock extends Entity{ return false; } + public function canBeMovedByCurrents() : bool{ + return false; + } + public function attack(EntityDamageEvent $source){ if($source->getCause() === EntityDamageEvent::CAUSE_VOID){ parent::attack($source);