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

[SOLVED] Using NBT?

Discussion in 'Development' started by Jons, Dec 25, 2016.

  1. Jons

    Jons Spider

    Messages:
    14
    GitHub:
    jonsmc
    hi, i recently coded a plugin that uses NBT to detach something on an item, here is how i create and set NBT to it:
    PHP:
    $player $this->getServer()->getPlayer("Steve");
    $item pocketmine\item\Item::get(101 pocketmine\nbt\NBT::parseJSON("{display:{Name:'Good Name'}}"));
    $player->getInventory()->addItem($item);
    And using that tag in PlayerInteractEvent:
    PHP:
    //player interact heading..
    $player $event->getPlayer();
    if(isset(
    $player->getItemInHand()->tags->display)) {
      
    $player->sendMessage("§aYep, have display tag");
    }
    But it isn't working, nothing happen, no error logs, can you help?
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    You may want to try some var_dump($item); for some more info
     
  3. Jons

    Jons Spider

    Messages:
    14
    GitHub:
    jonsmc
    I did, but seems like it doesn't have "tags" variable, instead, "cachedNBT"
     
  4. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    You missed a comma in the Item::get argument list
     
    applqpak likes this.
  5. Jons

    Jons Spider

    Messages:
    14
    GitHub:
    jonsmc
    Sorry, i was on Mobile :), it's fixed now
     
  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.