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 )
Пример #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();
 }
Пример #2
0
 protected function initEntity()
 {
     $this->inventory = new PlayerInventory($this);
     if ($this instanceof Player) {
         $this->addWindow($this->inventory, 0);
     }
     if (isset($this->namedtag->NameTag)) {
         $this->nameTag = $this->namedtag["NameTag"];
     }
     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, Item::get($item["id"], $item["Damage"], $item["Count"]), $this);
         } else {
             $this->inventory->setItem($item["Slot"] - 9, Item::get($item["id"], $item["Damage"], $item["Count"]), $this);
         }
     }
     parent::initEntity();
 }
Пример #3
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 (isset($this->namedtag->NameTag)) {
         $this->setNameTag($this->namedtag["NameTag"]);
     }
     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, ItemItem::get($item["id"], $item["Damage"], $item["Count"]));
         } else {
             $this->inventory->setItem($item["Slot"] - 9, ItemItem::get($item["id"], $item["Damage"], $item["Count"]));
         }
     }
     parent::initEntity();
 }
Пример #4
0
 protected function initEntity()
 {
     $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, false, self::DATA_TYPE_BYTE);
     $this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0], false);
     $inventoryContents = $this->namedtag->Inventory ?? null;
     $this->inventory = new PlayerInventory($this, $inventoryContents);
     //Virtual inventory for desktop GUI crafting and anti-cheat transaction processing
     $this->floatingInventory = new FloatingInventory($this);
     if ($this instanceof Player) {
         $this->addWindow($this->inventory, 0);
     } else {
         if (isset($this->namedtag->NameTag)) {
             $this->setNameTag($this->namedtag["NameTag"]);
         }
         if (isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof CompoundTag) {
             $this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Name"]);
         }
         $this->uuid = UUID::fromData($this->getId(), $this->getSkinData(), $this->getNameTag());
     }
     if (isset($this->namedtag->Inventory) and $this->namedtag->Inventory instanceof ListTag) {
         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, ItemItem::nbtDeserialize($item));
             } else {
                 $this->inventory->setItem($item["Slot"] - 9, ItemItem::nbtDeserialize($item));
             }
         }
     }
     parent::initEntity();
     if (!isset($this->namedtag->foodLevel) or !$this->namedtag->foodLevel instanceof IntTag) {
         $this->namedtag->foodLevel = new IntTag("foodLevel", $this->getFood());
     } else {
         $this->setFood($this->namedtag["foodLevel"]);
     }
     if (!isset($this->namedtag->foodExhaustionLevel) or !$this->namedtag->foodExhaustionLevel instanceof IntTag) {
         $this->namedtag->foodExhaustionLevel = new FloatTag("foodExhaustionLevel", $this->getExhaustion());
     } else {
         $this->setExhaustion($this->namedtag["foodExhaustionLevel"]);
     }
     if (!isset($this->namedtag->foodSaturationLevel) or !$this->namedtag->foodSaturationLevel instanceof IntTag) {
         $this->namedtag->foodSaturationLevel = new FloatTag("foodSaturationLevel", $this->getSaturation());
     } else {
         $this->setSaturation($this->namedtag["foodSaturationLevel"]);
     }
     if (!isset($this->namedtag->foodTickTimer) or !$this->namedtag->foodTickTimer instanceof IntTag) {
         $this->namedtag->foodTickTimer = new IntTag("foodTickTimer", $this->foodTickTimer);
     } else {
         $this->foodTickTimer = $this->namedtag["foodTickTimer"];
     }
     if (!isset($this->namedtag->XpLevel) or !$this->namedtag->XpLevel instanceof IntTag) {
         $this->namedtag->XpLevel = new IntTag("XpLevel", $this->getXpLevel());
     } else {
         $this->setXpLevel($this->namedtag["XpLevel"]);
     }
     if (!isset($this->namedtag->XpP) or !$this->namedtag->XpP instanceof FloatTag) {
         $this->namedtag->XpP = new FloatTag("XpP", $this->getXpProgress());
     }
     if (!isset($this->namedtag->XpTotal) or !$this->namedtag->XpTotal instanceof IntTag) {
         $this->namedtag->XpTotal = new IntTag("XpTotal", $this->totalXp);
     } else {
         $this->totalXp = $this->namedtag["XpTotal"];
     }
     if (!isset($this->namedtag->XpSeed) or !$this->namedtag->XpSeed instanceof IntTag) {
         $this->namedtag->XpSeed = new IntTag("XpSeed", $this->xpSeed ?? ($this->xpSeed = mt_rand(PHP_INT_MIN, PHP_INT_MAX)));
     } else {
         $this->xpSeed = $this->namedtag["XpSeed"];
     }
 }