__construct() public method

public __construct ( pocketmine\inventory\InventoryHolder $holder, InventoryType $type, array $items = [], integer $overrideSize = null, string $overrideTitle = null )
$holder pocketmine\inventory\InventoryHolder
$type InventoryType
$items array
$overrideSize integer
$overrideTitle string
 public function __construct(Chest $left, Chest $right)
 {
     $this->left = $left->getRealInventory();
     $this->right = $right->getRealInventory();
     $items = array_merge($this->left->getContents(), $this->right->getContents());
     BaseInventory::__construct($this, InventoryType::get(InventoryType::DOUBLE_CHEST), $items);
 }
Beispiel #2
0
 public function __construct(Human $player, $contents = null)
 {
     $this->hotbar = range(0, $this->getHotbarSize() - 1, 1);
     parent::__construct($player, InventoryType::get(InventoryType::PLAYER));
     if ($contents !== null) {
         if ($contents instanceof ListTag) {
             //Saved data to be loaded into the inventory
             foreach ($contents as $item) {
                 if ($item["Slot"] >= 0 and $item["Slot"] < $this->getHotbarSize()) {
                     //Hotbar
                     if (isset($item["TrueSlot"])) {
                         //Valid slot was found, change the linkage to this slot
                         if (0 <= $item["TrueSlot"] and $item["TrueSlot"] < $this->getSize()) {
                             $this->hotbar[$item["Slot"]] = $item["TrueSlot"];
                         } elseif ($item["TrueSlot"] < 0) {
                             //Link to an empty slot (empty hand)
                             $this->hotbar[$item["Slot"]] = -1;
                         }
                     }
                     /* If TrueSlot is not set, leave the slot index as its default which was filled in above
                      * This only overwrites slot indexes for valid links */
                 } elseif ($item["Slot"] >= 100 and $item["Slot"] < 104) {
                     //Armor
                     $this->setItem($this->getSize() + $item["Slot"] - 100, NBT::getItemHelper($item), false);
                 } else {
                     $this->setItem($item["Slot"] - $this->getHotbarSize(), NBT::getItemHelper($item), false);
                 }
             }
         } else {
             throw new \InvalidArgumentException("Expecting ListTag, received " . gettype($contents));
         }
     }
 }
 public function __construct(Human $player)
 {
     $this->hotbar = array_fill(0, $this->getHotbarSize(), -1);
     parent::__construct($player, InventoryType::get(InventoryType::PLAYER));
 }
 public function __construct(Chest $left, Chest $right)
 {
     $this->left = $left->getRealInventory();
     $this->right = $right->getRealInventory();
     BaseInventory::__construct($this, InventoryType::get(InventoryType::DOUBLE_CHEST));
 }