Error: "Call to undefined method pocketmine\item\ItemBlock::write()" (EXCEPTION) in "pmsrc/src/pocketmine/network/mcpe/protocol/AddPlayerPacket" at line 132 /** * @param VortexPlayer $player */ public function spawnTo(VortexPlayer $player): void { $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; $pk->entries = [PlayerListEntry::createAdditionEntry($this->uuid, $this->entityId, $this->getNameTag(), SkinAdapterSingleton::get()->toSkinData($this->skin))]; $player->dataPacket($pk); $xdiff = $player->x - $this->position->x; $zdiff = $player->z - $this->position->z; $angle = atan2($zdiff, $xdiff); $yaw = (($angle * 180) / M_PI) - 90; $ydiff = $player->y - $this->position->y; $v = new Vector2($this->position->x, $this->position->z); $dist = $v->distance($player->x, $player->z); $angle = atan2($dist, $ydiff); $pitch = (($angle * 180) / M_PI) - 90; $pk = new AddPlayerPacket(); $pk->uuid = $this->getUniqueId(); $pk->username = $this->nameTag; $pk->entityRuntimeId = $this->entityId; $pk->position = $this->position->asVector3(); $pk->yaw = $yaw; $pk->pitch = $pitch; $pk->item = Item::get(Item::AIR); $pk->metadata = [ Entity:ATA_FLAGS => [ Entity:ATA_TYPE_LONG, 1 << Entity:ATA_FLAG_ALWAYS_SHOW_NAMETAG ^ 1 << Entity:ATA_FLAG_CAN_SHOW_NAMETAG ], Entity:ATA_NAMETAG => [ Entity:ATA_TYPE_STRING, $this->nameTag ], Entity:ATA_LEAD_HOLDER_EID => [ Entity:ATA_TYPE_LONG, -1 ] ]; $player->dataPacket($pk); $this->setNameTag($player); $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_REMOVE; $pk->entries = [PlayerListEntry::createRemovalEntry($this->uuid)]; $player->dataPacket($pk); } and /** * @priority NORMAL * * @param PlayerJoinEvent $event */ public function onPlayerJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); if(!$player instanceof VortexPlayer) { return; } foreach($this->core->getEntityManager()->getNPCs() as $npc) { $npc->spawnTo($player); } }
PHP: $pk->item = \pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper::legacy(\pocketmine\item\ItemFactory::get(\pocketmine\item\ItemIds::AIR));