Make use of CompoundTag->hasTag()

This commit is contained in:
Dylan K. Taylor
2017-10-16 18:32:08 +01:00
parent 292e462ea0
commit 28a840d161
7 changed files with 17 additions and 17 deletions

View File

@ -41,14 +41,14 @@ class Sign extends Spawnable{
protected $text = ["", "", "", ""];
public function __construct(Level $level, CompoundTag $nbt){
if($nbt->getTag(self::TAG_TEXT_BLOB) instanceof StringTag){ //MCPE 1.2 save format
if($nbt->hasTag(self::TAG_TEXT_BLOB, StringTag::class)){ //MCPE 1.2 save format
$this->text = explode("\n", $nbt->getString(self::TAG_TEXT_BLOB));
assert(count($this->text) === 4, "Too many lines!");
$nbt->removeTag(self::TAG_TEXT_BLOB);
}else{
for($i = 1; $i <= 4; ++$i){
$textKey = sprintf(self::TAG_TEXT_LINE, $i);
if($nbt->getTag($textKey) instanceof StringTag){
if($nbt->hasTag($textKey, StringTag::class)){
$this->text[$i - 1] = $nbt->getString($textKey);
$nbt->removeTag($textKey);
}
@ -140,8 +140,8 @@ class Sign extends Spawnable{
return false;
}
if(($blob = $nbt->getString(self::TAG_TEXT_BLOB)) !== null){
$lines = array_pad(explode("\n", $blob), 4, "");
if($nbt->hasTag(self::TAG_TEXT_BLOB, StringTag::class)){
$lines = array_pad(explode("\n", $nbt->getString(self::TAG_TEXT_BLOB)), 4, "");
}else{
$lines = [
$nbt->getString(sprintf(self::TAG_TEXT_LINE, 1)),