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

Easiests Method?

Discussion in 'Development' started by Junkdude, Mar 9, 2017.

  1. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    Easiest method to fill an entire chest with items?
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    PHP:
    $chestTile->getInventory()->setContents()
    ?
     
    LilCrispy2o9 likes this.
  3. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    But i only want to set slots 1-27 and leave 0 blank, probably should have stated that
     
  4. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    PHP:
    $chestTile->getInventory()->setContents(array(=> Item::get(0),$item1,$item2,$item3));
     
  5. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    What have you tried? A simple for-i loop is already simple enough.
     
    Thunder33345 likes this.
  6. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    thread solved
     
  7. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    A thread isn't solved if there is not an answer provided in the thread.
     
    Muqsit likes this.
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Are you replying to the thread...
     
  9. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Deleted, and no; I think there was a secret edit by someone, or maybe I am just going crazy.
     
  10. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    array_fill
    PHP:
    /** @var BaseInventory $inventory */
    $item Item::get(276); //The nether reactor aka "pocketmine" block.
    $array array_fill(126$item); //Starts from 1, has 26 keys.
    $inventory->setContents($array);
     
  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.