NPC didnt save after server restart PHP: public function NPC(Player $player){ $nbt = new CompoundTag; $nbt->Pos = new ListTag("Pos", [ new DoubleTag("", $player->getX()), new DoubleTag("", $player->getY()), new DoubleTag("", $player->getZ()) ]); $nbt->Motion = new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]); $nbt->Rotation = new ListTag("Rotation", [ new FloatTag("", $player->getYaw()), new FloatTag("", $player->getPitch()) ]); $nbt->Health = new ShortTag("Health", 20); $nbt->Skin = new CompoundTag("Skin", [ "Data" => new StringTag("Data", $player->getSkin()->getSkinData()), "Name" => new StringTag("Name", $player->getSkin()->getSkinId())]); $npc = new Human($player->getLevel(), $nbt); $npc->setNameTag(C::YELLOW . "Test"); $npc->setNameTagVisible(false); $npc->spawnToAll(); }
i think you need to add the entity to the level https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/level/Level.php#L2576
Well, replace "Test" with $entity and $sender with $player (for your code snippet up there at least) and it should work
nope, just into the code you posted above. like this: PHP: public function NPC(Player $player){ $nbt = new CompoundTag; $nbt->Pos = new ListTag("Pos", [ new DoubleTag("", $player->getX()), new DoubleTag("", $player->getY()), new DoubleTag("", $player->getZ()) ]); $nbt->Motion = new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]); $nbt->Rotation = new ListTag("Rotation", [ new FloatTag("", $player->getYaw()), new FloatTag("", $player->getPitch()) ]); $nbt->Health = new ShortTag("Health", 20); $nbt->Skin = new CompoundTag("Skin", [ "Data" => new StringTag("Data", $player->getSkin()->getSkinData()), "Name" => new StringTag("Name", $player->getSkin()->getSkinId())]); $npc = new Human($player->getLevel(), $nbt); $npc->setNameTag(C::YELLOW . "Test"); $npc->setNameTagVisible(false); $player->getLevel()->addEntity($npc); $npc->spawnToAll(); }