mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
Added nametag saving
This commit is contained in:
parent
840690d801
commit
70a7c4c552
@ -268,6 +268,13 @@ abstract class Entity extends Location implements Metadatable{
|
||||
return $this->getDataProperty(self::DATA_NAMETAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNameTagVisible(){
|
||||
return $this->getDataProperty(self::DATA_SHOW_NAMETAG) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
@ -275,6 +282,13 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$this->setDataProperty(self::DATA_NAMETAG, self::DATA_TYPE_STRING, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setNameTagVisible($value = true){
|
||||
$this->setDataProperty(self::DATA_SHOW_NAMETAG, self::DATA_TYPE_BYTE, $value ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Effect[]
|
||||
*/
|
||||
@ -406,6 +420,8 @@ abstract class Entity extends Location implements Metadatable{
|
||||
public function saveNBT(){
|
||||
if(!($this instanceof Player)){
|
||||
$this->namedtag->id = new String("id", $this->getSaveId());
|
||||
$this->namedtag->CustomName = new String("CustomName", $this->getNameTag());
|
||||
$this->namedtag->CustomNameVisible = new String("CustomNameVisible", $this->isNameTagVisible());
|
||||
}
|
||||
|
||||
$this->namedtag->Pos = new Enum("Pos", [
|
||||
@ -463,6 +479,12 @@ abstract class Entity extends Location implements Metadatable{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($this->namedtag->CustomName)){
|
||||
$this->setNameTag($this->namedtag["CustomName"]);
|
||||
$this->setNameTagVisible($this->namedtag["CustomNameVisible"] > 0);
|
||||
}
|
||||
|
||||
$this->scheduleUpdate();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user