Item: fixed always-false null checks on getNamedTag() result

This commit is contained in:
Dylan K. Taylor 2019-07-18 19:45:59 +01:00
parent e22986f065
commit b5b4133c5d

View File

@ -644,7 +644,7 @@ class Item implements ItemIds, \JsonSerializable{
* @return string * @return string
*/ */
final public function __toString() : string{ final public function __toString() : string{
return "Item " . $this->name . " (" . $this->id . ":" . ($this->hasAnyDamageValue() ? "?" : $this->getMeta()) . ")x" . $this->count . (($tag = $this->getNamedTag()) !== null ? " tags:0x" . base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($tag))) : ""); return "Item " . $this->name . " (" . $this->id . ":" . ($this->hasAnyDamageValue() ? "?" : $this->getMeta()) . ")x" . $this->count . ($this->hasNamedTag() ? " tags:0x" . base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($this->getNamedTag()))) : "");
} }
/** /**
@ -665,8 +665,8 @@ class Item implements ItemIds, \JsonSerializable{
$data["count"] = $this->getCount(); $data["count"] = $this->getCount();
} }
if(($tag = $this->getNamedTag()) !== null){ if($this->hasNamedTag()){
$data["nbt_b64"] = base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($tag))); $data["nbt_b64"] = base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($this->getNamedTag())));
} }
return $data; return $data;
@ -710,8 +710,8 @@ class Item implements ItemIds, \JsonSerializable{
->setByte("Count", Binary::signByte($this->count)) ->setByte("Count", Binary::signByte($this->count))
->setShort("Damage", $this->getMeta()); ->setShort("Damage", $this->getMeta());
if(($itemNBT = $this->getNamedTag()) !== null){ if($this->hasNamedTag()){
$result->setTag("tag", $itemNBT); $result->setTag("tag", $this->getNamedTag());
} }
if($slot !== -1){ if($slot !== -1){