Add API methods: Entity::isInvisible(), Entity::setInvisible() (#1930)

* Make use of the API function in Effect class
This commit is contained in:
Muqsit 2018-01-17 13:56:59 +04:00 committed by Dylan K. Taylor
parent 7a5e5773b7
commit beb5bf6dda
2 changed files with 10 additions and 2 deletions

View File

@ -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:

View File

@ -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