本文整理汇总了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());
}
示例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());
}
}
示例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);
}
示例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;
}
示例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]);
}
}
示例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;
}
示例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');
}
示例8: getViewers
/**
* @return \pocketmine\entity\Human[]
*/
public function getViewers()
{
return $this->inventory->getViewers();
}
示例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;
}