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