Since the API4 changes, I'm aware that some things must be changed in plugins that create entities. However with this piece of code I'm not really sure what will make it work. PHP: public function spawn(Player $player, $name) { $entity = Entity::createEntity($name, $player->getLevel()->getChunk($player->x >> 4, $player->z >> 4), $this->createNbt($player->x, $player->y, $player->z, $player->yaw, $player->pitch)); $entity->spawnToAll(); $this->eid[$player->getName()] = $entity->getId(); $entity->setNameTag($player->getName()); $entity->setNameTagAlwaysVisible(true); $entity->setNameTagVisible(true); foreach ($this->getServer()->getOnlinePlayers() as $pl) { $pl->hidePlayer($player); } $player->addEffect(Effect::getEffect(14)->setDuration(9999999999)->setVisible(false)); } iv tried changing it to. Code: public function spawn(Player $player, $name) { $entity = Entity::createEntity($name, $player->getLevel(), $this->createNbt($player->x, $player->y, $player->z, $player->yaw, $player->pitch)); $entity->spawnToAll(); $this->eid[$player->getName()] = $entity->getId(); $entity->setNameTag($player->getName()); $entity->setNameTagAlwaysVisible(true); $entity->setNameTagVisible(true); foreach ($this->getServer()->getOnlinePlayers() as $pl) { $pl->hidePlayer($player); } $player->addEffect(Effect::getEffect(14)->setDuration(9999999999)->setVisible(false)); } but then it says something about spawnToAll Please help
Code: 2017-03-15 [17:58:24] [Server thread/CRITICAL]: Unhandled exception executing command 'morph cat' in morph: Call to a member function spawnToAll() on null 2017-03-15 [17:58:24] [Server thread/CRITICAL]: Error: "Call to a member function spawnToAll() on null" (EXCEPTION) in "/plugins/morph_v0.1beta/src/morph/main" at line 99
It appears that Entity::CreateEntity() is returning a null. You didn't do something right. Probably because of PHP: $this->createNbt($player->x, $player->y, $player->z, $player->yaw, $player->pitch)
nope, this is the exact same problem as in Chunks https://forums.pmmp.io/threads/chunks.1382/#post-15836