Can anyone tutorial me how did i can create a Entity like a player or an mob , i dont understand the nbt thing what it is and why "nbt", please a code and comment them xD that would be nice ^^
Just look at the Entity.php in the pocketmine source code, or even the slapper plugin. Anyways, this is how to spawn an entity: PHP: public static function createEntity($type, Position $source, ...$args){ $chunk = $source->getLevel()->getChunk($source->x >> 4, $source->z >> 4, true); if($chunk == null) return null; if(!$chunk->isLoaded()) $chunk->load(); if(!$chunk->isGenerated()) $chunk->setGenerated(); if(!$chunk->isPopulated()) $chunk->setPopulated(); $nbt = new Compound("", [ "Pos" => new Enum("Pos", [ new Double("", $source->x), new Double("", $source->y), new Double("", $source->z) ]), "Motion" => new Enum("Motion", [ new Double("", 0), new Double("", 0), new Double("", 0) ]), "Rotation" => new Enum("Rotation", [ new Float("", $source instanceof Location ? $source->yaw : 0), new Float("", $source instanceof Location ? $source->pitch : 0) ]), ]); $keys = array_keys(self::$knownEntities); foreach($keys as $c => $name){ if(strtolower($type) == strtolower($name)){ $type = $name; break; } } if(isset(self::$knownEntities[$type])){ $class = self::$knownEntities[$type]; /** @var BaseEntity $entity */ $entity = new $class($chunk, $nbt, ...$args); if($entity != null && $entity->isCreated()) $entity->spawnToAll(); return $entity; }else{ $entity = Entity::createEntity($type, $chunk, $nbt, ...$args); if($entity != null) $entity->spawnToAll(); return $entity; } }