當前位置: 首頁>>代碼示例>>PHP>>正文


PHP inventory\Inventory類代碼示例

本文整理匯總了PHP中pocketmine\inventory\Inventory的典型用法代碼示例。如果您正苦於以下問題:PHP Inventory類的具體用法?PHP Inventory怎麽用?PHP Inventory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Inventory類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addToInventory

 /**
  * @param Inventory $inventory
  */
 public function addToInventory(Inventory $inventory)
 {
     foreach ($this->getItems() as $i) {
         $inventory->setItem($inventory->firstEmpty(), clone $i);
     }
     // call_user_func_array($inventory->addItem(), $this->getItems());
 }
開發者ID:PrimusLV,項目名稱:EssentialsPE,代碼行數:10,代碼來源:BaseKit.php

示例2: addInventoryRandomItems

 public function addInventoryRandomItems($level, Inventory $inv)
 {
     if ($inv != null) {
         $inv->setItem(0, self::randomItems());
         $inv->setItem(1, self::randomItems());
         $inv->setItem(2, self::randomItems());
         $inv->setItem(3, self::randomItems());
     }
 }
開發者ID:Ragnok123,項目名稱:CSCase,代碼行數:9,代碼來源:ChestInventory.php

示例3: sendSlotUpdate

 /**
  * @param Player $source
  *
  * Sends a slot update to inventory viewers
  * For successful transactions, update non-source viewers (source does not need updating)
  * For failed transactions, update the source (non-source viewers will see nothing anyway)
  */
 public function sendSlotUpdate(Player $source)
 {
     if ($this->getInventory() instanceof TemporaryInventory) {
         return;
     }
     $targets = [];
     if ($this->wasSuccessful) {
         $targets = $this->getInventory()->getViewers();
         unset($targets[spl_object_hash($source)]);
     } else {
         $targets = [$source];
     }
     $this->inventory->sendSlot($this->slot, $targets);
 }
開發者ID:ClearSkyTeam,項目名稱:ClearSky,代碼行數:21,代碼來源:BaseTransaction.php

示例4: loadInventory

 public function loadInventory(Player $player, Inventory $inv)
 {
     $n = trim(strtolower($player->getName()));
     if ($n === "") {
         return false;
     }
     if ($this->isGlobal) {
         $ln = "*";
     } else {
         $ln = trim(strtolower($player->getLevel()->getName()));
     }
     $inv->clearAll();
     $sql = "SELECT slot,id,damage,count FROM NetherChests WHERE player = " . $this->prepare($n) . " AND world = " . $this->prepare($ln);
     $res = $this->database->query($sql);
     if ($res === false) {
         return false;
     }
     while (($row = $res->fetch_assoc()) != null) {
         $inv->setItem($row["slot"], Item::get($row["id"], $row["damage"], $row["count"]));
     }
     $res->free();
     return true;
 }
開發者ID:DWWf,項目名稱:pocketmine-plugins,代碼行數:23,代碼來源:MySqlMgr.php

示例5: removeWindow

 public function removeWindow(Inventory $inventory)
 {
     $inventory->close($this);
     if ($this->windows->contains($inventory)) {
         $id = $this->windows[$inventory];
         $this->windows->detach($this->windowIndex[$id]);
         unset($this->windowIndex[$id]);
     }
 }
開發者ID:NewDelion,項目名稱:PocketMine-0.13.x,代碼行數:9,代碼來源:Player.php

示例6: isNeChest

 public function isNeChest(Inventory $inv)
 {
     if ($inv instanceof DoubleChestInventory) {
         return false;
     }
     if (!$inv instanceof ChestInventory) {
         return false;
     }
     $tile = $inv->getHolder();
     if (!$tile instanceof Chest) {
         return false;
     }
     $bl = $tile->getBlock();
     if ($bl->getId() != Block::CHEST) {
         return false;
     }
     if ($bl->getSide(Vector3::SIDE_DOWN)->getId() != $this->base_block) {
         return false;
     }
     return true;
 }
開發者ID:Gabriel865,項目名稱:pocketmine-plugins,代碼行數:21,代碼來源:Main.php

示例7: deleteChest

 public function deleteChest(Inventory $inv)
 {
     $bl = $inv->getHolder()->getBlock();
     $x = $bl->getFloorX();
     $y = $bl->getFloorY();
     $z = $bl->getFloorZ();
     unset($this->chests[$x . ":" . $y . ":" . $z]);
     //	$this->getLogger()->info('Chest deleted');
 }
開發者ID:xHFx,項目名稱:TreasureHunt-,代碼行數:9,代碼來源:Main.php

示例8: getViewers

 /**
  * @return \pocketmine\entity\Human[]
  */
 public function getViewers()
 {
     return $this->inventory->getViewers();
 }
開發者ID:ClearSkyTeam,項目名稱:ClearSky,代碼行數:7,代碼來源:InventoryEvent.php

示例9: loadInventory

 public function loadInventory(Player $player, Inventory $inv)
 {
     $n = trim(strtolower($player->getName()));
     if ($n === "") {
         return false;
     }
     $d = substr($n, 0, 1);
     $path = $this->getDataFolder() . $d . "/" . $n . ".yml";
     if (!is_file($path)) {
         return false;
     }
     $cfg = new Config($path, Config::YAML);
     $yaml = $cfg->getAll();
     if ($this->isGlobal) {
         $ln = "*";
     } else {
         $ln = trim(strtolower($player->getLevel()->getName()));
     }
     if (!isset($yaml[$ln])) {
         return false;
     }
     $inv->clearAll();
     foreach ($yaml[$ln] as $slot => $t) {
         list($id, $dam, $cnt) = explode(":", $t);
         $item = Item::get($id, $dam, $cnt);
         $inv->setItem($slot, $item);
     }
     return true;
 }
開發者ID:DWWf,項目名稱:pocketmine-plugins,代碼行數:29,代碼來源:YamlMgr.php


注:本文中的pocketmine\inventory\Inventory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。