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

Chest

Discussion in 'Development' started by LucGamesDE, Jun 3, 2017.

  1. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Hi. I tried to spawn a temporary chest. With my code I only set a chest block. I saw some posts about chest tiles but they weren't working for me.
    My code:
    PHP:
    $player->getLevel()->setBlock(new Vector3($p->x$p->2$p->z), Block::get(54), truetrue);
    Then I want to get the inventory and open it to the player using addWindow ()
     
  2. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
    So instead you only show one line of code? Why not showing the whole code that didn't work including errors! Put some effort in it or stop making plugins.
     
    corytortoise likes this.
  3. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    There are no errors.

    This code only creates a chest. But I want to reset the block when the inventory is closed.
    PHP:
    public function onClick(PlayerInteractEvent $e) {
    $player $e->getPlayer();
    if(
    $e->getBlock()->getId() == 1) {
    $chest $player->getLevel()->setBlock(new Vector3($player->x$player->2$player->z), Block::get(54), truetrue);
    $inv $chest->getInventory();
    $player->addWindow($inv);
    }
    }
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    You must create Chest Tile
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Create a window?
    PHP:
    $inventort $player->getLevel()->getTile($p)->getInventory();
    $player->addWindow($inventort);
     
  6. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    What is $p? And how can I create the tile?
     
  7. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Whatever $p is here:
     
  8. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    $p is $player
     
  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.