mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 03:06:55 +00:00
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:
@ -30,6 +30,7 @@ use pocketmine\level\format\io\ChunkUtils;
|
||||
use pocketmine\level\format\SubChunk;
|
||||
use pocketmine\level\generator\Generator;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\BigEndianNBTStream;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\{
|
||||
ByteArrayTag, ByteTag, CompoundTag, IntArrayTag, IntTag, ListTag, LongTag, StringTag
|
||||
@ -102,7 +103,7 @@ class McRegion extends BaseLevelProvider{
|
||||
|
||||
$nbt->setTag(new ListTag("TileEntities", $tiles, NBT::TAG_Compound));
|
||||
|
||||
$writer = new NBT(NBT::BIG_ENDIAN);
|
||||
$writer = new BigEndianNBTStream();
|
||||
$nbt->setName("Level");
|
||||
$writer->setData(new CompoundTag("", [$nbt]));
|
||||
|
||||
@ -115,7 +116,7 @@ class McRegion extends BaseLevelProvider{
|
||||
* @return Chunk|null
|
||||
*/
|
||||
public function nbtDeserialize(string $data){
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
$nbt = new BigEndianNBTStream();
|
||||
try{
|
||||
$nbt->readCompressed($data);
|
||||
|
||||
@ -258,7 +259,7 @@ class McRegion extends BaseLevelProvider{
|
||||
new StringTag("LevelName", $name),
|
||||
new CompoundTag("GameRules", [])
|
||||
]);
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
$nbt = new BigEndianNBTStream();
|
||||
$nbt->setData(new CompoundTag("", [
|
||||
$levelData
|
||||
]));
|
||||
|
Reference in New Issue
Block a user