//This is my ANPC class <?php namespace SuperCopy\entity\monster\walking\WearableMonster; use SuperCopy\entity\monster\WearableMonster; use pocketmine\Player; use pocketmine\item\Item; use pocketmine\level\Level; use pocketmine\utils\UUID; use pocketmine\entity\Entity; use pocketmine\network\mcpe\protocol\AddPlayerPacket; use pocketmine\network\mcpe\protocol\RemoveEntityPacket; use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket; use pocketmine\network\mcpe\protocol\PlayerListPacket; use pocketmine\network\mcpe\protocol\types\PlayerListEntry; use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; use pocketmine\Server; use pocketmine\level\Location; use pocketmine\network\mcpe\protocol\MovePlayerPacket; use pocketmine\network\mcpe\protocol\types\SkinAdapterSingleton; class ANPC extends WearableMonster{ const NETWORK_ID = 63; public $width = 0.6; public $height = 1.8; //public $eyeHeight = 1.62; public $Location; public static $metadata=array(); public function getName() : string{ return "ANPC"; } public function getDrops() : array{ if($this->rpg === []){ switch(mt_rand(1, 3)){ case 1: case 2: return [Item::get(367, 0, mt_rand(1, 3))]; default: return []; } }else{ return []; } } public function getUniqueId() : ?UUID{ return UUID::fromData($this->getId(), $this->namedtag["Skin"]["Data"], $this->rpg["名字"]); } public function spawnTo(Player $player): void { // if(isset($this->hasSpawned[$player->getLoaderId()]) or !isset($player->usedChunks[Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())])) return; //$this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getName(), $this->namedtag["Skin"]["Name"], $this->namedtag["Skin"]["Data"]); $this->Location = new Location((float) $this->x, (float) $this->y+1.67, (float) $this->z, 0.0, 0.0, Server::getInstance()->getLevelByName($this->level->getName())); /* if($level===false) { $level=$player->getLevel(); } if($this->getLevel()!=='' && strtolower($level->getFolderName())!==strtolower($this->level)) { $this->despawnFrom($player); //return false; } */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //var_dump( $this->namedtag["Skin"]["Data"]); $skin = SkinAdapterSingleton::get()->toSkinData($player->getSkin()); $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; $pk->entries = [PlayerListEntry::createAdditionEntry($this->getUniqueId(),$this->getId(), $this->getName(), $skin)]; $player->dataPacket($pk); $pk = new AddPlayerPacket(); $pk->uuid = $this->getUniqueId(); $pk->username = $this->getName(); $pk->entityRuntimeId = $this->getId(); $pk->position = $this->Location->asVector3(); $pk->motion = $this->Location->asVector3(); $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->item = ItemStackWrapper::legacy($this->Held); $pk->metadata = $this->getDataPropertyManager()->getAll(); $player->dataPacket($pk); $this->sendData($player, [self:ATA_NAMETAG => [self:ATA_TYPE_STRING, $this->getName()]]);//Hack for MCPE 1.2.13: DATA_NAMETAG is useless in AddPlayerPacket, so it has to be sent separately $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_REMOVE; $pk->entries = [PlayerListEntry::createRemovalEntry( $this->getUniqueId())]; $player->dataPacket($pk); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* $pk = new AddPlayerPacket(); $pk->uuid = $this->getUniqueId(); $pk->username = $this->getName(); $pk->entityUniqueId = $this->getId(); $pk->entityRuntimeId = $this->getId(); // $pk->eid = $this->getId(); $pk->motion= $this->Location->asVector3(); // var_dump( $pk->motion); $pk->position = $this->Location->asVector3(); //$pk->x = $this->x; //$pk->y = $this->y; //$pk->z = $this->z; //$pk->speedX = 0; //$pk->speedY = 0; //$pk->speedZ = 0; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->item= ItemStackWrapper::legacy($this->Held); $pk->headYaw=$this->yaw; // var_dump($this->Location->yaw); //$pk->item = $this->Held; $pk->metadata = self::$metadata; $player->dataPacket($pk); //$this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getName(), $player->getSkin(),$xboxUserId = "",array($player)); Server::getInstance()->updatePlayerListData($this->getUniqueId(),$this->getId(),$this->getName(),$player->getSkin(),$xboxUserId = "",array($player)); // */ $Armor = new MobArmorEquipmentPacket(); $Armor->entityRuntimeId = $this->getId(); $Armor->head = ItemStackWrapper::legacy($this->Cap); $Armor->chest = ItemStackWrapper::legacy($this->Tunic); $Armor->legs = ItemStackWrapper::legacy($this->Pants); $Armor->feet = ItemStackWrapper::legacy($this->Boots); /* $Armor->slots = [ 0 => $this->Cap, 1 => $this->Tunic, 2 => $this->Pants, 3 => $this->Boots ]; */ $player->dataPacket($Armor); // Server::getInstance()->removePlayerListData($this->getUniqueId(),array($player)); $this->hasSpawned[$player->getLoaderId()] = $player; } }
And if I created other entity like zombie ,The body is normal body in game not half .But use AddPlayerPacket() create is half.