mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-19 09:26:45 +00:00
LevelDB load/write fixes
This commit is contained in:
parent
20f9352714
commit
a40918aabf
@ -242,7 +242,7 @@ class Chunk extends BaseFullChunk{
|
||||
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
||||
|
||||
$entityData = $provider->getDatabase()->get(substr($data, 0, 8) . "\x32");
|
||||
if($entityData !== false){
|
||||
if($entityData !== false and strlen($entityData) > 0){
|
||||
$nbt->read($entityData);
|
||||
$entities = $nbt->getData();
|
||||
if(!is_array($entities)){
|
||||
@ -250,7 +250,7 @@ class Chunk extends BaseFullChunk{
|
||||
}
|
||||
}
|
||||
$tileData = $provider->getDatabase()->get(substr($data, 0, 8) . "\x31");
|
||||
if($tileData !== false){
|
||||
if($tileData !== false and strlen($tileData) > 0){
|
||||
$nbt->read($tileData);
|
||||
$tiles = $nbt->getData();
|
||||
if(!is_array($tiles)){
|
||||
@ -268,6 +268,7 @@ class Chunk extends BaseFullChunk{
|
||||
}
|
||||
return $chunk;
|
||||
}catch(\Exception $e){
|
||||
echo $e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -283,7 +284,8 @@ class Chunk extends BaseFullChunk{
|
||||
foreach($this->getEntities() as $entity){
|
||||
if(!($entity instanceof Player) and !$entity->closed){
|
||||
$entity->saveNBT();
|
||||
$entities[] = $nbt->write($entity->namedtag);
|
||||
$nbt->setData($entity->namedtag);
|
||||
$entities[] = $nbt->write();
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,7 +299,8 @@ class Chunk extends BaseFullChunk{
|
||||
$tiles = [];
|
||||
foreach($this->getTiles() as $tile){
|
||||
$tile->saveNBT();
|
||||
$tiles[] = $nbt->write($tile->namedtag);
|
||||
$nbt->setData($tile->namedtag);
|
||||
$tiles[] = $nbt->write();
|
||||
}
|
||||
|
||||
if(count($tiles) > 0){
|
||||
|
@ -235,7 +235,8 @@ class LevelDB extends BaseLevelProvider{
|
||||
|
||||
private function writeChunk(Chunk $chunk){
|
||||
$binary = $chunk->toBinary(true);
|
||||
$this->db->put($index = LevelDB::chunkIndex($chunk->getX(), $chunk->getZ()) . "\x30", substr($binary, 8, -1));
|
||||
$index = LevelDB::chunkIndex($chunk->getX(), $chunk->getZ());
|
||||
$this->db->put($index . "\x30", substr($binary, 8, -1));
|
||||
$this->db->put($index . "f", substr($binary, -1));
|
||||
$this->db->put($index . "v", "\x02");
|
||||
}
|
||||
@ -311,7 +312,7 @@ class LevelDB extends BaseLevelProvider{
|
||||
}
|
||||
|
||||
private function chunkExists($chunkX, $chunkZ){
|
||||
return $this->db->get(LevelDB::chunkIndex($chunkX, $chunkZ) . "\x76") !== false;
|
||||
return $this->db->get(LevelDB::chunkIndex($chunkX, $chunkZ) . "v") !== false;
|
||||
}
|
||||
|
||||
public function isChunkGenerated($chunkX, $chunkZ){
|
||||
|
Loading…
x
Reference in New Issue
Block a user