InventoryContentPacket

Discussion in 'Development' started by KielKing, Nov 22, 2018.

  1. KielKing

    KielKing Creeper

    Messages:
    3
    GitHub:
    kielking
    Hello PocketMine-MP Forums.

    I have an issue, my goal is to fill the container's inventory with a stone block but unfortunately that did not happen.

    This is the code i used:

    PHP:
    /* @var Player $this->player */
    /* @var Vector3 $this->pos */
    $pk1 = new ContainerOpenPacket();
    $pk1->windowId WindowTypes::MINECART_CHEST;
    $pk1->type WindowTypes::CONTAINER;
    $pk1->$this->pos->x;
    $pk1->$this->pos->y;
    $pk1->$this->pos->z;
    $this->player->sendDataPacket($pk1);

    $pk2 = new InventoryContentPacket();
    $pk2->windowId =  WindowTypes::MINECART_CHEST;
    $pk2->items array_fill(02Item::get(Item::AIR00));
    $pk2->items[3] = Item::get(Item::STONE04);
    $this->player->sendDataPacket($pk2);
    Does anyone know why this is?
    Thanks in advanced.
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    593
    Same here. Better use tiles...
     
  3. KielKing

    KielKing Creeper

    Messages:
    3
    GitHub:
    kielking
    Really? I don't want to use tiles as is it server-side, and not really efficient
     
  4. Muqsit

    Muqsit Wither Skeleton Verified

    Messages:
    1,419
    GitHub:
    muqsit
    What exactly are you trying to do? If you are using packets for those things, then you'll need to handle ContainerClosePacket and InventoryTransactionPacket yourself. You may end up writing what's already written in the pocketmine core.
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    593

Share This Page

  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.