Well I am trying to spawn an NPC but I get this error: Code: 06.09 16:56:22 [Server] Server thread/CRITICAL Unhandled exception executing command 'npc' in npc: Argument 1 passed to pocketmine\nbt\tag\CompoundTag::setTag() must be an instance of pocketmine\nbt\tag\NamedTag, null given, called in /plugins/NPC/src/NPC/Main.php on line 233 06.09 16:56:22 [Server] Server thread/CRITICAL TypeError: "Argument 1 passed to pocketmine\nbt\tag\CompoundTag::setTag() must be an instance of pocketmine\nbt\tag\NamedTag, null given, called in /plugins/NPC/src/NPC/Main.php on line 233" (EXCEPTION) in "vendor/pocketmine/nbt/src/tag/CompoundTag" at line 122 Code: PHP: $nbt = Entity::createBaseNBT($player, null, 2, 2); $nbt->setTag($player->namedtag->getTag("Skin")); //line 233 $npc = new Human($player->getLevel(), $nbt); $npc->setNameTag("Test"); $npc->setNameTagAlwaysVisible(true); $npc->spawnToAll();
Before anybody ask I used the latest stable release "This server is running PocketMine-MP 3.2.0 for Minecraft: Bedrock Edition v1.6.0 (protocol version 282)"
Lol Try this Of course u have to edit it but try this! PHP: $name = implode(" ", $args); $nbt = Entity::createBaseNBT($sender, null, 2, 2); $nbt->setTag($sender->namedtag->getTag("Skin")); $npc = new NPC($sender->getLevel(), $nbt); $npc->setNameTag($name . " Health: " . round($npc->getHealth())); $npc->setNameTagAlwaysVisible(true); $npc->spawnToAll(); $sender->sendMessage("$name bot"); } return true; }
No it's doesn't change! + Null becos we want to spawn the npc next to the player/sender! And this command I used in my server it's worked with me
I am a biginnir but I don't understand what happening with u!! When I made this code in the first try ! It didn't work But now it's work and I give it for u but why it's didn't woork??????
PHP: $nbt = Entity::createBaseNBT(new Vector3($player->getX(), $player->getY(), $player->getZ()), null, $player->getYaw(), $player->getPitch()); $sheep = Entity::createEntity("EntityName", $player->getLevel()->getName(), $nbt); $sheep->setMaxHealth(20); $sheep->setHealth(20); $sheep->spawnToAll(); If you want to know more about NPCs see Slapper
That's mean when you try to spawn a normal entity it works? Ok I will now but talk here in English better xD
Well, never tested that but it should. As I said, getting the skin tag of the player returns null, this is my issue. This is what I found so far: https://github.com/jojoe77777/Slapper/blob/master/src/slapper/Main.php#L590-#L598 What is the difference between getTag() and getCompoundTag()?
Well I $player->saveNBT(); before I run the code and this part seems to be okay(?). I will let you know if I need further help.