mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 12:27:51 +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."/";
|
$path = DATA."worlds/".$name."/";
|
||||||
console("[INFO] Preparing level \"".$name."\"");
|
console("[INFO] Preparing level \"".$name."\"");
|
||||||
$level = new PMF\Level($path."level.pmf");
|
$level = new PMF\LevelFormat($path."level.pmf");
|
||||||
if(!$level->isLoaded){
|
if(!$level->isLoaded){
|
||||||
console("[ERROR] Could not load level \"".$name."\"");
|
console("[ERROR] Could not load level \"".$name."\"");
|
||||||
return false;
|
return false;
|
||||||
|
@ -359,7 +359,7 @@ class Player extends Entity\RealHuman{
|
|||||||
for($X = $startX; $X <= $finalX; ++$X){
|
for($X = $startX; $X <= $finalX; ++$X){
|
||||||
for($Z = $startZ; $Z <= $finalZ; ++$Z){
|
for($Z = $startZ; $Z <= $finalZ; ++$Z){
|
||||||
$distance = abs($X - $centerX) + abs($Z - $centerZ);
|
$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){
|
if(!isset($this->chunksLoaded[$index]) or $this->chunksLoaded[$index] !== 0){
|
||||||
$newOrder[$index] = $distance;
|
$newOrder[$index] = $distance;
|
||||||
}
|
}
|
||||||
@ -370,7 +370,7 @@ class Player extends Entity\RealHuman{
|
|||||||
$this->chunksOrder = $newOrder;
|
$this->chunksOrder = $newOrder;
|
||||||
|
|
||||||
$index = key($this->chunksOrder);
|
$index = key($this->chunksOrder);
|
||||||
PMF\Level::getXZ($index, $X, $Z);
|
PMF\LevelFormat::getXZ($index, $X, $Z);
|
||||||
$this->level->loadChunk($X, $Z);
|
$this->level->loadChunk($X, $Z);
|
||||||
if(!$this->level->isChunkPopulated($X, $Z)){
|
if(!$this->level->isChunkPopulated($X, $Z)){
|
||||||
$this->level->loadChunk($X - 1, $Z);
|
$this->level->loadChunk($X - 1, $Z);
|
||||||
@ -387,7 +387,7 @@ class Player extends Entity\RealHuman{
|
|||||||
if($Yndex !== 0xff){
|
if($Yndex !== 0xff){
|
||||||
$X = null;
|
$X = null;
|
||||||
$Z = null;
|
$Z = null;
|
||||||
PMF\Level::getXZ($index, $X, $Z);
|
PMF\LevelFormat::getXZ($index, $X, $Z);
|
||||||
foreach($this->level->getChunkEntities($X, $Z) as $entity){
|
foreach($this->level->getChunkEntities($X, $Z) as $entity){
|
||||||
if($entity !== $this){
|
if($entity !== $this){
|
||||||
$entity->despawnFrom($this);
|
$entity->despawnFrom($this);
|
||||||
@ -446,7 +446,7 @@ class Player extends Entity\RealHuman{
|
|||||||
}
|
}
|
||||||
$X = null;
|
$X = null;
|
||||||
$Z = null;
|
$Z = null;
|
||||||
PMF\Level::getXZ($index, $X, $Z);
|
PMF\LevelFormat::getXZ($index, $X, $Z);
|
||||||
if(!$this->level->isChunkPopulated($X, $Z)){
|
if(!$this->level->isChunkPopulated($X, $Z)){
|
||||||
$this->orderChunks();
|
$this->orderChunks();
|
||||||
if($this->chunkScheduled === 0 or $force === true){
|
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->onGround = $this->namedtag->OnGround > 0 ? true:false;
|
||||||
$this->invulnerable = $this->namedtag->Invulnerable > 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;
|
$this->chunkIndex = $index;
|
||||||
Entity::$list[$this->id] = $this;
|
Entity::$list[$this->id] = $this;
|
||||||
$this->level->entities[$this->id] = $this;
|
$this->level->entities[$this->id] = $this;
|
||||||
@ -312,7 +312,7 @@ abstract class Entity extends Level\Position{
|
|||||||
if($Yndex !== 0xff){
|
if($Yndex !== 0xff){
|
||||||
$X = null;
|
$X = null;
|
||||||
$Z = null;
|
$Z = null;
|
||||||
PMF\Level::getXZ($index, $X, $Z);
|
PMF\LevelFormat::getXZ($index, $X, $Z);
|
||||||
foreach($this->level->getChunkEntities($X, $Z) as $entity){
|
foreach($this->level->getChunkEntities($X, $Z) as $entity){
|
||||||
$entity->despawnFrom($this);
|
$entity->despawnFrom($this);
|
||||||
}
|
}
|
||||||
@ -377,7 +377,7 @@ abstract class Entity extends Level\Position{
|
|||||||
$this->z = $pos->z;
|
$this->z = $pos->z;
|
||||||
|
|
||||||
$radius = $this->width / 2;
|
$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){
|
if($this->chunkIndex !== false){
|
||||||
unset($this->level->chunkEntities[$this->chunkIndex][$this->id]);
|
unset($this->level->chunkEntities[$this->chunkIndex][$this->id]);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class Level{
|
|||||||
public $stopTime;
|
public $stopTime;
|
||||||
private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $generator;
|
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->server = ServerAPI::request();
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$this->level->level = $this;
|
$this->level->level = $this;
|
||||||
@ -59,12 +59,12 @@ class Level{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getUsingChunk($X, $Z){
|
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();
|
return isset($this->usedChunks[$index]) ? $this->usedChunks[$index]:array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function useChunk($X, $Z, Player $player){
|
public function useChunk($X, $Z, Player $player){
|
||||||
$index = PMF\Level::getIndex($X, $Z);
|
$index = PMF\LevelFormat::getIndex($X, $Z);
|
||||||
$this->loadChunk($X, $Z);
|
$this->loadChunk($X, $Z);
|
||||||
$this->usedChunks[$index][$player->CID] = $player;
|
$this->usedChunks[$index][$player->CID] = $player;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ class Level{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function freeChunk($X, $Z, Player $player){
|
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){
|
public function isChunkPopulated($X, $Z){
|
||||||
@ -148,7 +148,7 @@ class Level{
|
|||||||
|
|
||||||
//Do chunk updates
|
//Do chunk updates
|
||||||
foreach($this->usedChunks as $index => $p){
|
foreach($this->usedChunks as $index => $p){
|
||||||
PMF\Level::getXZ($index, $X, $Z);
|
PMF\LevelFormat::getXZ($index, $X, $Z);
|
||||||
for($Y = 0; $Y < 8; ++$Y){
|
for($Y = 0; $Y < 8; ++$Y){
|
||||||
if(!$this->level->isMiniChunkEmpty($X, $Z, $Y)){
|
if(!$this->level->isMiniChunkEmpty($X, $Z, $Y)){
|
||||||
for($i = 0; $i < 3; ++$i){
|
for($i = 0; $i < 3; ++$i){
|
||||||
@ -170,7 +170,7 @@ class Level{
|
|||||||
foreach($this->usedChunks as $i => $c){
|
foreach($this->usedChunks as $i => $c){
|
||||||
if(count($c) === 0){
|
if(count($c) === 0){
|
||||||
unset($this->usedChunks[$i]);
|
unset($this->usedChunks[$i]);
|
||||||
PMF\Level::getXZ($i, $X, $Z);
|
PMF\LevelFormat::getXZ($i, $X, $Z);
|
||||||
if(!$this->isSpawnChunk($X, $Z)){
|
if(!$this->isSpawnChunk($X, $Z)){
|
||||||
$this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
$this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ class Level{
|
|||||||
|
|
||||||
protected function doSaveRoundExtra(){
|
protected function doSaveRoundExtra(){
|
||||||
foreach($this->usedChunks as $index => $d){
|
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 = new NBT(NBT\BIG_ENDIAN);
|
||||||
$nbt->setData(new NBT\Tag\Compound("", array(
|
$nbt->setData(new NBT\Tag\Compound("", array(
|
||||||
"Entities" => new NBT\Tag\Enum("Entities", array()),
|
"Entities" => new NBT\Tag\Enum("Entities", array()),
|
||||||
@ -279,7 +279,7 @@ class Level{
|
|||||||
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
||||||
}
|
}
|
||||||
$block->position($pos);
|
$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){
|
if(ADVANCED_CACHE == true){
|
||||||
Utils\Cache::remove("world:{$this->name}:{$index}");
|
Utils\Cache::remove("world:{$this->name}:{$index}");
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ class Level{
|
|||||||
$pk->meta = $block->getMetadata();
|
$pk->meta = $block->getMetadata();
|
||||||
Player::broadcastPacket($this->players, $pk);
|
Player::broadcastPacket($this->players, $pk);
|
||||||
}else{
|
}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){
|
if(ADVANCED_CACHE == true){
|
||||||
Utils\Cache::remove("world:{$this->name}:{$index}");
|
Utils\Cache::remove("world:{$this->name}:{$index}");
|
||||||
}
|
}
|
||||||
@ -395,7 +395,7 @@ class Level{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getChunkEntities($X, $Z){
|
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){
|
if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){
|
||||||
return $this->chunkEntities[$index];
|
return $this->chunkEntities[$index];
|
||||||
}
|
}
|
||||||
@ -403,7 +403,7 @@ class Level{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getChunkTiles($X, $Z){
|
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){
|
if(isset($this->usedChunks[$index]) or $this->loadChunk($X, $Z) === true){
|
||||||
return $this->chunkTiles[$index];
|
return $this->chunkTiles[$index];
|
||||||
}
|
}
|
||||||
@ -413,7 +413,7 @@ class Level{
|
|||||||
|
|
||||||
|
|
||||||
public function loadChunk($X, $Z){
|
public function loadChunk($X, $Z){
|
||||||
$index = PMF\Level::getIndex($X, $Z);
|
$index = PMF\LevelFormat::getIndex($X, $Z);
|
||||||
if(isset($this->usedChunks[$index])){
|
if(isset($this->usedChunks[$index])){
|
||||||
return true;
|
return true;
|
||||||
}elseif($this->level->loadChunk($X, $Z) !== false){
|
}elseif($this->level->loadChunk($X, $Z) !== false){
|
||||||
@ -469,7 +469,7 @@ class Level{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(ADVANCED_CACHE == true and $Yndex === 0xff){
|
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){
|
if(($cache = Utils\Cache::get($identifier)) !== false){
|
||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class LevelImport{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pmf = new PMF\Level($this->path."level.pmf", array(
|
$pmf = new PMF\LevelFormat($this->path."level.pmf", array(
|
||||||
"name" => $level["LevelName"],
|
"name" => $level["LevelName"],
|
||||||
"seed" => $level["RandomSeed"],
|
"seed" => $level["RandomSeed"],
|
||||||
"time" => $level["Time"],
|
"time" => $level["Time"],
|
||||||
|
@ -30,7 +30,7 @@ class WorldGenerator{
|
|||||||
$this->height = (int) $height;
|
$this->height = (int) $height;
|
||||||
$this->path = DATA."worlds/".$name."/";
|
$this->path = DATA."worlds/".$name."/";
|
||||||
$this->generator = $generator;
|
$this->generator = $generator;
|
||||||
$level = new PMF\Level($this->path."level.pmf", array(
|
$level = new PMF\LevelFormat($this->path."level.pmf", array(
|
||||||
"name" => $name,
|
"name" => $name,
|
||||||
"seed" => $this->seed,
|
"seed" => $this->seed,
|
||||||
"time" => 0,
|
"time" => 0,
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
namespace PocketMine\PMF;
|
namespace PocketMine\PMF;
|
||||||
use PocketMine;
|
use PocketMine;
|
||||||
|
|
||||||
class Level extends PMF{
|
class LevelFormat extends PMF{
|
||||||
const VERSION = 2;
|
const VERSION = 2;
|
||||||
const ZLIB_LEVEL = 6;
|
const ZLIB_LEVEL = 6;
|
||||||
const ZLIB_ENCODING = 15; //15 = zlib, -15 = raw deflate, 31 = gzip
|
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->y = (int) $this->namedtag->y;
|
||||||
$this->z = (int) $this->namedtag->z;
|
$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->chunkIndex = $index;
|
||||||
$this->level->tiles[$this->id] = $this;
|
$this->level->tiles[$this->id] = $this;
|
||||||
$this->level->chunkTiles[$this->chunkIndex][$this->id] = $this;
|
$this->level->chunkTiles[$this->chunkIndex][$this->id] = $this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user