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

Pairing 2 chests into 1

Comments in 'Plugin Development' started by Irish, May 12, 2016.

  1. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    I've been having trouble pairing two chests, and I have no clue what to do. It was working with one chest, but now has stopped. I have searched through the Chest.php and tried many ways with no success.

    Main:
    PHP:
    public function onDeath(Death $event) {
    $entity $event->getEntity();
    $lvl $entity->getLevel();
    if (
    $entity instanceof Player) {
    $x $entity->getX();
    $y $entity->getY();
    $z $entity->getZ();
    $dchest = new Block(Block::CHEST);
    $inventory $entity->getInventory()->getContents();
    $event->setDrops(array(Item::get(Item::AIR)));
    $entity->getLevel()->setBlock(new Vector3($x$y$z), new Block(Block::CHEST), truetrue);
    $entity->getLevel()->setBlock(new Vector3($x-1$y$z), $dchesttruetrue);
    $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id"Tile::CHEST), new IntTag("x"$x), new IntTag("y"$y), new IntTag("z"$z)]);
    $nbt->Items->setTagType(NBT::TAG_Compound);
    $tile Tile::createTile("Chest"$entity->getLevel()->getChunk($x >> 4$z >> 4), $nbt);
    $chest $lvl->getTile(new Vector3($x$y$z));
    $chest->getInventory()->setContents($inventory);
    $other $chest->getRight();
    if(
    $chest instanceof Chest){
    if(
    $chest->isPaired() === false){
    $chest->pairWith($dchest);
    }
    }
    }
    }
    Error:
    Code:
    [04:06:12] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerDeathEvent' to 'TimeBombPE v1.0.0': Call to a member function isPaired() on null on TimeBomb\Main
    [04:06:12] [Server thread/CRITICAL]: Error: "Call to a member function isPaired() on null" (EXCEPTION) in "/TimeBomb/src/TimeBomb/main" at line 69
    
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    The "Chest" you used... Is it pocketmine\block\Chest or pocketmine\tile\Chest?
  3. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    Should I use tile?
  4. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    Still having problems with making two single chests into one double chest.

Share This Page

Advertisement