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

addWindow not working

Discussion in 'Development' started by Nemo404, Aug 2, 2019.

  1. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
    I tried using

    PHP:
    $player->addWindow($chest->getInventory);
    $chest is a chest tile;

    i also tried
    PHP:
    $player->addWindows($player->getInventory()
     
  2. OnTheVerge

    OnTheVerge Spider Jockey

    Messages:
    46
    Try using this bud
    PHP:
    $player->addWindow($chest->getInventory());
     
  3. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
    already did, it was a typo. still not working
     
  4. OnTheVerge

    OnTheVerge Spider Jockey

    Messages:
    46
    Show me your full code
     
  5. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
    PHP:

                 $pos 
    = [
                    
    $player->getX(), $player->getY(), $player->getZ()
                ];
                
    $level $player->getLevel();
                
    $items = new ListTag("Items", []);
                
    $items->setTagType(NBT::TAG_Compound);
                
    $nbt = new CompoundTag("", [
                    
    $items,
                    new 
    StringTag("id"Tile::CHEST),
                    new 
    StringTag("CustomName""Insert Custom Name Here"),
                    new 
    IntTag("x"$pos[0]),
                    new 
    IntTag("y"$pos[1]),
                    new 
    IntTag("z"$pos[2])
                ]);
                
    $chest Tile::createTile(Tile::CHEST$level$nbt);
                if(
    $chest instanceof Chest)
                {
                
                    
    $chest->getInventory()->addItem($rpgItem['item']);
                    
    $player->addWindow($chest->getInventory());
                }
     
  6. OnTheVerge

    OnTheVerge Spider Jockey

    Messages:
    46
    What exactly is your error?
     
  7. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
    there were no error. it just doesnt show up
     
  8. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
    i can hear the chest opening sound. but nothing opened
     
  9. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    You need to setblock at that position as chest, also need to spawn the chest tile to the player before you addWindow
     
    OnTheVerge likes this.
  10. OnTheVerge

    OnTheVerge Spider Jockey

    Messages:
    46
    Is this executed on BlockPlaceEvent???
     
  11. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
    It was executed on command
     
  12. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    you can use this very useful library made by @Muqsit https://github.com/Muqsit/InvMenu
    read the README.md for instructions
     
    OnTheVerge and Muqsit like this.
  13. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
  14. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    you did not set the chest block
     
  15. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
    How to set the block?
     
  16. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    you get your wanted level's instance, then use the function called setBlock to set the block. The first parameter requires a Vector3 instance of your wanted location, and the second parameter requires a Block instance of your wanted block which you can get by using Block::get()
     
  17. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
  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.