From beb5bf6ddac4a9beb705ff2e789537d37efe6bcc Mon Sep 17 00:00:00 2001 From: Muqsit Date: Wed, 17 Jan 2018 13:56:59 +0400 Subject: [PATCH] Add API methods: Entity::isInvisible(), Entity::setInvisible() (#1930) * Make use of the API function in Effect class --- src/pocketmine/entity/Effect.php | 4 ++-- src/pocketmine/entity/Entity.php | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/entity/Effect.php b/src/pocketmine/entity/Effect.php index df978d036..04c740ba5 100644 --- a/src/pocketmine/entity/Effect.php +++ b/src/pocketmine/entity/Effect.php @@ -423,7 +423,7 @@ class Effect{ switch($this->id){ case Effect::INVISIBILITY: - $entity->setGenericFlag(Entity::DATA_FLAG_INVISIBLE, true); + $entity->setInvisible(); $entity->setNameTagVisible(false); break; case Effect::SPEED: @@ -466,7 +466,7 @@ class Effect{ switch($this->id){ case Effect::INVISIBILITY: - $entity->setGenericFlag(Entity::DATA_FLAG_INVISIBLE, false); + $entity->setInvisible(false); $entity->setNameTagVisible(true); break; case Effect::SPEED: diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index eb3865150..a64d6828c 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -655,6 +655,14 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ $this->setGenericFlag(self::DATA_FLAG_IMMOBILE, $value); } + public function isInvisible() : bool{ + return $this->getGenericFlag(self::DATA_FLAG_INVISIBLE); + } + + public function setInvisible(bool $value = true) : void{ + $this->setGenericFlag(self::DATA_FLAG_INVISIBLE, $value); + } + /** * Returns whether the entity is able to climb blocks such as ladders or vines. * @return bool