Im trying to spawn a Zombie with a Plugin. Since Pocketmine aint got working AI yet im assuming the mob will forever stay at where it was spawned. But i cant find a method or getter to spawn a mob. Can anyone help? Im trying to... -Spawn a Zombie -Spawn it with custom health -Spawn it with a Custom name
PHP: public static function addZombie(Location $pos) { $nbt = new CompoundTag; $nbt->Pos = new ListTag("Pos", [ new DoubleTag("", $pos->x), new DoubleTag("", $pos->y), new DoubleTag("", $pos->z) ]); $nbt->Rotation = new ListTag("Rotation", [ new FloatTag("", $pos->yaw), new FloatTag("", $pos->pitch) ]); $nbt->Health = new ShortTag("Health", 20);//HEALTH $nbt->displayname = "Custom Name"; $chunk = $player->chunk; if (!$chunk instanceof Chunk) { return; } $entity = Entity::createEntity("Zombie", $chunk, $nbt); $entity->spawnToAll(); $entity->saveNBT(); $entity->setNamedTagVisible(true); $entity->setNamedTagAlwaysVisible(true); //$entity->setNamedTag($nbt->display name); } PHP: /** @var Player $player */self::addZombie($player->getLocation());
PHP: /** @var int $x *//** @var int $y *//** @var int $z *///Keep $yaw and $pitch 0.0 if you don't know what it is.$yaw = 0.0;$pitch = 0.0$level = Server::getInstance()->getLevelByName("world");//or another level.$loc = new Location($x, $y, $z, $yaw, $pitch, $level);self::addZombie($loc);