protected function initEntity() { parent::initEntity(); if (!isset($this->namedtag->Profession)) { $this->setProfession(self::PROFESSION_GENERIC); } }
protected function initEntity() { parent::initEntity(); $this->namedtag->id = new String("id", "Villager"); if (!isset($this->namedtag->Profession)) { $this->setProfession(self::PROFESSION_GENERIC); } }
public function initEntity() { parent::initEntity(); if (isset($this->namedtag->Movement)) { $this->setMovement($this->namedtag["Movement"]); } $this->dataProperties[self::DATA_NO_AI] = [self::DATA_TYPE_BYTE, 1]; }
protected function initEntity() { $this->setMaxHealth(20); parent::initEntity(); if (!isset($this->namedtag->Profession)) { $this->setProfession(mt_rand(0, 5)); } }
protected function initEntity() { $this->setMaxHealth(20); parent::initEntity(); if (!isset($this->namedtag->Profession) || $this->getVariant() > 4) { $this->setVariant(mt_rand(0, 4)); } $this->setDataProperty(16, self::DATA_TYPE_BYTE, $this->getVariant()); }
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(); }
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"]; } }
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(); }
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()); } 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", 0); } $this->setXpLevel($this->namedtag["XpLevel"]); if (!isset($this->namedtag->XpP) or !$this->namedtag->XpP instanceof FloatTag) { $this->namedtag->XpP = new FloatTag("XpP", 0); } $this->setXpProgress($this->namedtag["XpP"]); if (!isset($this->namedtag->XpTotal) or !$this->namedtag->XpTotal instanceof IntTag) { $this->namedtag->XpTotal = new IntTag("XpTotal", 0); } $this->totalXp = $this->namedtag["XpTotal"]; if (!isset($this->namedtag->XpSeed) or !$this->namedtag->XpSeed instanceof IntTag) { $this->namedtag->XpSeed = new IntTag("XpSeed", mt_rand(PHP_INT_MIN, PHP_INT_MAX)); } $this->xpSeed = $this->namedtag["XpSeed"]; }
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(); }
protected function initEntity() { parent::initEntity(); if ($this->addmob_pk == null) { $this->addmob_pk = new AddMobPacket(); } if ($this->setmotion_pk == null) { $this->setmotion_pk = new SetEntityMotionPacket(); } if ($this->entityevent_pk == null) { $this->entityevent_pk = new EntityEventPacket(); } if ($this->removeentity_pk == null) { $this->removeentity_pk = new RemoveEntityPacket(); } $this->namedtag->id = new String("id", "BOT"); }
public function initEntity() { parent::initEntity(); if ($this->getDataProperty(self::DATA_AGEABLE_FLAGS) === null) { $this->setDataProperty(self::DATA_AGEABLE_FLAGS, self::DATA_TYPE_BYTE, 0); } }
public function initEntity() { parent::initEntity(); $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_BABY, false); }