예제 #1
0
 public function initEntity()
 {
     parent::initEntity();
     if ($this->getDataProperty(self::DATA_AGEABLE_FLAGS) === null) {
         $this->setDataProperty(self::DATA_AGEABLE_FLAGS, self::DATA_TYPE_BYTE, 0);
     }
 }
예제 #2
0
 protected function initEntity()
 {
     $this->setMaxHealth(20);
     parent::initEntity();
     if (!isset($this->namedtag->Profession)) {
         $this->setProfession(mt_rand(0, 5));
     }
 }
예제 #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 (!$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["Name"] > 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();
 }