pocketmine\tile\Chest::getPair PHP Method

getPair() public method

public getPair ( ) : Chest
return Chest
    public function getPair()
    {
        if ($this->isPaired()) {
            $tile = $this->getLevel()->getTile(new Vector3((int) $this->namedtag["pairx"], $this->y, (int) $this->namedtag["pairz"]));
            if ($tile instanceof Chest) {
                return $tile;
            }
        }
        return null;
    }

Usage Example

Exemplo n.º 1
0
 public function refillChest(Chest $chest, $refillPair = true)
 {
     $replaceSlots = [];
     $chest->clearAll();
     if (count($replaceSlots) >= $chest->getSize() / 2) {
         array_slice($replaceSlots, $chest->getSize() / 2 - 1);
     }
     foreach ($replaceSlots as $slot) {
         $item = null;
         // TODO: Decide items to put in chest.
         $chest->setItem($slot, $item);
     }
     if ($chest->isPaired() && $refillPair) {
         // Large chests
         $this->refillChest($chest->getPair(), false);
     }
 }