mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
renamed PocketMine\PMF\Level to PocketMine\PMF\LevelFormat
This commit is contained in:
parent
e3c0ea6be5
commit
dd2d229f74
@ -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;
|
||||
|
@ -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){
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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"],
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user