本文整理汇总了PHP中pocketmine\inventory\Inventory::setItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Inventory::setItem方法的具体用法?PHP Inventory::setItem怎么用?PHP Inventory::setItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\inventory\Inventory
的用法示例。
在下文中一共展示了Inventory::setItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
}
示例2: 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());
}
示例3: 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;
}
示例4: 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;
}