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

Giving a name to a virtual inventory won't work

Discussion in 'Development' started by Karanpatel567, Oct 6, 2017.

  1. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    Hey, does anyone know why this doesn't rename my virtual inventory? It just stays "Chest"
    PHP:
        public function sendBin (Player $player) {
            
    $nbt = new CompoundTag "", [
                    new 
    StringTag "id"Tile::CHEST ),
                    new 
    IntTag "Inventory"),
                    new 
    StringTag("CustomName"c::GREEN"ImperialBin"),
                    new 
    IntTag "x", ( int ) $player->getX () ),
                    new 
    IntTag "y", ( int ) $player->getY () ),
                    new 
    IntTag "z", ( int ) $player->getZ () )
            ] );
            
    /** @var Chest $tile */
            
    $tile Tile::createTile "Chest"$player->getLevel (), $nbt );
            
    $block Block::get Block::CHEST );
            
    $block->= ( int ) $tile->x;
            
    $block->= ( int ) $tile->y;
            
    $block->= ( int ) $tile->z;
            
    $block->level $tile->getLevel ();
            
    $block->level->sendBlocks ( [
                    
    $player
            
    ], [
                    
    $block
            
    ] );
     
    Dovie and Levi like this.
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    I think custom chest names were removed in 1.2
     
  3. Derpific

    Derpific Spider Jockey

    Messages:
    44
    GitHub:
    Derpific
    They were not removed in 1.2, I have tested it
    Try this:
    PHP:
        public function sendBin (Player $player) {
            
    $nbt = new CompoundTag "", [
                    new 
    StringTag "id"Tile::CHEST ),
                    new 
    IntTag "Inventory"),
                    new 
    StringTag("CustomName"c::GREEN"ImperialBin"),
                    new 
    IntTag "x", ( int ) $player->getX () ),
                    new 
    IntTag "y", ( int ) $player->getY () ),
                    new 
    IntTag "z", ( int ) $player->getZ () )
            ] );
            
    /** @var Chest $tile */
            
    $tile Tile::createTile "Chest"$player->getLevel (), $nbt );
            
    $block Block::get Block::CHEST );
            
    $block->= ( int ) $tile->x;
            
    $block->= ( int ) $tile->y;
            
    $block->= ( int ) $tile->z;
            
    $block->level $tile->getLevel ();
            
    $block->level->sendBlocks ( [
                    
    $player
            
    ], [
                    
    $block
            
    ] );
            
    $inventory = new ChestInventory($tile);
            
    $tile->saveNBT();
            
    $tile->spawnTo($player);
            
    $player->addWindow($inventory);
            return 
    $inventory;
    [/QUOTE]
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Why saveNBT() :eek:?
     
  5. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    I've had the same issue, you have to send blocks BEFORE creating the tile, that fixed my problem
     
  6. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    Any code?
     
  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.