pocketmine\inventory\PlayerInventory::setHotbarSlotIndex PHP Метод

setHotbarSlotIndex() публичный Метод

Устаревший: Changes the linkage of the specified hotbar slot. This should never be done unless it is requested by the client.
public setHotbarSlotIndex ( $index, $slot )
    public function setHotbarSlotIndex($index, $slot)
    {
        if ($this->getHolder()->getServer()->getProperty("settings.deprecated-verbose") !== false) {
            trigger_error("Do not attempt to change hotbar links in plugins!", E_USER_DEPRECATED);
        }
    }

Usage Example

Пример #1
0
 protected function initEntity()
 {
     $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false);
     $this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0]);
     $this->inventory = new PlayerInventory($this);
     if ($this instanceof Player) {
         $this->addWindow($this->inventory, 0);
     }
     if (!$this instanceof Player) {
         if (isset($this->namedtag->NameTag)) {
             $this->setNameTag($this->namedtag["NameTag"]);
         }
         if (isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof Compound) {
             $this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Slim"] > 0, $this->namedtag->Skin["Transparent"] > 0);
         }
         $this->uuid = UUID::fromData($this->getId(), $this->getSkinData(), $this->getNameTag());
     }
     if (isset($this->namedtag->Inventory) and $this->namedtag->Inventory instanceof Enum) {
         foreach ($this->namedtag->Inventory as $item) {
             if ($item["Slot"] >= 0 and $item["Slot"] < 9) {
                 //Hotbar
                 $this->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1);
             } elseif ($item["Slot"] >= 100 and $item["Slot"] < 104) {
                 //Armor
                 $this->inventory->setItem($this->inventory->getSize() + $item["Slot"] - 100, NBT::getItemHelper($item));
             } else {
                 $this->inventory->setItem($item["Slot"] - 9, NBT::getItemHelper($item));
             }
         }
     }
     parent::initEntity();
 }
All Usage Examples Of pocketmine\inventory\PlayerInventory::setHotbarSlotIndex