From dd2d229f74503a2d5f7f94737ae4beddda324046 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Thu, 6 Mar 2014 02:45:09 +0100 Subject: [PATCH] renamed PocketMine\PMF\Level to PocketMine\PMF\LevelFormat --- src/LevelAPI.php | 2 +- src/Player.php | 8 ++++---- src/entity/Entity.php | 6 +++--- src/level/Level.php | 26 +++++++++++++------------- src/level/LevelImport.php | 2 +- src/level/WorldGenerator.php | 2 +- src/pmf/Level.php | 2 +- src/tile/Tile.php | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/LevelAPI.php b/src/LevelAPI.php index 8990e170d..6aca94846 100644 --- a/src/LevelAPI.php +++ b/src/LevelAPI.php @@ -144,7 +144,7 @@ class LevelAPI{ } $path = DATA."worlds/".$name."/"; console("[INFO] Preparing level \"".$name."\""); - $level = new PMF\Level($path."level.pmf"); + $level = new PMF\LevelFormat($path."level.pmf"); if(!$level->isLoaded){ console("[ERROR] Could not load level \"".$name."\""); return false; diff --git a/src/Player.php b/src/Player.php index ad81ec5d8..79188d1c3 100644 --- a/src/Player.php +++ b/src/Player.php @@ -359,7 +359,7 @@ class Player extends Entity\RealHuman{ for($X = $startX; $X <= $finalX; ++$X){ for($Z = $startZ; $Z <= $finalZ; ++$Z){ $distance = abs($X - $centerX) + abs($Z - $centerZ); - $index = PMF\Level::getIndex($X, $Z); + $index = PMF\LevelFormat::getIndex($X, $Z); if(!isset($this->chunksLoaded[$index]) or $this->chunksLoaded[$index] !== 0){ $newOrder[$index] = $distance; } @@ -370,7 +370,7 @@ class Player extends Entity\RealHuman{ $this->chunksOrder = $newOrder; $index = key($this->chunksOrder); - PMF\Level::getXZ($index, $X, $Z); + PMF\LevelFormat::getXZ($index, $X, $Z); $this->level->loadChunk($X, $Z); if(!$this->level->isChunkPopulated($X, $Z)){ $this->level->loadChunk($X - 1, $Z); @@ -387,7 +387,7 @@ class Player extends Entity\RealHuman{ if($Yndex !== 0xff){ $X = null; $Z = null; - PMF\Level::getXZ($index, $X, $Z); + PMF\LevelFormat::getXZ($index, $X, $Z); foreach($this->level->getChunkEntities($X, $Z) as $entity){ if($entity !== $this){ $entity->despawnFrom($this); @@ -446,7 +446,7 @@ class Player extends Entity\RealHuman{ } $X = null; $Z = null; - PMF\Level::getXZ($index, $X, $Z); + PMF\LevelFormat::getXZ($index, $X, $Z); if(!$this->level->isChunkPopulated($X, $Z)){ $this->orderChunks(); if($this->chunkScheduled === 0 or $force === true){ diff --git a/src/entity/Entity.php b/src/entity/Entity.php index a5342a79a..f851ccf73 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -101,7 +101,7 @@ abstract class Entity extends Level\Position{ $this->onGround = $this->namedtag->OnGround > 0 ? true:false; $this->invulnerable = $this->namedtag->Invulnerable > 0 ? true:false; - $index = PMF\Level::getIndex($this->x >> 4, $this->z >> 4); + $index = PMF\LevelFormat::getIndex($this->x >> 4, $this->z >> 4); $this->chunkIndex = $index; Entity::$list[$this->id] = $this; $this->level->entities[$this->id] = $this; @@ -312,7 +312,7 @@ abstract class Entity extends Level\Position{ if($Yndex !== 0xff){ $X = null; $Z = null; - PMF\Level::getXZ($index, $X, $Z); + PMF\LevelFormat::getXZ($index, $X, $Z); foreach($this->level->getChunkEntities($X, $Z) as $entity){ $entity->despawnFrom($this); } @@ -377,7 +377,7 @@ abstract class Entity extends Level\Position{ $this->z = $pos->z; $radius = $this->width / 2; - if(($index = PMF\Level::getIndex($this->x >> 4, $this->z >> 4)) !== $this->chunkIndex){ + if(($index = PMF\LevelFormat::getIndex($this->x >> 4, $this->z >> 4)) !== $this->chunkIndex){ if($this->chunkIndex !== false){ unset($this->level->chunkEntities[$this->chunkIndex][$this->id]); } diff --git a/src/level/Level.php b/src/level/Level.php index c57c59ca2..a7ce7c83f 100644 --- a/src/level/Level.php +++ b/src/level/Level.php @@ -35,7 +35,7 @@ class Level{ public $stopTime; private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $generator; - public function __construct(PMF\Level $level, $name){ + public function __construct(PMF\LevelFormat $level, $name){ $this->server = ServerAPI::request(); $this->level = $level; $this->level->level = $this; @@ -59,12 +59,12 @@ class Level{ } public function getUsingChunk($X, $Z){ - $index = PMF\Level::getIndex($X, $Z); + $index = PMF\LevelFormat::getIndex($X, $Z); return isset($this->usedChunks[$index]) ? $this->usedChunks[$index]:array(); } public function useChunk($X, $Z, Player $player){ - $index = PMF\Level::getIndex($X, $Z); + $index = PMF\LevelFormat::getIndex($X, $Z); $this->loadChunk($X, $Z); $this->usedChunks[$index][$player->CID] = $player; } @@ -76,7 +76,7 @@ class Level{ } public function freeChunk($X, $Z, Player $player){ - unset($this->usedChunks[PMF\Level::getIndex($X, $Z)][$player->CID]); + unset($this->usedChunks[PMF\LevelFormat::getIndex($X, $Z)][$player->CID]); } public function isChunkPopulated($X, $Z){ @@ -148,7 +148,7 @@ class Level{ //Do chunk updates foreach($this->usedChunks as $index => $p){ - PMF\Level::getXZ($index, $X, $Z); + PMF\LevelFormat::getXZ($index, $X, $Z); for($Y = 0; $Y < 8; ++$Y){ if(!$this->level->isMiniChunkEmpty($X, $Z, $Y)){ for($i = 0; $i < 3; ++$i){ @@ -170,7 +170,7 @@ class Level{ foreach($this->usedChunks as $i => $c){ if(count($c) === 0){ unset($this->usedChunks[$i]); - PMF\Level::getXZ($i, $X, $Z); + PMF\LevelFormat::getXZ($i, $X, $Z); if(!$this->isSpawnChunk($X, $Z)){ $this->level->unloadChunk($X, $Z, $this->server->saveEnabled); } @@ -221,7 +221,7 @@ class Level{ protected function doSaveRoundExtra(){ foreach($this->usedChunks as $index => $d){ - PMF\Level::getXZ($index, $X, $Z); + PMF\LevelFormat::getXZ($index, $X, $Z); $nbt = new NBT(NBT\BIG_ENDIAN); $nbt->setData(new NBT\Tag\Compound("", array( "Entities" => new NBT\Tag\Enum("Entities", array()), @@ -279,7 +279,7 @@ class Level{ $pos = new Position($pos->x, $pos->y, $pos->z, $this); } $block->position($pos); - $index = PMF\Level::getIndex($pos->x >> 4, $pos->z >> 4); + $index = PMF\LevelFormat::getIndex($pos->x >> 4, $pos->z >> 4); if(ADVANCED_CACHE == true){ Utils\Cache::remove("world:{$this->name}:{$index}"); } @@ -319,7 +319,7 @@ class Level{ $pk->meta = $block->getMetadata(); Player::broadcastPacket($this->players, $pk); }else{ - $index = PMF\Level::getIndex($pos->x >> 4, $pos->z >> 4); + $index = PMF\LevelFormat::getIndex($pos->x >> 4, $pos->z >> 4); if(ADVANCED_CACHE == true){ Utils\Cache::remove("world:{$this->name}:{$index}"); } @@ -395,7 +395,7 @@ class Level{ } public function getChunkEntities($X, $Z){ - $index = PMF\Level::getIndex($X, $Z); + $index = PMF\LevelFormat::getIndex($X, $Z); if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){ return $this->chunkEntities[$index]; } @@ -403,7 +403,7 @@ class Level{ } public function getChunkTiles($X, $Z){ - $index = PMF\Level::getIndex($X, $Z); + $index = PMF\LevelFormat::getIndex($X, $Z); if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){ return $this->chunkTiles[$index]; } @@ -413,7 +413,7 @@ class Level{ public function loadChunk($X, $Z){ - $index = PMF\Level::getIndex($X, $Z); + $index = PMF\LevelFormat::getIndex($X, $Z); if(isset($this->usedChunks[$index])){ return true; }elseif($this->level->loadChunk($X, $Z) !== false){ @@ -469,7 +469,7 @@ class Level{ return false; } if(ADVANCED_CACHE == true and $Yndex === 0xff){ - $identifier = "world:{$this->name}:".PMF\Level::getIndex($X, $Z); + $identifier = "world:{$this->name}:".PMF\LevelFormat::getIndex($X, $Z); if(($cache = Utils\Cache::get($identifier)) !== false){ return $cache; } diff --git a/src/level/LevelImport.php b/src/level/LevelImport.php index f67f6df48..ddcee751b 100644 --- a/src/level/LevelImport.php +++ b/src/level/LevelImport.php @@ -60,7 +60,7 @@ class LevelImport{ return false; } - $pmf = new PMF\Level($this->path."level.pmf", array( + $pmf = new PMF\LevelFormat($this->path."level.pmf", array( "name" => $level["LevelName"], "seed" => $level["RandomSeed"], "time" => $level["Time"], diff --git a/src/level/WorldGenerator.php b/src/level/WorldGenerator.php index f4fcb5baa..c2d0809fe 100644 --- a/src/level/WorldGenerator.php +++ b/src/level/WorldGenerator.php @@ -30,7 +30,7 @@ class WorldGenerator{ $this->height = (int) $height; $this->path = DATA."worlds/".$name."/"; $this->generator = $generator; - $level = new PMF\Level($this->path."level.pmf", array( + $level = new PMF\LevelFormat($this->path."level.pmf", array( "name" => $name, "seed" => $this->seed, "time" => 0, diff --git a/src/pmf/Level.php b/src/pmf/Level.php index dc4c88df0..cc786a83c 100644 --- a/src/pmf/Level.php +++ b/src/pmf/Level.php @@ -22,7 +22,7 @@ namespace PocketMine\PMF; use PocketMine; -class Level extends PMF{ +class LevelFormat extends PMF{ const VERSION = 2; const ZLIB_LEVEL = 6; const ZLIB_ENCODING = 15; //15 = zlib, -15 = raw deflate, 31 = gzip diff --git a/src/tile/Tile.php b/src/tile/Tile.php index 655dd2079..95a669d3e 100644 --- a/src/tile/Tile.php +++ b/src/tile/Tile.php @@ -70,7 +70,7 @@ abstract class Tile extends Position{ $this->y = (int) $this->namedtag->y; $this->z = (int) $this->namedtag->z; - $index = PMF\Level::getIndex($this->x >> 4, $this->z >> 4); + $index = PMF\LevelFormat::getIndex($this->x >> 4, $this->z >> 4); $this->chunkIndex = $index; $this->level->tiles[$this->id] = $this; $this->level->chunkTiles[$this->chunkIndex][$this->id] = $this;