Entity: Cater for old data with CustomNameVisible as a StringTag

This was a bug in older versions, fixed by 890f72dbf23a77f294169b79590770470041adc4. However since ALPHA10 this has been moved to the new, strict-ified CompoundTag API, which shits its pants when it encounters a tag of the wrong type.

Closes jojoe77777/Slapper#119
This commit is contained in:
Dylan K. Taylor 2018-01-26 20:01:04 +00:00
parent 6c8a1a5b80
commit 6fd4b9f1e2

View File

@ -848,7 +848,14 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
if($this->namedtag->hasTag("CustomName", StringTag::class)){
$this->setNameTag($this->namedtag->getString("CustomName"));
$this->setNameTagVisible($this->namedtag->getByte("CustomNameVisible", 1) !== 0);
if($this->namedtag->hasTag("CustomNameVisible", StringTag::class)){
//Older versions incorrectly saved this as a string (see 890f72dbf23a77f294169b79590770470041adc4)
$this->setNameTagVisible($this->namedtag->getString("CustomNameVisible") !== "");
$this->namedtag->removeTag("CustomNameVisible");
}else{
$this->setNameTagVisible($this->namedtag->getByte("CustomNameVisible", 1) !== 0);
}
}
$this->scheduleUpdate();