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

Chests....

Comments in 'Plugin Development' started by Sensej, Sep 5, 2014.

  1. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    So hey Coders,
    The last code for my plugin would be a chest refill code.
    I tried this but it doesent work.
    PHP:
    public function refillChests()
        {
        
    $level $this->getServer()->getLevelByName("world");
        
    $tiles $level->getTiles();
        foreach(
    $tiles as $t)     
        {
        if(
    $t instanceof Chest)
        {
        for(
    $slot 0$slot $t->getSize(); $slot++) {
        
    $t->setItem($slot, new Air());
        }}}
        }
    Last edited: Sep 5, 2014
  2. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
  3. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    Already Saw, but i dont understand why my code not working
  4. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    I already call the function with a command ;)
  5. Minetox
    Offline

    Minetox New Member

    Joined:
    Jun 23, 2014
    Posts:
    31
    Minecraft User:
    Minetox
    PHP:
    public function refillChests()
        {
        
    $level $this->getServer()->getLevelByName("world");
        
    $tiles $level->getTiles();
        foreach(
    $tiles as $t)     
        {
        if(
    $t instanceof Chest)
        {
        for(
    $slot 0$slot $t->getSize(); $slot++) {
        
    $t->getInventory()->setItem($slot, new Air()); //You need to call the Inventory for this methode ;)
        
    }}}
        } 
    Sensej likes this.
  6. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    PHP:
    public function refillChests()
        {
        
    $level $this->getServer()->getLevelByName("world");
        
    $tiles $level->getTiles();
        foreach(
    $tiles as $t)     
        {
        if(
    $t instanceof Chest)
        {
        for(
    $slot 0$slot $t->getSize(); $slot++) {
        
    $t->getInventory()->setItem($slot, new Air()); //You need to call the Inventory for this methode ;)
        
    }}}
        } 
    Thank you this Works :)

Share This Page

Advertisement