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

@ -25,6 +25,7 @@ namespace pocketmine\tile;
use pocketmine\level\Level;
use pocketmine\nbt\NBT;
use pocketmine\nbt\NetworkLittleEndianNBTStream;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
use pocketmine\Player;
@ -92,11 +93,11 @@ abstract class Spawnable extends Tile{
final public function getSerializedSpawnCompound() : string{
if($this->spawnCompoundCache === null){
if(self::$nbtWriter === null){
self::$nbtWriter = new NBT(NBT::LITTLE_ENDIAN);
self::$nbtWriter = new NetworkLittleEndianNBTStream();
}
self::$nbtWriter->setData($this->getSpawnCompound());
$this->spawnCompoundCache = self::$nbtWriter->write(true);
$this->spawnCompoundCache = self::$nbtWriter->write();
}
return $this->spawnCompoundCache;