If you open Entity.php you can see the base NBT for creating the entity. In turn, I want to spawn the NPC. I found a ready-made code to spawn the NPC, but I don't know where to get these NBT tags such as "Skin". I would like to get the entire list of tags and find out how to set displayname npc thx) Spoiler: Entity.php PHP: /** * Helper function which creates minimal NBT needed to spawn an entity. */ public static function createBaseNBT(Vector3 $pos, ?Vector3 $motion = null, float $yaw = 0.0, float $pitch = 0.0) : CompoundTag{ return new CompoundTag("", [ new ListTag("Pos", [ new DoubleTag("", $pos->x), new DoubleTag("", $pos->y), new DoubleTag("", $pos->z) ]), new ListTag("Motion", [ new DoubleTag("", $motion !== null ? $motion->x : 0.0), new DoubleTag("", $motion !== null ? $motion->y : 0.0), new DoubleTag("", $motion !== null ? $motion->z : 0.0) ]), new ListTag("Rotation", [ new FloatTag("", $yaw), new FloatTag("", $pitch) ]) ]); } Spoiler: code PHP: public function spawnNPC(Player $player){ $nbt = new CompoundTag("", [ new ListTag("Pos", [ new DoubleTag("", $player->getX()), new DoubleTag("", $player->getY()), new DoubleTag("", $player->getZ()) ]), new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]), new ListTag("Rotation", [ new FloatTag("", $player->getYaw()), new FloatTag("", $player->getPitch()) ]), new CompoundTag("Skin", [ new StringTag("Data", $player->getSkin()->getSkinData()), new StringTag("Name", $player->getSkin()->getSkinId()), ]) ]); $npc = new Human($player->getLevel(), $nbt); foreach($this->getServer()->getOnlinePlayers() as $plr) { $npc->spawnTo($plr); } }
use this. PHP: <?php/** Created by PhpStorm** User: zOmArRD* Date: 11/8/2021** Copyright © 2021 - All Rights Reserved.*/namespace here;use pocketmine\entity\Human;use pocketmine\entity\Skin;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;use pocketmine\Player;class Example{ public function spawnHuman(Player $player): void { $position = $player->getPosition(); $plSkinData = $player->getSkin(); $nbt = new CompoundTag("", [ new ListTag("Pos", [ new DoubleTag("", $position->getX()), new DoubleTag("", $position->getY()), new DoubleTag("", $position->getZ()) ]), new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]), new ListTag("Rotation", [ new FloatTag("", $player->getYaw()), new FloatTag("", $player->getPitch()) ]), new CompoundTag("Skin", [ new StringTag("Data", $plSkinData->getSkinData()), new StringTag("Name", $plSkinData->getSkinId()), ]), ]); $human = new Human($player->getLevel(), $nbt); $human->setScale(1); $human->setSkin(new Skin($player->getName(), $plSkinData->getSkinData(), $plSkinData->getCapeData(), $plSkinData->getGeometryName(), $plSkinData->getGeometryData())); $human->setNametagVisible(true); $human->setNameTagAlwaysVisible(true); $human->setImmobile(true); $human->spawnToAll(); }}