Where is the mistake? ArgumentCountError: "Too few arguments to function NiLen\NPC\NPC::npc6(), 1 passed in /srv/data/plugins/NPC_plugin/src/NiLen/NPC/NPC.php on line 76 and exactly 2 expected public function npc6($type, Player $player){ $nbt = new CompoundTag("", [ "Pos" => new ListTag("Pos", [ new DoubleTag ("", $player->x), new DoubleTag ("", $player->y + $player->getEyeHeight()), new DoubleTag ("", $player->z) ]), "Motion" => new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]), "Rotation" => new ListTag("Rotation", [ new FloatTag ("", $player->yaw), new FloatTag ("", $player->pitch) ]), ]); $snowball = Entity::createEntity("Cow", $player->getLevel(), $type, $nbt); $snowball->spawnToAll(true); } Spawn code: $this->npc6($player);
PHP: public function npc6(Player $player){ $nbt = new CompoundTag("", [ "Pos" => new ListTag("Pos", [ new DoubleTag ("", $player->x), new DoubleTag ("", $player->y + $player->getEyeHeight()), new DoubleTag ("", $player->z) ]), "Motion" => new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]), "Rotation" => new ListTag("Rotation", [ new FloatTag ("", $player->yaw), new FloatTag ("", $player->pitch) ]), ]); $snowball = Entity::createEntity("Cow", $player->getLevel(), $type, $nbt); $snowball->spawnToAll(true); }
new mistake: Error: "Call to a member function spawnToAll() on null" (EXCEPTION) in "plugins/NPC_plugin/src/NiLen/NPC/NPC" at line 213 [13:28:47] [Server thread/CRITICAL]: #0 plugins/NPC_plugin/src/NiLen/NPC/NPC(76): NiLen\NPC\NPC->npc6(object pocketmine\Player)
I did it exactly the same but it does not work ReflectionException: "Class NiLen\NPC\Cow does not exist" (-1) in "pmsrc/src/pocketmine/entity/Entity" at line 399 The line with this error: Entity::registerEntity(Сow::class);