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

save hotbar

Comments in 'Plugin Development' started by Creeperface, Jul 30, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i have this code:
    PHP:
    //save hotbar
    $hotbar = [];
    $inv $player->getInventory();
    for(
    $i 0$i 7$i++){
         
    $hotbar[$i] = $inv->getHotbarSlotIndex($i);
    }

    //load hotbar
    for($i 0$i 7$i++){
          
    $inv->setHotbarSlotIndex($hotbar[$i], $i);
    }
    $inv->sendContents($player);
    but this doesnt work :/ what is wrong?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Maybe swap $hotbar[$i] and $i in the setting function?
    Creeperface likes this.
  3. Yosshi999
    Offline

    Yosshi999 New Member Plugin Developer

    Joined:
    Mar 13, 2014
    Posts:
    29
    Plugins:
    1
    Minecraft User:
    Yosshi999
    Are you in creative?
    Creative hotbar is different from a survival one.
  4. Yosshi999
    Offline

    Yosshi999 New Member Plugin Developer

    Joined:
    Mar 13, 2014
    Posts:
    29
    Plugins:
    1
    Minecraft User:
    Yosshi999
    In creative, $inv->hotbar[] is always {0,1,2, ...,8} . Data is in $slots[].
    Use getItem() and setItem().
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    No survival

Share This Page

Advertisement