getEntityTimings() public static method

public static getEntityTimings ( Entity $entity ) : TimingsHandler
$entity pocketmine\entity\Entity
return TimingsHandler
Beispiel #1
0
 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();
 }
 private function entityConstruct(Player $player, FullChunk $chunk, CompoundTag $nbt)
 {
     assert($chunk !== null and $chunk->getProvider() !== null);
     $this->setPrivateVariableData($player, 'timings', Timings::getEntityTimings($player));
     $this->setPrivateVariableData($player, 'isPlayer', $player instanceof Player);
     $player->temporalVector = new Vector3();
     if ($player->eyeHeight === null) {
         $player->eyeHeight = $player->height / 2 + 0.1;
     }
     $this->setPrivateVariableData($player, 'id', Entity::$entityCount++);
     $this->setPrivateVariableData($player, 'justCreated', true);
     $player->namedtag = $nbt;
     $player->chunk = $chunk;
     $player->setLevel($chunk->getProvider()->getLevel());
     $this->setPrivateVariableData($player, 'server', $chunk->getProvider()->getLevel()->getServer());
     $player->boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
     $player->setPositionAndRotation($player->temporalVector->setComponents($player->namedtag["Pos"][0], $player->namedtag["Pos"][1], $player->namedtag["Pos"][2]), $player->namedtag->Rotation[0], $player->namedtag->Rotation[1]);
     $player->setMotion($player->temporalVector->setComponents($player->namedtag["Motion"][0], $player->namedtag["Motion"][1], $player->namedtag["Motion"][2]));
     assert(!is_nan($player->x) and !is_infinite($player->x) and !is_nan($player->y) and !is_infinite($player->y) and !is_nan($player->z) and !is_infinite($player->z));
     if (!isset($player->namedtag->FallDistance)) {
         $player->namedtag->FallDistance = new FloatTag("FallDistance", 0);
     }
     $player->fallDistance = $player->namedtag["FallDistance"];
     if (!isset($player->namedtag->Fire)) {
         $player->namedtag->Fire = new ShortTag("Fire", 0);
     }
     $player->fireTicks = $player->namedtag["Fire"];
     if (!isset($player->namedtag->Air)) {
         $player->namedtag->Air = new ShortTag("Air", 300);
     }
     $player->setDataProperty($player::DATA_AIR, $player::DATA_TYPE_SHORT, $player->namedtag["Air"]);
     if (!isset($player->namedtag->OnGround)) {
         $player->namedtag->OnGround = new ByteTag("OnGround", 0);
     }
     $player->onGround = $player->namedtag["OnGround"] > 0 ? true : false;
     if (!isset($player->namedtag->Invulnerable)) {
         $player->namedtag->Invulnerable = new ByteTag("Invulnerable", 0);
     }
     $player->invulnerable = $player->namedtag["Invulnerable"] > 0 ? true : false;
     $player->chunk->addEntity($player);
     $player->level->addEntity($player);
     $this->initialHuman($player);
     $player->lastUpdate = $this->server->getTick();
     $this->server->getPluginManager()->callEvent(new EntitySpawnEvent($player));
     $player->scheduleUpdate();
 }
