pocketmine\item\Item::getNamedTag PHP Method

getNamedTag() public method

public getNamedTag ( )
    public function getNamedTag()
    {
        if (!$this->hasCompoundTag()) {
            return null;
        } elseif ($this->cachedNBT !== null) {
            return $this->cachedNBT;
        }
        return $this->cachedNBT = self::parseCompoundTag($this->tags);
    }

Usage Example

Example #1
8
 /**
  * @param Item $item
  * @param int  $slot
  * @return CompoundTag
  */
 public static function putItemHelper(Item $item, $slot = null)
 {
     $tag = new CompoundTag(null, ["id" => new ShortTag("id", $item->getId()), "Count" => new ByteTag("Count", $item->getCount()), "Damage" => new ShortTag("Damage", $item->getDamage())]);
     if ($slot !== null) {
         $tag->Slot = new ByteTag("Slot", (int) $slot);
     }
     if ($item->hasCompoundTag()) {
         $tag->tag = clone $item->getNamedTag();
         $tag->tag->setName("tag");
     }
     return $tag;
 }
All Usage Examples Of pocketmine\item\Item::getNamedTag