Extract mandatory parameters into constructor parameters

the goal is obviously to ditch NBT entirely here, but there's more work to be done before that becomes possible.
This commit is contained in:
Dylan K. Taylor
2020-06-19 02:49:24 +01:00
parent 3f135da704
commit 1205432c34
22 changed files with 192 additions and 180 deletions

View File

@@ -213,7 +213,7 @@ abstract class Entity{
/** @var int|null */
protected $targetId = null;
public function __construct(World $world, CompoundTag $nbt){
public function __construct(Location $location, CompoundTag $nbt){
$this->timings = Timings::getEntityTimings($this);
$this->temporalVector = new Vector3();
@@ -223,14 +223,9 @@ abstract class Entity{
}
$this->id = EntityFactory::nextRuntimeId();
$this->server = $world->getServer();
$this->server = $location->getWorldNonNull()->getServer();
/** @var float[] $pos */
$pos = $nbt->getListTag("Pos")->getAllValues();
/** @var float[] $rotation */
$rotation = $nbt->getListTag("Rotation")->getAllValues();
$this->location = new Location($pos[0], $pos[1], $pos[2], $rotation[0], $rotation[1], $world);
$this->location = $location->asLocation();
assert(
!is_nan($this->location->x) and !is_infinite($this->location->x) and
!is_nan($this->location->y) and !is_infinite($this->location->y) and