mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-03 18:42:37 +00:00
Added optional parameter for multiple NBT read
This commit is contained in:
parent
afa8496767
commit
b6c0eb8c96
@ -243,7 +243,7 @@ class Chunk extends BaseFullChunk{
|
||||
|
||||
$entityData = $provider->getDatabase()->get(substr($data, 0, 8) . "\x32");
|
||||
if($entityData !== false and strlen($entityData) > 0){
|
||||
$nbt->read($entityData);
|
||||
$nbt->read($entityData, true);
|
||||
$entities = $nbt->getData();
|
||||
if(!is_array($entities)){
|
||||
$entities = [$entities];
|
||||
@ -251,7 +251,7 @@ class Chunk extends BaseFullChunk{
|
||||
}
|
||||
$tileData = $provider->getDatabase()->get(substr($data, 0, 8) . "\x31");
|
||||
if($tileData !== false and strlen($tileData) > 0){
|
||||
$nbt->read($tileData);
|
||||
$nbt->read($tileData, true);
|
||||
$tiles = $nbt->getData();
|
||||
if(!is_array($tiles)){
|
||||
$tiles = [$tiles];
|
||||
|
@ -97,11 +97,11 @@ class NBT{
|
||||
$this->endianness = $endianness & 0x01;
|
||||
}
|
||||
|
||||
public function read($buffer){
|
||||
public function read($buffer, $doMultiple = false){
|
||||
$this->offset = 0;
|
||||
$this->buffer = $buffer;
|
||||
$this->data = $this->readTag();
|
||||
if($this->offset < strlen($this->buffer)){
|
||||
if($doMultiple and $this->offset < strlen($this->buffer)){
|
||||
$this->data = [$this->data];
|
||||
do{
|
||||
$this->data[] = $this->readTag();
|
||||
@ -120,9 +120,14 @@ class NBT{
|
||||
$this->writeTag($this->data);
|
||||
|
||||
return $this->buffer;
|
||||
}else{
|
||||
return false;
|
||||
}elseif(is_array($this->data)){
|
||||
foreach($this->data as $tag){
|
||||
$this->writeTag($tag);
|
||||
}
|
||||
return $this->buffer;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function writeCompressed($compression = ZLIB_ENCODING_GZIP, $level = 7){
|
||||
|
Loading…
x
Reference in New Issue
Block a user