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

Error of addItem of hotbar

Comments in 'Plugin Development' started by Valeron, Mar 2, 2016.

  1. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    $event->getPlayer()->getInventory()->getHotbarSlotIndex(2)->addItem( Item::get(2, 0, 2) )->setItemInHand(2);

    How can i fix it?
  2. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    I wanna set id2 to hotbar slot
  3. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    I wanna set in 4 slot
  4. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    Can u give example?
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    give us the error.
    Valeron likes this.
  6. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    addItem() on integer
  7. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    Call to funtion: additem() on integer
  8. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    don't you understand the error?
    Player::getHotbarSlotIndex(2) returns an Integer, and is there functions on the integer?
    so It would be
    PHP:
    $slot $event->getPlayer()->getInventory()->getHotbarSlotIndex(2);

    $i $event->getPlayer()->getInventory()->setItem($slot$item);

    $event->getPlayer()->getInventory()->setItemInHand($item);
    Last edited: Mar 11, 2016
    PEMapModder and Valeron like this.
  9. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    call to undefined method setitem
  10. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
  11. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    Doubleclick
  12. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    $player = $event->getPlayer();
    $player->getInventory()->setItem(0, Item::get(388,0,1));
    $player->getInventory()->setHotbarSlotIndex(0,388);
    Does not works... What will i do?
  13. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    $player->getInventory()->setHotbarSlotIndex(5,Item::get(Item::EMERALD,0,1));
    I tried. Doesnt works
  14. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
  15. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Use PhP Brackets...
  16. Valeron
    Offline

    Valeron New Member

    Joined:
    Aug 26, 2015
    Posts:
    111
    Minecraft User:
    DarkSpive
    So, what will i do?

Share This Page

Advertisement