What I am trying to do is — spawning a human NPC with an elytra wing and then extend the Elytra wing, using packets. Code: PHP: public function spawnTo(PlayerJoinEvent $e) {$player = $e->getPlayer();$uuid = $player->getUniqueId();$id = $player->getId();$packet = new \pocketmine\network\mcpe\protocol\AddPlayerPacket;$x = 100;$y = 75;$z = 100;$elytrapacket = new \pocketmine\network\mcpe\protocol\AnimatePacket;// Spawning Human$packet->uuid = $uuid;$packet->username = "";$packet->entityRuntimeId = $id;$packet->eid = $id;$packet->x = $x;$packet->y = $y;$packet->z = $z;$packet->speedX = $packet->speedY = $packet->speedZ = 0;$packet->yaw = 0;$packet->pitch = 0;$packet->chestPlate = Item::$list[444];// $packet->item = getItem(Item::DIAMOND_AXE);// $packet->metaData = $player->dataProperties; Doesn't work because dataProperties is protected.$player->dataPacket($packet);$player->getInventory()->sendArmorContents($player);// Setting Elytra to Drag.$elytrapacket->entityRuntimeId = $id;$elytrapacket->animation = 15; // Id for 'Drag'$player->dataPacket($elytrapacket);} Issues that I experience: - Can't spawn the Entity. - Can't set the Item in hand. - Can't set dataProperties as it is a protected class (perhaps extending the class Player using my class might help.) Query: - What is the function of setting dataProperties? I'm afraid that I'm a bit new to the pocketmine API so any help would be greatly appreciated from my side. Console logged Error: Spoiler [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'RumBenHub v1': Argument 1 passed to pocketmine\utils\BinaryStream:: putSlot() must be an instance of pocketmine\item\Item, null given, called in /MCPE/lobby/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php on line 80 on RoyalMCPE\RumBenHub\Events\RumBenHuman [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\utils\BinaryStream:: putSlot() must be an instance of pocketmine\item\Item, null given, called in /MCPE/lobby/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php on line 80" (EXCEPTION) in "src/pocketmine/utils/BinaryStream" at line 288
https://github.com/pmmp/PocketMine-...ine/network/mcpe/protocol/AddPlayerPacket.php there is no eid in AddPlayerPacket , remove it
$id should be an unused entity ID PHP: $id = Entity::$entityCount++; Item in hand PHP: $packet->item = Item::get(Item::DIAMOND_AXE); After sending the AddPlayerPacket to a player, you'll need to send MobArmorEquipmentPacket with the following values PHP: $pk = new MobArmorEquipmentPacket();$pk->entityRuntimeId = $id;$pk->slots = [ Item::get(Item::DIAMOND_HELMET), Item::get(Item::DIAMOND_CHESTPLATE), Item::get(Item::DIAMOND_LEGGINGS), Item::get(Item::DIAMOND_BOOTS)];
How do I send the MobArmorEquipmentPacket to the NPC? $packet->dataPacket($pk); ?? Quite sure that won't work.
Wouldn't sending a MobArmorEquipmentPacket to a player equip the player with armor instead of the NPC? Or am I just being dumb?