Example #1
0
        public static ChunkData Deserialize(ref SpanReader br, bool isOverworld)
        {
            var result = new ChunkData
            {
                ChunkX             = br.ReadAsInt(),
                ChunkZ             = br.ReadAsInt(),
                GroundUpContinuous = br.ReadAsBoolean(),
                PrimaryBitMask     = br.ReadAsVarInt(out _)
            };

            var hasBioms = result.GroundUpContinuous;

            result.Size = br.ReadAsVarInt(out _);
            var dataReader = br.ReadAsSubReader((int)result.Size - (hasBioms ? 256 : 0));
            var data       = new List <ChunkSection>();

            while (!dataReader.IsCosumed)
            {
                data.Add(ChunkSection.Deserialize(ref dataReader, isOverworld));
            }
            result.Data = data.ToArray();

            if (hasBioms)
            {
                result.Biomes = br.ReadAsByteArray(256);
            }
            result.NumberOfBlockEntities = br.ReadAsVarInt(out _);
            return(result);
        }
Example #2
0
        public static ChunkData Deserialize(ref SpanReader br, bool isOverworld)
        {
            var result = new ChunkData
            {
                ChunkX         = br.ReadAsInt(),
                ChunkZ         = br.ReadAsInt(),
                FullChunk      = br.ReadAsBoolean(),
                PrimaryBitMask = br.ReadAsVarInt(out _),
                Heightmaps     = br.ReadAsNbtTag(),
            };

            var hasBioms = result.FullChunk;

            if (hasBioms)
            {
                result.Biomes = br.ReadAsIntArray(1024);
            }

            result.Size = br.ReadAsVarInt(out _);
            var dataReader = br.ReadAsSubReader((int)result.Size);
            var data       = new List <ChunkSection>();

            while (!dataReader.IsCosumed)
            {
                data.Add(ChunkSection.Deserialize(ref dataReader, isOverworld));
            }
            result.Data = data.ToArray();

            result.NumberOfBlockEntities = br.ReadAsVarInt(out _);
            result.BlockEntities         = br.ReadAsNbtTagArray((int)result.NumberOfBlockEntities);
            return(result);
        }
Example #3
0
 public static Respawn Deserialize(ref SpanReader br)
 {
     return(new Respawn
     {
         Dimension = br.ReadAsInt(),
         HashedSeed = br.ReadAsLong(),
         Gamemode = br.ReadAsByte(),
         LevelType = br.ReadAsString()
     });
 }