Hi, guys! I have a problem with the mobs spawning. My code you can see Spoiler: here PHP: public function createVillager($x, $y, $z, Level $level){ $x += 0.5; $z += 0.5; $nbt = new CompoundTag; $nbt->Pos = new ListTag("Pos", [ new DoubleTag("", $x), new DoubleTag("", $y), new DoubleTag("", $z) ]); $nbt->Rotation = new ListTag("Rotation", [ new FloatTag("", 0), new FloatTag("", 0) ]); $nbt->Health = new ShortTag("Health", 20); $nbt->CustomName = new StringTag("CustomName", "§3Эдвард §7- §eКвестер"); $nbt->CustomNameVisible = new ByteTag("CustomNameVisible", 1); $level->loadChunk($x >> 4, $z >> 4); $villager = Entity::createEntity("Villager", $level->getChunk($x >> 4, $y >> 4), $nbt); $villager->spawnToAll(); } So, there is a Spoiler: CRITICAL PHP: [23:05:39] [Server thread/CRITICAL]: ▒еоб▒або▒анное и▒кл▒▒ение п▒и в▒полнении команд▒ 'vc' в vc: Argument 2 passed to pocketmine\entity\Entity::createEntity() must implement interface pocketmine\level\format\FullChunk, null given, called in /root/test/plugins/aQuest/src/AlexBrin/aQuest.php on line 153[23:05:39] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to pocketmine\entity\Entity::createEntity() must implement interface pocketmine\level\format\FullChunk, null given, called in /root/test/plugins/Mob/src/FIRERO/main_file.php on line 153" (EXCEPTION) in "/src/pocketmine/entity/Entity" at line 554 in the console Spoiler: line 153 PHP: $villager = Entity::createEntity("Villager", $level->getChunk($x >> 4, $y >> 4), $nbt); Spoiler: line 554 PHP: public static function createEntity($type, FullChunk $chunk, CompoundTag $nbt, ...$args){
Spoiler: Here PHP: <?php namespace FIRERO; use pocketmine\plugin\PluginBase; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\command\CommandExecutor; use pocketmine\entity\Entity; use pocketmine\level\Level; use pocketmine\level\Position; use pocketmine\math\Vector3; use pocketmine\nbt\NBT; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\DoubleTag; use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\StringTag; use pocketmine\entity\Villager; use pocketmine\event\Listener; use pocketmine\Player; use pocketmine\Server; class main_file extends PluginBase implements Listener { public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if($sender instanceof Player) { if($command == "vc"){ $this->createVillager($sender->getX(), $sender->getY(), $sender->getZ(), $this->getServer()->getLevelByName("lobby")); } } else $sender->sendMessage('§cOnly for players!'); } public function createVillager($x, $y, $z, Level $level){ $x += 0.5; $z += 0.5; $nbt = new CompoundTag; $nbt->Pos = new ListTag("Pos", [ new DoubleTag("", $x), new DoubleTag("", $y), new DoubleTag("", $z) ]); $nbt->Rotation = new ListTag("Rotation", [ new FloatTag("", 0), new FloatTag("", 0) ]); $nbt->Health = new ShortTag("Health", 20); $nbt->CustomName = new StringTag("CustomName", "§3Эдвард §7- §eКвестер"); $nbt->CustomNameVisible = new ByteTag("CustomNameVisible", 1); $level->loadChunk($x >> 4, $z >> 4); $villager = Entity::createEntity("Villager", $level->getChunk($x >> 4, $y >> 4), $nbt); $villager->spawnToAll(); } }?>
Why ist there a $y?? PHP: $villager = Entity::createEntity("Villager", $level->getChunk($x >> 4, $y >> 4), $nbt);