NBT: Split up concerns of endianness and varint NBT into their own classes, separate stream handling from NBT class

The remaining methods, constants and fields in the NBT class now pertain to generic NBT functionality (except for the matchList()/matchTree() methods, but that's a job for another time). All NBT I/O specific logic has now been moved to NBTStream and its descendents.
This commit is contained in:
Dylan K. Taylor
2017-11-18 16:44:21 +00:00
parent 63edcb8934
commit 965c19375f
26 changed files with 588 additions and 342 deletions

View File

@ -29,7 +29,7 @@ use pocketmine\level\generator\Generator;
use pocketmine\level\Level;
use pocketmine\level\LevelException;
use pocketmine\math\Vector3;
use pocketmine\nbt\NBT;
use pocketmine\nbt\BigEndianNBTStream;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\scheduler\AsyncTask;
@ -48,7 +48,7 @@ abstract class BaseLevelProvider implements LevelProvider{
if(!file_exists($this->path)){
mkdir($this->path, 0777, true);
}
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt = new BigEndianNBTStream();
$nbt->readCompressed(file_get_contents($this->getPath() . "level.dat"));
$levelData = $nbt->getData()->getCompoundTag("Data");
if($levelData !== null){
@ -120,7 +120,7 @@ abstract class BaseLevelProvider implements LevelProvider{
}
public function saveLevelData(){
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt = new BigEndianNBTStream();
$nbt->setData(new CompoundTag("", [
$this->levelData
]));