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

Solved Remove the item a player is holding in his hand

Discussion in 'Development' started by SkyZone, Apr 11, 2017.

  1. SkyZone

    SkyZone Slime

    Messages:
    95
    How can i do that?
    I've already tried things like:
    PHP:
    $player->getItemInHand()->clear();
    But its not working.

    Thanks for help :)
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    You are calling close on Item object. There is no such method and Item doesn't know where it is, it cannot destroy itself from container.
    Code:
    Inventory::removeItem(Item ...$item)
    
     
    SkyZone likes this.
  3. SkyZone

    SkyZone Slime

    Messages:
    95
    Will it work like that?
    Code:
    $itemrem = $player->getItemInHand();
    $player->Inventory::removeItem(Item, $itemrem);
     
  4. Primus

    Primus Zombie Pigman

    Messages:
    749
    -.-
    PHP:
    $player->getInventory()->removeItem($player->getItemInHand());
     
    SkyZone, Sandertv and corytortoise like this.
  5. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Massive facepalms...:facepalm:
     
  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.