Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Opening chests

Comments in 'Plugin Development' started by SuperChipsLP, Sep 23, 2014.

  1. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Hi!

    I need some help at opening a chest GUI.
    The chest should contain the items that I want it to have.

    What's the packet that I need to send, and, how do I send it?
    I had an almost working solution a few days ago, but then I
    accidentally deleted that part of my code. :D

    Thanks. :)
    LDX likes this.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Get the Tile (actually Chest) object of the chest using $level->getTile() and $chest->open($player)
  3. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    He means without a chest being affiliated.
    EvolSoft likes this.
  4. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    That would also work. :D

    Thanks, @PEMapModder :)
    LDX likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then create a CustomInventory object.
    SuperChipsLP likes this.
  6. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    How do I create such an object?
    PHPStorm can't find the class..
  7. MobileCrafter
    Offline

    MobileCrafter New Member

    Joined:
    Sep 8, 2013
    Posts:
    27
    LDX likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    MineMobileCrafter likes this.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Seriously? pocketmine\inventory\CustomInventory
    The InventoryHolder thing is a bit annoying though.
  10. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    I can't instantiate the class. :(
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You have to extend it yourself.
  12. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    Hmm if i try to use the ->open($player) methode i will get this error
    "Fatal error: Call to undefined method pocketmine\tile\Chest::eek:pen() in :eek:\***\
    Server\plugins\*****\src\*****\****.php on line 129
    22:48:42 [EMERGENCY] An unrecoverable error has occurred and the server has cras
    hed. Creating a crash dump"

    My Code
    PHP:
    $level $this->getServer()->getLevelByName("world")->getTile(new Vector3($x$y$z));
    $chest->open($player);
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Call the function on the ChestInventory, not the tile.
    ...->getTile(...)->getInventory();
  14. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    Hmm it doesent crash but it wont open the chest .
  15. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    here ismy code
    PHP:
    $chest $level->getTile(new Vector3(-126798, -980));
                
    $chest->getInventory()->open($player);
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Sorry, I don't know about this part.

Share This Page

Advertisement