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

Get Item via slot

Comments in 'Plugin Development' started by MyNameIsTriXz, May 16, 2016.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    How can I get an item via its slot? So when I choose the 7th slot of a chest, I get the item on this slot? What's the function?
  2. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    PHP:
    $chestTile->getItem(6);
    Array always start at "0", and Chest must be Tile to get Chest Inventory.
    MyNameIsTriXz likes this.
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Thank you and how to get the slotnumber of an item?
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    As far as I know, you will need to use for().
  5. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    You mean searching the item for getting index?
    PHP:
    foreach($tile->getInventory()->getItems() as $key=>$item) {
    // do something checking and searching
    // also $key is an index of the item.
    }
    So you want to get the 7th item, then the index would be 7-1=6
    Or you want to get the specific slotnumber of an item that you already know the index ? Then +1 to the index.
    MyNameIsTriXz likes this.

Share This Page

Advertisement