1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to add tag on item?

Discussion in 'Facepalm' started by Az928, Feb 6, 2017.

  1. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    Hi, I was wondering how to add tag to an item... I used
    PHP:
     $item->setNamedTag($tag);
    But it gave this error
    Code:
     pocketmine\item\Item::setNamedTag must be instanceof CompundTag 
    Thanks for help
     
    Last edited: Feb 6, 2017
  2. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    use setCustomName()
     
  3. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    How to add Item in inventory with custom name then?
     
  4. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    PHP:
    $item Item::DIAMOND_SWORD
    $item
    ->setCustomName("hi");
    $player->getInventory()->addItem($item);
     
  5. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    Thanks !
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.