diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index eecb2a8ad..2069c97f7 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -359,6 +359,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ protected $gravity; /** @var float */ protected $drag; + /** @var bool */ + protected $gravityEnabled = true; /** @var Server */ protected $server; @@ -1046,6 +1048,14 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->level->broadcastPacketToViewers($this, $pk); } + public function hasGravity() : bool{ + return $this->gravityEnabled; + } + + public function setHasGravity(bool $v = true) : void{ + $this->gravityEnabled = $v; + } + protected function applyDragBeforeGravity() : bool{ return false; } @@ -1061,7 +1071,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->motion->y *= $friction; } - $this->applyGravity(); + if($this->gravityEnabled){ + $this->applyGravity(); + } if(!$this->applyDragBeforeGravity()){ $this->motion->y *= $friction; diff --git a/src/pocketmine/entity/Squid.php b/src/pocketmine/entity/Squid.php index 352a4d8d0..9a2cf896b 100644 --- a/src/pocketmine/entity/Squid.php +++ b/src/pocketmine/entity/Squid.php @@ -99,6 +99,7 @@ class Squid extends WaterAnimal{ } $inWater = $this->isUnderwater(); + $this->setHasGravity(!$inWater); if(!$inWater){ $this->swimDirection = null; }elseif($this->swimDirection !== null){ @@ -118,12 +119,6 @@ class Squid extends WaterAnimal{ return $hasUpdate; } - protected function applyGravity() : void{ - if(!$this->isUnderwater()){ - parent::applyGravity(); - } - } - public function getDrops() : array{ return [ ItemFactory::get(Item::DYE, 0, mt_rand(1, 3))