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();
}