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

Remove 1 item from item in hand

Discussion in 'Development' started by Kabluinc, May 30, 2017.

  1. Kabluinc

    Kabluinc Baby Zombie

    Messages:
    129
    Im trying to remove 1 emerald from a players hand. He may have a stack of 6 forexample but when i run:

    Code:
    $player->getInventory->removeItem(new \pocketmine\item\Emerald(0,1));
    it takes the whole stack.

    Pls help
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Do not create a new item class in that way. Always use
    PHP:
    Item::get(Item::EMERALDdamagecount);
    You almost made it!
    PHP:
    $player->getInventory()->removeItem(Item::get(Item::EMERALD01));
     
    corytortoise likes this.
  3. Kabluinc

    Kabluinc Baby Zombie

    Messages:
    129
    Thanksss
     
  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.