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

Chest

Comments in 'Plugin Development' started by Bluplayz, Dec 19, 2015.

  1. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    I want to edit specific Chests at specific coordinates so like:

    PHP:
    $inv = ($x$y$z);
    $inv->addItem(1);
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    // you have position for a chest $x $y $z and the world name $world
    // $main points to a PluginBase instance, which should be $this if you are in the main class
    $level $main->getServer()->getLevelByName($world);
    $tile $level->getTile(new Vector3($x$y$z));
    if(
    $tile instanceof \pocketmine\tile\Chest){
      
    $inventory $tile->getInventory();
      
    $inventory->addItem(Item::get(1));
    }
    Also keep in mind that Inventory::addItem() accepts variadic parameters of Item, which means that you can pass any amount of parameters into it but they must all be instances of Item; you must not pass an integer.
    Andrey Nazarchuk likes this.

Share This Page

Advertisement