public function __construct(FullChunk $chunk, Compound $nbt)
{
if ($chunk === null or $chunk->getProvider() === null) {
throw new ChunkException("Invalid garbage Chunk given to Entity");
}
$this->timings = Timings::getEntityTimings($this);
if ($this->eyeHeight === null) {
$this->eyeHeight = $this->height / 2 + 0.1;
}
$this->id = Entity::$entityCount++;
$this->justCreated = true;
$this->namedtag = $nbt;
$this->chunk = $chunk;
$this->setLevel($chunk->getProvider()->getLevel());
$this->server = $chunk->getProvider()->getLevel()->getServer();
$this->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
$this->setPositionAndRotation(new Vector3($this->namedtag["Pos"][0], $this->namedtag["Pos"][1], $this->namedtag["Pos"][2]), $this->namedtag->Rotation[0], $this->namedtag->Rotation[1], true);
$this->setMotion(new Vector3($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2]));
if (!isset($this->namedtag->FallDistance)) {
$this->namedtag->FallDistance = new Float("FallDistance", 0);
}
$this->fallDistance = $this->namedtag["FallDistance"];
if (!isset($this->namedtag->Fire)) {
$this->namedtag->Fire = new Short("Fire", 0);
}
$this->fireTicks = $this->namedtag["Fire"];
if (!isset($this->namedtag->Air)) {
$this->namedtag->Air = new Short("Air", 300);
}
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"]);
if (!isset($this->namedtag->OnGround)) {
$this->namedtag->OnGround = new Byte("OnGround", 0);
}
$this->onGround = $this->namedtag["OnGround"] > 0 ? true : false;
if (!isset($this->namedtag->Invulnerable)) {
$this->namedtag->Invulnerable = new Byte("Invulnerable", 0);
}
$this->invulnerable = $this->namedtag["Invulnerable"] > 0 ? true : false;
$this->chunk->addEntity($this);
$this->level->addEntity($this);
$this->initEntity();
$this->lastUpdate = $this->server->getTick();
$this->server->getPluginManager()->callEvent(new EntitySpawnEvent($this));
$this->checkBlockCollisionTicks = (int) $this->server->getAdvancedProperty("main.check-block-collision", 1);
$this->scheduleUpdate();
}