Implement a Living::getDisplayName() (#5384)

This commit is contained in:
IvanCraft623
2022-11-27 14:48:55 -05:00
committed by GitHub
parent 80a432d9ff
commit d476a4c1aa
2 changed files with 10 additions and 7 deletions

View File

@ -184,6 +184,13 @@ abstract class Living extends Entity{
$this->attributeMap->add($this->absorptionAttr = AttributeFactory::getInstance()->mustGet(Attribute::ABSORPTION));
}
/**
* Returns the name used to describe this entity in chat and command outputs.
*/
public function getDisplayName() : string{
return $this->nameTag !== "" ? $this->nameTag : $this->getName();
}
public function setHealth(float $amount) : void{
$wasAlive = $this->isAlive();
parent::setHealth($amount);