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

Solved Information about opened chest

Discussion in 'Development' started by Yexeed, Oct 11, 2017.

  1. Yexeed

    Yexeed Slime

    Messages:
    76
    How to get information about chest, which was opened by player? E.g. name, items in it
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Only if you knew the coordinates and had access to the level instance of the chest.
    You'll need to fetch the Tile instance of the chest, then you can call API functions such as Chest::getViewers() and Chest::getInventory().
    PHP:
    $chest $level->getTile(new Vector3($x$y$z));
    if(
    $chest !== null){
        
    $chest->getViewers();//Player[]s viewing the chest.
        
    $chest->getInventory()->get contents();//Item[]s in chest.
    }
     
    Yexeed and Kyd like this.
  3. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    It should be getContents() :D Autocorrector? :p
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    yup :[ my bad.
     
  5. Yexeed

    Yexeed Slime

    Messages:
    76
    thanks a lot
     
  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.