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

Open chest

Discussion in 'Development' started by SergeyIvanov, Dec 4, 2016.

  1. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    How I can open chest window? And add items and name.
     
  2. XShockinFireX

    XShockinFireX Creeper

    Messages:
    4
    GitHub:
    xshockinfirex
    To open a tile's inventory for the specified player:
    PHP:
    $player->addWindow($tile->getInventory());
    To add an item in a tile's inventory:
    PHP:
    $tile->getInventory()->addItem($item);
     
  3. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    How to get tile?
     
  4. XShockinFireX

    XShockinFireX Creeper

    Messages:
    4
    GitHub:
    xshockinfirex
  5. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
  6. XShockinFireX

    XShockinFireX Creeper

    Messages:
    4
    GitHub:
    xshockinfirex
    Use InventoryTransactionEvent and get the item that was interacted with.
     
  7. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    I get item:

    PHP:
    if($event->getItem()->getId() == 276){
     
    $event->setCancelled();
    }
    And he give me error:

    [21:21:41] [Server thread/CRITICAL]: "Невозможно обработать событие 'pocketmine\event\inventory\InventoryTransactionEvent' в 'addWind
    ow v1': Call to undefined method pocketmine\event\inventory\InventoryTransactionEvent::getItem() в GenisysFTW\Main"
    [21:21:41] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\event\inventory\InventoryTransactionEvent::getItem()
    " (EXCEPTION) in "/plugins/addWindow-master/src/GenisysFTW/Main" at line 59
     
  8. KnownUnown

    KnownUnown Spider Jockey Poggit Reviewer

    Messages:
    47
    GitHub:
    knownunown
    This isn't your personal debugging service - some knowledge of the API is required. Looking at InventoryTransactionEvent, the error your code is giving you is to be expected, there is no getItem() method in InventoryTransactionEvent (https://github.com/pmmp/PocketMine-...event/inventory/InventoryTransactionEvent.php). However, it does have a getTransaction() method that returns a TransactionGroup...hmm...maybe this interface has some use! https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/inventory/TransactionGroup.php
     
    XShockinFireX and SOFe like this.
  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.