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

Solved Set hotbar slot

Comments in 'Plugin Development' started by MCPEPIG, Dec 30, 2015.

  1. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    How can you change which hotbar slot a player's using?
  2. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
  3. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    I don't want to add items to a certain hotbar slot.
  4. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    I want to change the hotbar slot selected.
  5. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
  6. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Also not wat I was looking for, either way I found out how.
  7. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    For people still looking:
    PHP:
    // Change the Hotbar slot to one from the inventory:
    $player->getInventory()->setHeldItemSlot($slot);

    // Change the Hotbar slot from other Hotbar slot:
    $player->getInventory()->setHeldItemIndex($hotbarslot);
    Last edited: Dec 31, 2015
  8. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Erm that's wrong (I tried it), it sets what slot from the inventory is used for the hotbar slot that the player is currently using... This is what I use (It works):
    PHP:
    $player->getInventory()->setHeldItemIndex($hotbarslot);
    PEMapModder likes this.
  9. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Oh okey, got it now :p
    MCPEPIG likes this.

Share This Page

Advertisement