Beispiel #3
0
 public function __construct(FullChunk $chunk, CompoundTag $nbt)
 {
     assert($chunk !== null and $chunk->getProvider() !== null);
     $this->timings = Timings::getEntityTimings($this);
     $this->isPlayer = $this instanceof Player;
     $this->temporalVector = new Vector3();
     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($this->temporalVector->setComponents($this->namedtag["Pos"][0], $this->namedtag["Pos"][1], $this->namedtag["Pos"][2]), $this->namedtag->Rotation[0], $this->namedtag->Rotation[1]);
     $this->setMotion($this->temporalVector->setComponents($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2]));
     assert(!is_nan($this->x) and !is_infinite($this->x) and !is_nan($this->y) and !is_infinite($this->y) and !is_nan($this->z) and !is_infinite($this->z));
     if (!isset($this->namedtag->FallDistance)) {
         $this->namedtag->FallDistance = new FloatTag("FallDistance", 0);
     }
     $this->fallDistance = $this->namedtag["FallDistance"];
     if (!isset($this->namedtag->Fire) || $this->namedtag["Fire"] > 32767) {
         $this->namedtag->Fire = new ShortTag("Fire", 0);
     }
     $this->fireTicks = $this->namedtag["Fire"];
     if (!isset($this->namedtag->Air)) {
         $this->namedtag->Air = new ShortTag("Air", 300);
     }
     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"], false);
     if (!isset($this->namedtag->OnGround)) {
         $this->namedtag->OnGround = new ByteTag("OnGround", 0);
     }
     $this->onGround = $this->namedtag["OnGround"] > 0 ? true : false;
     if (!isset($this->namedtag->Invulnerable)) {
         $this->namedtag->Invulnerable = new ByteTag("Invulnerable", 0);
     }
     $this->invulnerable = $this->namedtag["Invulnerable"] > 0 ? true : false;
     $this->attributeMap = new AttributeMap();
     $this->chunk->addEntity($this);
     $this->level->addEntity($this);
     $this->initEntity();
     $this->lastUpdate = $this->server->getTick();
     $this->server->getPluginManager()->callEvent(new EntitySpawnEvent($this));
     $this->scheduleUpdate();
 }
 public function doInit()
 {
     $nbt = $this->server->getOfflinePlayerData($this->name);
     if (!isset($nbt->NameTag)) {
         $nbt->NameTag = new StringTag("NameTag", $this->name);
     } else {
         $nbt["NameTag"] = $this->name;
     }
     $this->gamemode = $nbt["playerGameType"] & 0x3;
     if ($this->server->getForceGamemode()) {
         $this->gamemode = $this->server->getGamemode();
         $nbt->playerGameType = new IntTag("playerGameType", $this->gamemode);
     }
     $this->allowFlight = $this->isCreative();
     if (($level = $this->server->getLevelByName($nbt["Level"])) === null) {
         $this->setLevel($this->server->getDefaultLevel());
         $nbt["Level"] = $this->level->getName();
         $nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
         $nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
         $nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
     } else {
         $this->setLevel($level);
     }
     if (!$nbt instanceof CompoundTag) {
         $this->close($this->getLeaveMessage(), "Invalid data");
         return;
     }
     $this->achievements = [];
     /** @var Byte $achievement */
     foreach ($nbt->Achievements as $achievement) {
         $this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
     }
     $nbt->lastPlayed = new LongTag("lastPlayed", floor(microtime(true) * 1000));
     if ($this->server->getAutoSave()) {
         $this->server->saveOfflinePlayerData($this->name, $nbt, true);
     }
     $chunk = $this->level->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true);
     assert($chunk !== null and $chunk->getProvider() !== null);
     $this->timings = Timings::getEntityTimings($this);
     $this->isPlayer = $this instanceof Player;
     $this->temporalVector = new Vector3();
     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($this->temporalVector->setComponents($this->namedtag["Pos"][0], $this->namedtag["Pos"][1], $this->namedtag["Pos"][2]), $this->namedtag->Rotation[0], $this->namedtag->Rotation[1]);
     $this->setMotion($this->temporalVector->setComponents($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2]));
     assert(!is_nan($this->x) and !is_infinite($this->x) and !is_nan($this->y) and !is_infinite($this->y) and !is_nan($this->z) and !is_infinite($this->z));
     if (!isset($this->namedtag->FallDistance)) {
         $this->namedtag->FallDistance = new FloatTag("FallDistance", 0);
     }
     $this->fallDistance = $this->namedtag["FallDistance"];
     if (!isset($this->namedtag->Fire)) {
         $this->namedtag->Fire = new ShortTag("Fire", 0);
     }
     $this->fireTicks = $this->namedtag["Fire"];
     if (!isset($this->namedtag->Air)) {
         $this->namedtag->Air = new ShortTag("Air", 300);
     }
     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"]);
     if (!isset($this->namedtag->OnGround)) {
         $this->namedtag->OnGround = new ByteTag("OnGround", 0);
     }
     $this->onGround = $this->namedtag["OnGround"] > 0 ? true : false;
     if (!isset($this->namedtag->Invulnerable)) {
         $this->namedtag->Invulnerable = new ByteTag("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->scheduleUpdate();
 }