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

Spawn chest

Comments in 'Plugin Development' started by Sensej, Apr 5, 2015.

  1. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    Hello,

    Im trying to spawn a chest but im failing a lot. Here is my code. could please someone explain why its not working?

    PHP:
    $nbt = new Compound(false,[
    new 
    Enum("Items", []),
    new 
    String("id"Tile::CHEST),
    new 
    Int("x"$pos->getX() + $pos->getX()),
    new 
    Int("y"$pos->getY() + $pos->getY()),new Int("z"$pos->getZ() + $pos->getZ())]);
    $nbt->setName("random");
    $chest = new Chest($level->getChunk((($pos->getX() + $pos->getX() >> 4)), (($pos->getZ() + $pos->getX()) >> 4)), $nbt);
    $level->addTile($chest);
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What? $pos->getX() + $pos->getX()? Can you explain it?
  3. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    oh please ignore this. Im now on this Code but it wont spawn a chest.

    PHP:
    $nbt = new Compound(false,
            [
                new 
    Enum("Items", []),
                new 
    String("id"Tile::CHEST),
                new 
    Int("x"$pos->getX()),
                new 
    Int("y"$pos->getY()),
                new 
    Int("z"$pos->getZ())
            ]
            );
            
    $nbt->setName("random");
            
    $chest = new Chest($level->getChunk($pos->getX() >> 4$pos->getZ() >> 4), $nbt);
            
    $tile $chest->createTile(Tile::CHEST$level->getChunk($pos->getX() >> 4$pos->getZ() >> 4), $nbttrue);
            
    $level->addTile($tile);
            
    $chest->spawnToAll();

Share This Page

Advertisement