Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how do you know the number of the subject ?

Comments in 'Plugin Development' started by Barrington, Oct 16, 2015.

  1. Barrington
    Offline

    Barrington New Member

    Joined:
    Jul 31, 2015
    Posts:
    41
    Minecraft User:
    Berrington
    I need to know the number of the object , for example :

    if($p->getInventory()->getItemInHand()->getId() === 1){
    $p->sendMessage("hmm okay");
    return false;
    }

    and I need to accomplish something if the stone at count 10
  2. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    PHP:
    $ev->getItemInHand()->getCount();
    Tip: read THE DOCS
  3. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    If you are trying to get the item of a hand of a player it should be:
    PHP:
    $player->getInventory()->getItemInHand()->getCount();
    To learn more about how to do something with a player's inventory, look here: https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/inventory/PlayerInventory.php
    No, you should take your own advice and read the "docs". It's the "source code", not the docs. Please make sure you know what you're doing before replying.

Share This Page

Advertisement