mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Removed some remaining references, removed duplicated code on Anvil
This commit is contained in:
parent
897774f848
commit
6ed63edd89
@ -581,7 +581,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendChunk($x, $z, &$payload){
|
public function sendChunk($x, $z, $payload){
|
||||||
if($this->connected === false){
|
if($this->connected === false){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1993,11 +1993,11 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function chunkRequestCallback($x, $z, &$payload){
|
public function chunkRequestCallback($x, $z, $payload){
|
||||||
$index = Level::chunkHash($x, $z);
|
$index = Level::chunkHash($x, $z);
|
||||||
|
|
||||||
if(!isset($this->chunkCache[$index]) and $this->cacheChunks and $this->server->getMemoryManager()->canUseChunkCache()){
|
if(!isset($this->chunkCache[$index]) and $this->cacheChunks and $this->server->getMemoryManager()->canUseChunkCache()){
|
||||||
$this->chunkCache[$index] =& $payload;
|
$this->chunkCache[$index] = $payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($this->chunkSendTasks[$index])){
|
if(isset($this->chunkSendTasks[$index])){
|
||||||
|
@ -54,65 +54,8 @@ class RegionLoader extends \pocketmine\level\format\mcregion\RegionLoader{
|
|||||||
$this->lastUsed = time();
|
$this->lastUsed = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readChunk($x, $z, $generate = true, $forward = false){
|
protected function unserializeChunk($data){
|
||||||
$index = self::getChunkOffset($x, $z);
|
return Chunk::fromBinary($data, $this->levelProvider);
|
||||||
if($index < 0 or $index >= 4096){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->lastUsed = time();
|
|
||||||
|
|
||||||
if(!$this->isChunkGenerated($index)){
|
|
||||||
if($generate === true){
|
|
||||||
//Allocate space
|
|
||||||
$this->locationTable[$index][0] = ++$this->lastSector;
|
|
||||||
$this->locationTable[$index][1] = 1;
|
|
||||||
fseek($this->filePointer, $this->locationTable[$index][0] << 12);
|
|
||||||
fwrite($this->filePointer, str_pad(Binary::writeInt(-1) . chr(self::COMPRESSION_ZLIB), 4096, "\x00", STR_PAD_RIGHT));
|
|
||||||
$this->writeLocationIndex($index);
|
|
||||||
}else{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek($this->filePointer, $this->locationTable[$index][0] << 12);
|
|
||||||
$length = Binary::readInt(fread($this->filePointer, 4));
|
|
||||||
$compression = ord(fgetc($this->filePointer));
|
|
||||||
|
|
||||||
if($length <= 0 or $length >= self::MAX_SECTOR_LENGTH){ //Not yet generated / corrupted
|
|
||||||
if($length >= self::MAX_SECTOR_LENGTH){
|
|
||||||
$this->locationTable[$index][0] = ++$this->lastSector;
|
|
||||||
$this->locationTable[$index][1] = 1;
|
|
||||||
MainLogger::getLogger()->error("Corrupted chunk header detected");
|
|
||||||
}
|
|
||||||
$this->generateChunk($x, $z);
|
|
||||||
fseek($this->filePointer, $this->locationTable[$index][0] << 12);
|
|
||||||
$length = Binary::readInt(fread($this->filePointer, 4));
|
|
||||||
$compression = ord(fgetc($this->filePointer));
|
|
||||||
}
|
|
||||||
|
|
||||||
if($length > ($this->locationTable[$index][1] << 12)){ //Invalid chunk, bigger than defined number of sectors
|
|
||||||
MainLogger::getLogger()->error("Corrupted bigger chunk detected");
|
|
||||||
$this->locationTable[$index][1] = $length >> 12;
|
|
||||||
$this->writeLocationIndex($index);
|
|
||||||
}elseif($compression !== self::COMPRESSION_ZLIB and $compression !== self::COMPRESSION_GZIP){
|
|
||||||
MainLogger::getLogger()->error("Invalid compression type");
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = fread($this->filePointer, $length - 1);
|
|
||||||
$chunk = Chunk::fromBinary($data, $this->levelProvider);
|
|
||||||
if($chunk instanceof Chunk){
|
|
||||||
return $chunk;
|
|
||||||
}elseif($forward === false){
|
|
||||||
MainLogger::getLogger()->error("Corrupted chunk detected");
|
|
||||||
$this->generateChunk($x, $z);
|
|
||||||
|
|
||||||
return $this->readChunk($x, $z, $generate, true);
|
|
||||||
}else{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateChunk($x, $z){
|
public function generateChunk($x, $z){
|
||||||
|
@ -344,7 +344,7 @@ class Chunk extends BaseFullChunk{
|
|||||||
$biomeColors = pack("N*", ...$this->getBiomeColorArray());
|
$biomeColors = pack("N*", ...$this->getBiomeColorArray());
|
||||||
$heightMap = pack("N*", ...$this->getHeightMapArray());
|
$heightMap = pack("N*", ...$this->getHeightMapArray());
|
||||||
|
|
||||||
$data =
|
return
|
||||||
Binary::writeInt($this->x) .
|
Binary::writeInt($this->x) .
|
||||||
Binary::writeInt($this->z) .
|
Binary::writeInt($this->z) .
|
||||||
$this->getBlockIdArray() .
|
$this->getBlockIdArray() .
|
||||||
@ -355,7 +355,6 @@ class Chunk extends BaseFullChunk{
|
|||||||
$biomeColors .
|
$biomeColors .
|
||||||
$heightMap .
|
$heightMap .
|
||||||
chr(($this->isPopulated() ? 1 << 1 : 0) + ($this->isGenerated() ? 1 : 0));
|
chr(($this->isPopulated() ? 1 << 1 : 0) + ($this->isGenerated() ? 1 : 0));
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toBinary(){
|
public function toBinary(){
|
||||||
|
@ -130,8 +130,7 @@ class RegionLoader{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = fread($this->filePointer, $length - 1);
|
$chunk = $this->unserializeChunk(fread($this->filePointer, $length - 1));
|
||||||
$chunk = Chunk::fromBinary($data, $this->levelProvider);
|
|
||||||
if($chunk instanceof Chunk){
|
if($chunk instanceof Chunk){
|
||||||
return $chunk;
|
return $chunk;
|
||||||
}elseif($forward === false){
|
}elseif($forward === false){
|
||||||
@ -144,6 +143,10 @@ class RegionLoader{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function unserializeChunk($data){
|
||||||
|
return Chunk::fromBinary($data, $this->levelProvider);
|
||||||
|
}
|
||||||
|
|
||||||
public function chunkExists($x, $z){
|
public function chunkExists($x, $z){
|
||||||
return $this->isChunkGenerated(self::getChunkOffset($x, $z));
|
return $this->isChunkGenerated(self::getChunkOffset($x, $z));
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ class IntArray extends NamedTag{
|
|||||||
|
|
||||||
public function write(NBT $nbt){
|
public function write(NBT $nbt){
|
||||||
$nbt->putInt(count($this->value));
|
$nbt->putInt(count($this->value));
|
||||||
$data = pack($nbt->endianness === NBT::LITTLE_ENDIAN ? "V*" : "N*", ...$this->value);
|
$nbt->put(pack($nbt->endianness === NBT::LITTLE_ENDIAN ? "V*" : "N*", ...$this->value));
|
||||||
$nbt->put($data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,13 +27,6 @@ use pocketmine\nbt\NBT;
|
|||||||
|
|
||||||
class String extends NamedTag{
|
class String extends NamedTag{
|
||||||
|
|
||||||
public function __construct($name = "", $value = null){
|
|
||||||
$this->name = $name;
|
|
||||||
if($value !== null){
|
|
||||||
$this->value = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getType(){
|
public function getType(){
|
||||||
return NBT::TAG_String;
|
return NBT::TAG_String;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user