I spawned Entity Human with nametag and after server restart nameteag is not visible full code here: PHP: <?phpnamespace WallCore;use pocketmine\entity\Human;use pocketmine\event\Listener;use pocketmine\event\player\PlayerCommandPreprocessEvent;use pocketmine\nbt\tag\CompoundTag;use pocketmine\nbt\tag\DoubleTag;use pocketmine\nbt\tag\FloatTag;use pocketmine\nbt\tag\ListTag;use pocketmine\nbt\tag\StringTag;class NPCManager implements Listener{ public function onCommand(PlayerCommandPreprocessEvent $event) { { $cmd = explode(" ", strtolower($event->getMessage())); $player = $event->getPlayer(); if ($cmd[0] === "/npc") { $block = $player; $npc = new Human($player->chunk, new CompoundTag("", [ "Pos" => new ListTag("Pos", [ new DoubleTag("", $block->getX()), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ()) ]), "Motion" => new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]), "Rotation" => new ListTag("Rotation", [ new FloatTag("", 0), new FloatTag("", 360) ]), "Skin" => new CompoundTag("Skin", [ "Data" => new StringTag("Data", $player->getSkinData()) ]) ] )); $npc->spawnToAll(); $npc->setNameTagVisible(true); $npc->setNameTagAlwaysVisible(true); $npc->setNameTag("§l§eSkyWars"); $npc->setMaxHealth(99999999); $npc->setHealth(99999999); } $event->setCancelled(true); } }
Try with $entity->setDataProperty instead, tho setNameTagVisible should be doing the trick. Possibly, the server might not have shut down correctly. You can execute /save-all before shutting the server down and after spawning the $npc. If that didn't help, you can execute this during EntitySpawnEvent... PHP: if ($entity->getNameTag() == "§l§eSkyWars") { $entity->setNameTagVisible(true); $entity->setNameTagAlwaysVisible(true);}