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

Potion (Item)

Comments in 'Plugin Development' started by abxyHD, May 26, 2016.

  1. abxyHD
    Offline

    abxyHD New Member

    Joined:
    Sep 20, 2015
    Posts:
    6
    Minecraft User:
    abxyHD
    Hi
    How can i give a Player a Potion.

    That Code here doesn't Work:

    PHP:
    $sender->getInventory()->addItem(Item::get(373:8225 01));
    Or isn't it possible?
  2. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    PocketMine does not support potions.

    Also, use
    Code:
    Item::get(Item::POTION, 8225, 1)
    PHP does not accept colons.
    abxyHD likes this.
  3. abxyHD
    Offline

    abxyHD New Member

    Joined:
    Sep 20, 2015
    Posts:
    6
    Minecraft User:
    abxyHD
    Works without an ErrorCode but it crashs my Client. :c
  4. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @abxyHD I've corrected it
    PHP:
    $sender->getInventory()->addItem(Item::get(37382251));
    abxyHD likes this.
  5. Yosshi999
    Offline

    Yosshi999 New Member Plugin Developer

    Joined:
    Mar 13, 2014
    Posts:
    29
    Plugins:
    1
    Minecraft User:
    Yosshi999
    abxyHD likes this.
  6. abxyHD
    Offline

    abxyHD New Member

    Joined:
    Sep 20, 2015
    Posts:
    6
    Minecraft User:
    abxyHD
    Thx so much to all. c:
    It works without ClientCrash! C:
  7. udwarf
    Offline

    udwarf Active Member

    Joined:
    Apr 17, 2016
    Posts:
    61
    Minecraft User:
    1Zaza
    abxyHD, join the dark side(i.e. PM forks), they have cookies (i.e. Potions) ;-)
    abxyHD likes this.
  8. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    My Method ist that :
    PHP:
    $item Item::ITEM_NAME ;
    $player $event->getPlayer();
    $player->getInventory()->addItem($item);
    i hope i helped you :p
    abxyHD likes this.
  9. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    Please learn to use the PocketMine API before you try to help people. You're passing an integer to addItem() which only takes Item objects. Furthermore, I think the previous posts already addresses the issue...
  10. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Ehm your comment is wrong too
    WitherTube likes this.
  11. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    PHP:
    $sender->getInventory()->addItem(Item::get(37382251)); 
    or
    PHP:
     $sender->getInventory()->addItem(Item::get(ITEM::ITEMNAME));
  12. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Item::NAME will return the Item ID, so it is basically the same. But, what you have to watch out for, is the damage. (second parameter). Each potion has a different one, but the same Item ID.
  13. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    archie426 likes this.

Share This Page

Advertisement