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

Couldn't update the hot bar

Discussion in 'Development' started by instantlyta, Jan 10, 2017.

  1. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    I've done setting the index to the hotbar slot with setHotbarSlotIndex();. Now it doesn't wanna update it for me. The hotbar looks the same on the client, like client-side doesn't receive the hotbar change.
    Using PMMP mcpe-1.0, MCPE version. Just to make sure if I missed something.
     
  2. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    Inventory is very buggy currently, it is due for a rewrite, but I'm waiting to see what @shoghicp comes up with for vanilla before I mess with PocketMine.

    I ought to warn that setHotbarSlotIndex() will be removed in the future due to bugs that it causes with desktop GUI. It has already been deprecated in some spoons.
     
    instantlyta, Muqsit and Sulfatezzz like this.
  3. Sulfatezzz

    Sulfatezzz Creeper

    Messages:
    1
    Really ? You normally don't need this function. The first 9 Items in the Inventory will be displayed on the hotbar

    This works for me

    PHP:
    $inventory $player->getInventory();

    $inventory->setItem(0, new Item(34501));
    $inventory->setItem(8, new Item(33101));

    $inventory->sendContents($player); //You may not need this
     
    Last edited: Jan 10, 2017
  4. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Try
    PHP:
    $player->getInventory()->getItemInHand($item);
    I'm not sure about the other slots. I guess it's
    PHP:
    $p->getInventory()->addItem(8$item);
    Please define $item
     
  5. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i suppose $item is an instance of "Item"
     
  6. instantlyta

    instantlyta Slime

    Messages:
    96
    GitHub:
    intagaming
    I mean really, if i was joined the server already and try to mess with the hotbar for awhile (Matching hotbar index 0 to inventory index 4 for instance), then if I set the inventory index 0 with an item, it doesn't show up at hotbar index 0. Even if you quit the game and join again, the hotbar pair with the inventory is the same, doesn't seem to be reset.
     
  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.