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

Chest problems

Comments in 'Plugin Development' started by Angelo Vidrio, Apr 30, 2015.

  1. Angelo Vidrio
    Offline

    Angelo Vidrio Active Member Plugin Developer

    Joined:
    Jan 16, 2014
    Posts:
    123
    Plugins:
    5
    Minecraft User:
    LilCrispy45
    Hello, I am using the following code:
    PHP:
    foreach($w->getTiles() as $chest) {
                    if(
    $chest instanceof Chest) {
                        
    $this->getLogger()->info("CHESTS COMING");
                        if(
    $chest->getRealInventory()->getItem(0)->getName() == 'TNT') {
                            
    $chest->getRealInventory()->addItem(new Item(26801));
                            
    $chest->getRealInventory()->addItem(new Item(45901));
                            
    $chest->getRealInventory()->addItem(new Item(45901));
                            
    $chest->getRealInventory()->addItem(new Item(5030));
                            
    $chest->getRealInventory()->addItem(new Item(332016));
                        }
                    }
                }
    It does not log the message nor add items and there are multiple chests in world. Please help
  2. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,429
    Plugins:
    14
    The chunks must be loaded in order for Level::getTiles() to return tiles.
    Angelo Vidrio likes this.
  3. Angelo Vidrio
    Offline

    Angelo Vidrio Active Member Plugin Developer

    Joined:
    Jan 16, 2014
    Posts:
    123
    Plugins:
    5
    Minecraft User:
    LilCrispy45
    Before I run this, I do loadChunk for the players postion...
    LDX likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    How do you load?
    Angelo Vidrio likes this.
  5. Angelo Vidrio
    Offline

    Angelo Vidrio Active Member Plugin Developer

    Joined:
    Jan 16, 2014
    Posts:
    123
    Plugins:
    5
    Minecraft User:
    LilCrispy45
    Nevermind, thanks for helping, i used a different method and it works better now.

Share This Page

Advertisement