PocketMine-MP 5.15.1 git-5ef247620a7c6301a849b54e5ef1009217729fc8
pocketmine\entity\EntityFactory Class Reference
+ Collaboration diagram for pocketmine\entity\EntityFactory:

Public Member Functions

 createFromData (World $world, CompoundTag $nbt)
 
 getSaveId (string $class)
 
 injectSaveId (string $class, CompoundTag $saveData)
 
 register (string $className, \Closure $creationFunc, array $saveNames)
 

Public Attributes

const TAG_IDENTIFIER = "identifier"
 
const TAG_LEGACY_ID = "id"
 

Detailed Description

This class manages the creation of entities loaded from disk. You need to register your entity into this factory if you want to load/save your entity on disk (saving with chunks).

Definition at line 66 of file EntityFactory.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\entity\EntityFactory::__construct ( )

Definition at line 83 of file EntityFactory.php.

Member Function Documentation

◆ createFromData()

pocketmine\entity\EntityFactory::createFromData ( World  $world,
CompoundTag  $nbt 
)

Creates an entity from data stored on a chunk.

Exceptions
SavedDataLoadingException

Definition at line 218 of file EntityFactory.php.

◆ getSaveId()

pocketmine\entity\EntityFactory::getSaveId ( string  $class)

@phpstan-param class-string<Entity> $class

Definition at line 251 of file EntityFactory.php.

◆ injectSaveId()

pocketmine\entity\EntityFactory::injectSaveId ( string  $class,
CompoundTag  $saveData 
)

Definition at line 240 of file EntityFactory.php.

◆ register()

pocketmine\entity\EntityFactory::register ( string  $className,
\Closure  $creationFunc,
array  $saveNames 
)

Registers an entity type into the index.

Parameters
string$classNameClass that extends Entity
string[]$saveNamesAn array of save names which this entity might be saved under. @phpstan-param class-string<Entity> $className @phpstan-param list<string> $saveNames @phpstan-param \Closure(World $world, CompoundTag $nbt) : Entity $creationFunc

NOTE: The first save name in the $saveNames array will be used when saving the entity to disk.

Exceptions

InvalidArgumentException

Definition at line 194 of file EntityFactory.php.

References pocketmine\utils\Utils\testValidInstance(), and pocketmine\utils\Utils\validateCallableSignature().

+ Here is the call graph for this function:

Member Data Documentation

◆ TAG_IDENTIFIER

const pocketmine\entity\EntityFactory::TAG_IDENTIFIER = "identifier"

Definition at line 69 of file EntityFactory.php.

◆ TAG_LEGACY_ID

const pocketmine\entity\EntityFactory::TAG_LEGACY_ID = "id"

Definition at line 70 of file EntityFactory.php.


The documentation for this class was generated from the following file: