EntityFactory now exclusively handles loading data from disk

this commit removes the ability to replace centrally registered entity classes in favour of using constructors directly.
In future commits I may introduce a dedicated factory interface which allows an _actual_ factory pattern (e.g. factory->createArrow(world, pos, shooter, isCritical) with proper static analysability) but for now it's peripheral to my intended objective.
The purpose of this change is to facilitate untangling of NBT from entity constructors so that they can be properly created without using NBT at all, and instead use nice APIs.

Spawn eggs now support arbitrary entity creation functions like EntityFactory does, allowing much more flexibility in what can be passed to an entity's constructor (e.g. a Plugin reference can be injected by use()ing it in a closure or via traditional DI.
This commit is contained in:
Dylan K. Taylor
2020-06-19 00:40:44 +01:00
parent 72a7fc68c1
commit 6a26c0bebf
15 changed files with 68 additions and 154 deletions

View File

@ -55,8 +55,7 @@ trait FallableTrait{
$nbt->setInt("TileID", $this->getId());
$nbt->setByte("Data", $this->getMeta());
/** @var FallingBlock $fall */
$fall = EntityFactory::getInstance()->create(FallingBlock::class, $pos->getWorldNonNull(), $nbt);
$fall = new FallingBlock($pos->getWorldNonNull(), $nbt);
$fall->spawnToAll();
}
}