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

addWindow() without the block

Discussion in 'Development' started by Muqsit, Jan 20, 2017.

  1. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Is it possible to send a chest window to a player without setting chest block at the tile location?

    PHP:
        public function onCommand(CommandSender $issuerCommand $cmd$label, array $args)
        {
            
    $issuer->sendMessage("DEBUG MESSAGE SPAWNING TILE");
            
    //$issuer->getLevel()->setBlock($issuer->subtract(0, 2, 0), Block::get(Block::CHEST), true, true);
            
    $nbt = new CompoundTag('', [
                new 
    ListTag('Items', []),
                new 
    StringTag('id'Tile::CHEST),
                new 
    IntTag('x'floor($issuer->x)),
                new 
    IntTag('y'floor($issuer->y) - 2),
                new 
    IntTag('z'floor($issuer->z))
            ]);
           
    /** @var Chest $tile */
            
    $tile Tile::createTile('Chest'$issuer->chunk$nbt);

            
    $customInv = new ChestInventory($tile);
            
    $issuer->addWindow($customInv);
            
    $issuer->sendMessage("DEBUG: Custom Inventory sent.");
        }
    Didn't work. No errors.
    Source modifications are appreciated too.
     
    Primus likes this.
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    If you dont want to setblock, then you need to send the block to the player, as without a block the client will not display the inventory
    PHP:
    $block Block::get(54);
    $block->floor($issuer->x);
    $block->floor($issuer->y)-2;
    $block->floor($issuer->z);
    $block->level $issuer->level;
    $issuer->level->sendBlocks([$issuer],[$block]);
     
    Muqsit and Primus like this.
  3. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    Send a fake tile (packets) to the player and if that doesn't work then try sending a fake chest block and fake tile with packets. If you get it to work and see 'ghost blocks' (blocks that don't really exist but the client interprets as real) you'll have resend/update the blocks or you could just resend the chunk.
     
  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.