本文整理汇总了PHP中pocketmine\Player::getFloatingInventory方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getFloatingInventory方法的具体用法?PHP Player::getFloatingInventory怎么用?PHP Player::getFloatingInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Player
的用法示例。
在下文中一共展示了Player::getFloatingInventory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(Player $source) : bool
{
$droppedItem = $this->getTargetItem();
if (!$source->getServer()->getAllowInvCheats() and !$source->isCreative()) {
if (!$source->getFloatingInventory()->contains($droppedItem)) {
return false;
}
$source->getFloatingInventory()->removeItem($droppedItem);
}
$source->dropItem($droppedItem);
return true;
}
示例2: onRename
public function onRename(Player $player, Item $resultItem) : bool
{
if (!$resultItem->deepEquals($this->getItem(self::TARGET), true, false, true)) {
//Item does not match target item. Everything must match except the tags.
return false;
}
if ($player->getExpLevel() < $resultItem->getRepairCost()) {
//Not enough exp
return false;
}
$player->setExpLevel($player->getExpLevel() - $resultItem->getRepairCost());
$this->clearAll();
if (!$player->getServer()->allowInventoryCheats and !$player->isCreative()) {
if (!$player->getFloatingInventory()->canAddItem($resultItem)) {
return false;
}
$player->getFloatingInventory()->addItem($resultItem);
}
return true;
}
示例3: execute
/**
* @param Player $source
* @return bool
*
* Handles transaction execution. Returns whether transaction was successful or not.
*/
public function execute(Player $source) : bool
{
if ($this->getInventory()->processSlotChange($this)) {
//This means that the transaction should be handled the normal way
if (!$source->getServer()->getAllowInvCheats() and !$source->isCreative()) {
$change = $this->getChange();
if ($change === null) {
//No changes to make, ignore this transaction
return true;
}
/* Verify that we have the required items */
if ($change["out"] instanceof Item) {
if (!$this->getInventory()->slotContains($this->getSlot(), $change["out"])) {
return false;
}
}
if ($change["in"] instanceof Item) {
if (!$source->getFloatingInventory()->contains($change["in"])) {
return false;
}
}
/* All checks passed, make changes to floating inventory
* This will not be reached unless all requirements are met */
if ($change["out"] instanceof Item) {
$source->getFloatingInventory()->addItem($change["out"]);
}
if ($change["in"] instanceof Item) {
$source->getFloatingInventory()->removeItem($change["in"]);
}
}
$this->getInventory()->setItem($this->getSlot(), $this->getTargetItem(), false);
}
/* Process transaction achievements, like getting iron from a furnace */
foreach ($this->achievements as $achievement) {
$source->awardAchievement($achievement);
}
return true;
}