public function __construct(Position $center, $size, $what = null) { $this->level = $center->getLevel(); $this->source = $center; $this->size = max($size, 0); $this->what = $what; }
/** * Handles player data saving */ public function save($async = false) { if ($this->closed) { throw new \InvalidStateException("Tried to save closed player"); } parent::saveNBT(); if ($this->level instanceof Level) { $this->namedtag->Level = new String("Level", $this->level->getName()); if ($this->spawnPosition instanceof Position and $this->spawnPosition->getLevel() instanceof Level) { $this->namedtag["SpawnLevel"] = $this->spawnPosition->getLevel()->getName(); $this->namedtag["SpawnX"] = (int) $this->spawnPosition->x; $this->namedtag["SpawnY"] = (int) $this->spawnPosition->y; $this->namedtag["SpawnZ"] = (int) $this->spawnPosition->z; } foreach ($this->achievements as $achievement => $status) { $this->namedtag->Achievements[$achievement] = new Byte($achievement, $status === true ? 1 : 0); } $this->namedtag["playerGameType"] = $this->gamemode; $this->namedtag["lastPlayed"] = new Long("lastPlayed", floor(microtime(true) * 1000)); $this->namedtag["Hunger"] = new Short("Hunger", $this->getFood()); $this->namedtag["Health"] = new Short("Health", $this->getHealth()); $this->namedtag["MaxHealth"] = new Short("MaxHealth", $this->getMaxHealth()); $this->namedtag["ExpCurrent"] = new Long("ExpCurrent", $this->getCurrentExperience()); $this->namedtag["ExpLevel"] = new Long("ExpLevel", $this->getExperienceLevel()); if ($this->username != "" and $this->namedtag instanceof Compound) { $this->server->saveOfflinePlayerData($this->username, $this->namedtag, $async); } } }