From b5b4133c5d0763284fcd9a0e432b2eb26c4f7114 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 18 Jul 2019 19:45:59 +0100 Subject: [PATCH] Item: fixed always-false null checks on getNamedTag() result --- src/pocketmine/item/Item.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 833e6e1546..402f0dce73 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -644,7 +644,7 @@ class Item implements ItemIds, \JsonSerializable{ * @return 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(); } - if(($tag = $this->getNamedTag()) !== null){ - $data["nbt_b64"] = base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($tag))); + if($this->hasNamedTag()){ + $data["nbt_b64"] = base64_encode((new LittleEndianNbtSerializer())->write(new TreeRoot($this->getNamedTag()))); } return $data; @@ -710,8 +710,8 @@ class Item implements ItemIds, \JsonSerializable{ ->setByte("Count", Binary::signByte($this->count)) ->setShort("Damage", $this->getMeta()); - if(($itemNBT = $this->getNamedTag()) !== null){ - $result->setTag("tag", $itemNBT); + if($this->hasNamedTag()){ + $result->setTag("tag", $this->getNamedTag()); } if($slot !== -1){