EntityFactory
in package
Uses
SingletonTrait
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).
Table of Contents
- $creationFuncs : array<string|int, Closure>
- $instance : self|null
- $saveNames : array<string|int, string>
- __construct() : mixed
- getInstance() : self
- getSaveId() : string
- injectSaveId() : void
- register() : void
- Registers an entity type into the index.
- reset() : void
- setInstance() : void
- make() : self
- validateCreationFunc() : void
Properties
$creationFuncs
private
array<string|int, Closure>
$creationFuncs
= []
save ID => creator function
Tags
$instance
private
static self|null
$instance
= null
$saveNames
private
array<string|int, string>
$saveNames
= []
Tags
Methods
__construct()
public
__construct() : mixed
Return values
mixed —getInstance()
public
static getInstance() : self
Return values
self —getSaveId()
public
getSaveId(string $class) : string
Parameters
- $class : string
Tags
Return values
string —injectSaveId()
public
injectSaveId(string $class, CompoundTag $saveData) : void
Parameters
- $class : string
- $saveData : CompoundTag
Return values
void —register()
Registers an entity type into the index.
public
register(string $className, Closure $creationFunc, array<string|int, string> $saveNames[, int|null $legacyMcpeSaveId = null ]) : void
Parameters
- $className : string
-
Class that extends Entity
- $creationFunc : Closure
- $saveNames : array<string|int, string>
-
An array of save names which this entity might be saved under.
- $legacyMcpeSaveId : int|null = null
Tags
Return values
void —reset()
public
static reset() : void
Return values
void —setInstance()
public
static setInstance(self $instance) : void
Parameters
- $instance : self
Return values
void —make()
private
static make() : self
Return values
self —validateCreationFunc()
private
static validateCreationFunc(Closure $creationFunc) : void
Parameters
- $creationFunc : Closure