Exemple #1
0
        private void StructureToCMD_Load(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string path = openFileDialog1.FileName;

                List <string>   pallets = new List <string>();
                string          cmds    = "";
                BinaryTagReader file    = new BinaryTagReader(new FileStream(path, FileMode.Open));
                var             doc     = file.ReadDocument();

                foreach (TagCompound tag in doc.GetList("palette").Value)
                {
                    string name = tag.GetStringValue("Name");
                    if (tag.Contains("Properties"))
                    {
                        name += "[";
                        name += tag.GetCompound("Properties").Value.Select(x => x.Name + "=" + x.GetValue().ToString()).Aggregate((x, y) => x + "," + y);
                        name += "]";
                    }
                    pallets.Add(name);
                }
                foreach (TagCompound tag in doc.GetList("blocks").Value)
                {
                    var pos2 = tag.GetList("pos").Value;
                    var pos  = pos2.Select(x => (int)x.GetValue()).ToArray();
                    cmds += $"/setblock ~{pos[0]} ~{pos[1]} ~{pos[2]} {pallets[tag.GetInt("state").Value]}\n";
                }
                CodeBox.Text = cmds;
            }
        }
Exemple #2
0
        public void ReadDocument_should_handle_uncompressed_files()
        {
            // arrange
            var       expected = CreateComplexData();
            Stream    stream   = File.OpenRead(UncompressedComplexDataFileName);
            TagReader target   = new BinaryTagReader(stream);

            // act
            var actual = target.ReadDocument();

            // assert
            NbtAssert.Equal(expected, actual);
        }
Exemple #3
0
        public void ReadExceptionTest()
        {
            // arrange
            var stream = new MemoryStream();

            stream.WriteByte(255);
            stream.Seek(0, SeekOrigin.Begin);
            TagReader reader = new BinaryTagReader(stream);

            // act
            var e = Assert.Throws <InvalidDataException>(() => reader.ReadTag());

            Assert.Equal("Unrecognized tag type: 255.", e.Message);
        }
Exemple #4
0
        public void ReadExceptionTest()
        {
            // arrange
            MemoryStream stream;
            TagReader    reader;

            stream = new MemoryStream();
            stream.WriteByte(255);
            stream.Seek(0, SeekOrigin.Begin);
            reader = new BinaryTagReader(stream);

            // act
            reader.ReadTag();

            // assert
        }
Exemple #5
0
        private void Inspector_Load(object sender, EventArgs e)
        {
            bool good = false;

            if (File.Exists(path))
            {
                good = true;
            }
            if (!good && openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                good = true;
                path = openFileDialog1.FileName;
            }
            if (good)
            {
                Dictionary <string, string> mapRevert = new Dictionary <string, string>();
                foreach (var key in Compiler.offuscationMap.Keys)
                {
                    mapRevert[Compiler.offuscationMap[key]] = key;
                }
                BinaryTagReader file = new BinaryTagReader(new FileStream(path, FileMode.Open));
                foreach (TagCompound i in file.ReadDocument().GetCompound("data").GetList("PlayerScores").Value)
                {
                    var name      = i.GetString("Name").Value;
                    var objective = i.GetString("Objective").Value;
                    var value     = i.GetInt("Score").Value;
                    if (mapRevert.ContainsKey(name))
                    {
                        lst.Add(new Scoreboard(mapRevert[name], objective, GetValue(mapRevert[name], value)));
                    }
                    else if (mapRevert.ContainsKey(objective))
                    {
                        lst.Add(new Scoreboard(name, mapRevert[objective], GetValue(mapRevert[objective], value)));
                    }
                    else
                    {
                        lst2.Add(new Scoreboard(name, objective, value.ToString()));
                    }
                }
                file.Close();
            }
            lst.Sort((x, y) => x.name.CompareTo(y.name));
            lst2.Sort((x, y) => x.name.CompareTo(y.name));
            Reload();
        }
Exemple #6
0
        public void ReadDocument_should_handle_uncompressed_files()
        {
            // arrange
            TagReader   target;
            TagCompound expected;
            TagCompound actual;
            Stream      stream;

            expected = this.CreateComplexData();
            stream   = File.OpenRead(this.UncompressedComplexDataFileName);
            target   = new BinaryTagReader(stream);

            // act
            actual = target.ReadDocument();

            // assert
            NbtAssert.AreEqual(expected, actual);
        }
Exemple #7
0
        private static TagReader GetReader(NbtFormat format, Stream stream)
        {
            TagReader reader;

            switch (format)
            {
            case NbtFormat.Binary:
                reader = new BinaryTagReader(stream);
                break;

            case NbtFormat.Xml:
                reader = new XmlTagReader(stream);
                break;

            default:
                throw new InvalidDataException("Unrecognized or unsupported file format.");
            }

            return(reader);
        }
Exemple #8
0
        public void TestAnvilRegion()
        {
            string     filename = this.AnvilRegionFileName;
            FileStream input    = File.OpenRead(filename);

            int[]  locations = new int[1024];
            byte[] buffer    = new byte[4096];
            input.Read(buffer, 0, 4096);
            for (int i = 0; i < 1024; i++)
            {
                locations[i] = BitConverter.ToInt32(buffer, i * 4);
            }

            int[] timestamps = new int[1024];
            input.Read(buffer, 0, 4096);
            for (int i = 0; i < 1024; i++)
            {
                timestamps[i] = BitConverter.ToInt32(buffer, i * 4);
            }

            input.Read(buffer, 0, 4);
            if (BitConverter.IsLittleEndian)
            {
                BitHelper.SwapBytes(buffer, 0, 4);
            }
            int sizeOfChunkData = BitConverter.ToInt32(buffer, 0) - 1;

            int compressionType = input.ReadByte();

            buffer = new byte[sizeOfChunkData];
            input.Read(buffer, 0, sizeOfChunkData);

            Stream inputStream = null;

            if (compressionType == 1)
            {
                inputStream = new GZipStream(new MemoryStream(buffer), CompressionMode.Decompress);
            }
            else if (compressionType == 2)
            {
                inputStream = new DeflateStream(new MemoryStream(buffer, 2, buffer.Length - 6), CompressionMode.Decompress);
            }

            TagReader reader;

            reader = new BinaryTagReader(inputStream);
            TagCompound tag    = (TagCompound)reader.ReadTag();
            string      strTag = tag.ToString();

            Assert.IsNotNull(tag);

            Assert.AreEqual(TagType.Compound, tag.GetTag("Level").Type);
            TagCompound levelTag = tag.GetCompound("Level");

            Tag aTag = levelTag.GetTag("Entities");

            Assert.AreEqual(TagType.List, aTag.Type);
            TagList entitiesTag = aTag as TagList;

            Assert.AreEqual(0, entitiesTag.Value.Count);

            aTag = levelTag.GetTag("Biomes");
            Assert.AreEqual(TagType.ByteArray, aTag.Type);
            TagByteArray biomesTag = aTag as TagByteArray;

            Assert.AreEqual(256, biomesTag.Value.Length);

            aTag = levelTag.GetTag("LastUpdate");
            Assert.AreEqual(TagType.Long, aTag.Type);
            TagLong lastUpdateTag = aTag as TagLong;

            Assert.AreEqual(2861877, lastUpdateTag.Value);

            aTag = levelTag.GetTag("xPos");
            Assert.AreEqual(TagType.Int, aTag.Type);
            TagInt xPosTag = aTag as TagInt;

            Assert.AreEqual(10, xPosTag.Value);

            aTag = levelTag.GetTag("zPos");
            Assert.AreEqual(TagType.Int, aTag.Type);
            TagInt zPosTag = aTag as TagInt;

            Assert.AreEqual(0, zPosTag.Value);

            aTag = levelTag.GetTag("TileEntities");
            Assert.AreEqual(TagType.List, aTag.Type);
            TagList tileEntitiesTag = aTag as TagList;

            Assert.AreEqual(0, tileEntitiesTag.Value.Count);

            aTag = levelTag.GetTag("TerrainPopulated");
            Assert.AreEqual(TagType.Byte, aTag.Type);
            TagByte terrainPopulatedTag = aTag as TagByte;

            Assert.AreEqual(1, terrainPopulatedTag.Value);

            aTag = levelTag.GetTag("HeightMap");
            Assert.AreEqual(TagType.IntArray, aTag.Type);
            TagIntArray heightmapTag = aTag as TagIntArray;

            Assert.AreEqual(256, heightmapTag.Value.Length);

            aTag = levelTag.GetTag("Sections");
            Assert.AreEqual(TagType.List, aTag.Type);
            TagList sectionsTag = aTag as TagList;

            Assert.AreEqual(4, sectionsTag.Value.Count);

            TagCompound section_0 = sectionsTag.Value[0] as TagCompound;

            Assert.IsNotNull(section_0);
            TagByteArray section_0_data = section_0.GetByteArray("Data");

            Assert.IsNotNull(section_0_data);
            Assert.AreEqual(2048, section_0_data.Value.Length);
            TagByteArray section_0_skyLight = section_0.GetByteArray("SkyLight");

            Assert.IsNotNull(section_0_skyLight);
            Assert.AreEqual(2048, section_0_skyLight.Value.Length);
            TagByteArray section_0_blockLight = section_0.GetByteArray("BlockLight");

            Assert.IsNotNull(section_0_blockLight);
            Assert.AreEqual(2048, section_0_blockLight.Value.Length);
            TagByte section_0_y = section_0.GetByte("Y");

            Assert.IsNotNull(section_0_y);
            Assert.AreEqual(0, section_0_y.Value);
            TagByteArray section_0_blocks = section_0.GetByteArray("Blocks");

            Assert.IsNotNull(section_0_blocks);
            Assert.AreEqual(4096, section_0_blocks.Value.Length);

            TagCompound section_1 = sectionsTag.Value[1] as TagCompound;

            Assert.IsNotNull(section_1);
            TagByteArray section_1_data = section_1.GetByteArray("Data");

            Assert.IsNotNull(section_1_data);
            Assert.AreEqual(2048, section_1_data.Value.Length);
            TagByteArray section_1_skyLight = section_1.GetByteArray("SkyLight");

            Assert.IsNotNull(section_1_skyLight);
            Assert.AreEqual(2048, section_1_skyLight.Value.Length);
            TagByteArray section_1_blockLight = section_1.GetByteArray("BlockLight");

            Assert.IsNotNull(section_1_blockLight);
            Assert.AreEqual(2048, section_1_blockLight.Value.Length);
            TagByte section_1_y = section_1.GetByte("Y");

            Assert.IsNotNull(section_1_y);
            Assert.AreEqual(1, section_1_y.Value);
            TagByteArray section_1_blocks = section_1.GetByteArray("Blocks");

            Assert.IsNotNull(section_1_blocks);
            Assert.AreEqual(4096, section_1_blocks.Value.Length);

            TagCompound section_2 = sectionsTag.Value[2] as TagCompound;

            Assert.IsNotNull(section_2);
            TagByteArray section_2_data = section_2.GetByteArray("Data");

            Assert.IsNotNull(section_2_data);
            Assert.AreEqual(2048, section_2_data.Value.Length);
            TagByteArray section_2_skyLight = section_2.GetByteArray("SkyLight");

            Assert.IsNotNull(section_2_skyLight);
            Assert.AreEqual(2048, section_2_skyLight.Value.Length);
            TagByteArray section_2_blockLight = section_2.GetByteArray("BlockLight");

            Assert.IsNotNull(section_2_blockLight);
            Assert.AreEqual(2048, section_2_blockLight.Value.Length);
            TagByte section_2_y = section_2.GetByte("Y");

            Assert.IsNotNull(section_2_y);
            Assert.AreEqual(2, section_2_y.Value);
            TagByteArray section_2_blocks = section_2.GetByteArray("Blocks");

            Assert.IsNotNull(section_2_blocks);
            Assert.AreEqual(4096, section_2_blocks.Value.Length);

            TagCompound section_3 = sectionsTag.Value[3] as TagCompound;

            Assert.IsNotNull(section_3);
            TagByteArray section_3_data = section_3.GetByteArray("Data");

            Assert.IsNotNull(section_3_data);
            Assert.AreEqual(2048, section_3_data.Value.Length);
            TagByteArray section_3_skyLight = section_3.GetByteArray("SkyLight");

            Assert.IsNotNull(section_3_skyLight);
            Assert.AreEqual(2048, section_3_skyLight.Value.Length);
            TagByteArray section_3_blockLight = section_3.GetByteArray("BlockLight");

            Assert.IsNotNull(section_3_blockLight);
            Assert.AreEqual(2048, section_3_blockLight.Value.Length);
            TagByte section_3_y = section_3.GetByte("Y");

            Assert.IsNotNull(section_3_y);
            Assert.AreEqual(3, section_3_y.Value);
            TagByteArray section_3_blocks = section_3.GetByteArray("Blocks");

            Assert.IsNotNull(section_3_blocks);
            Assert.AreEqual(4096, section_3_blocks.Value.Length);
        }
Exemple #9
0
        public void TestAnvilRegion()
        {
            var filename  = AnvilRegionFileName;
            var input     = File.OpenRead(filename);
            var locations = new int[1024];
            var buffer    = new byte[4096];

            input.Read(buffer, 0, 4096);
            for (var i = 0; i < 1024; i++)
            {
                locations[i] = BitConverter.ToInt32(buffer, i * 4);
            }

            var timestamps = new int[1024];

            input.Read(buffer, 0, 4096);
            for (var i = 0; i < 1024; i++)
            {
                timestamps[i] = BitConverter.ToInt32(buffer, i * 4);
            }

            input.Read(buffer, 0, 4);
            if (BitConverter.IsLittleEndian)
            {
                BitHelper.SwapBytes(buffer, 0, 4);
            }
            var sizeOfChunkData = BitConverter.ToInt32(buffer, 0) - 1;

            var compressionType = input.ReadByte();

            buffer = new byte[sizeOfChunkData];
            input.Read(buffer, 0, sizeOfChunkData);

            Stream inputStream = null;

            if (compressionType == 1)
            {
                inputStream = new GZipStream(new MemoryStream(buffer), CompressionMode.Decompress);
            }
            else if (compressionType == 2)
            {
                inputStream = new DeflateStream(new MemoryStream(buffer, 2, buffer.Length - 6),
                                                CompressionMode.Decompress);
            }

            TagReader reader;

            reader = new BinaryTagReader(inputStream);
            var tag = (TagCompound)reader.ReadTag();

            Assert.NotNull(tag);

            Assert.Equal(TagType.Compound, tag.GetTag("Level").Type);
            var levelTag = tag.GetCompound("Level");

            var aTag = levelTag.GetTag("Entities");

            Assert.Equal(TagType.List, aTag.Type);
            var entitiesTag = aTag as TagList;

            Assert.Equal(0, entitiesTag.Value.Count);

            aTag = levelTag.GetTag("Biomes");
            Assert.Equal(TagType.ByteArray, aTag.Type);
            var biomesTag = aTag as TagByteArray;

            Assert.Equal(256, biomesTag.Value.Length);

            aTag = levelTag.GetTag("LastUpdate");
            Assert.Equal(TagType.Long, aTag.Type);
            var lastUpdateTag = aTag as TagLong;

            Assert.Equal(2861877, lastUpdateTag.Value);

            aTag = levelTag.GetTag("xPos");
            Assert.Equal(TagType.Int, aTag.Type);
            var xPosTag = aTag as TagInt;

            Assert.Equal(10, xPosTag.Value);

            aTag = levelTag.GetTag("zPos");
            Assert.Equal(TagType.Int, aTag.Type);
            var zPosTag = aTag as TagInt;

            Assert.Equal(0, zPosTag.Value);

            aTag = levelTag.GetTag("TileEntities");
            Assert.Equal(TagType.List, aTag.Type);
            var tileEntitiesTag = aTag as TagList;

            Assert.Equal(0, tileEntitiesTag.Value.Count);

            aTag = levelTag.GetTag("TerrainPopulated");
            Assert.Equal(TagType.Byte, aTag.Type);
            var terrainPopulatedTag = aTag as TagByte;

            Assert.Equal(1, terrainPopulatedTag.Value);

            aTag = levelTag.GetTag("HeightMap");
            Assert.Equal(TagType.IntArray, aTag.Type);
            var heightmapTag = aTag as TagIntArray;

            Assert.Equal(256, heightmapTag.Value.Length);

            aTag = levelTag.GetTag("Sections");
            Assert.Equal(TagType.List, aTag.Type);
            var sectionsTag = aTag as TagList;

            Assert.Equal(4, sectionsTag.Value.Count);

            var section0 = sectionsTag.Value[0] as TagCompound;

            Assert.NotNull(section0);
            var section0Data = section0.GetByteArray("Data");

            Assert.NotNull(section0Data);
            Assert.Equal(2048, section0Data.Value.Length);
            var section0SkyLight = section0.GetByteArray("SkyLight");

            Assert.NotNull(section0SkyLight);
            Assert.Equal(2048, section0SkyLight.Value.Length);
            var section0BlockLight = section0.GetByteArray("BlockLight");

            Assert.NotNull(section0BlockLight);
            Assert.Equal(2048, section0BlockLight.Value.Length);
            var section0Y = section0.GetByte("Y");

            Assert.NotNull(section0Y);
            Assert.Equal(0, section0Y.Value);
            var section0Blocks = section0.GetByteArray("Blocks");

            Assert.NotNull(section0Blocks);
            Assert.Equal(4096, section0Blocks.Value.Length);

            var section1 = sectionsTag.Value[1] as TagCompound;

            Assert.NotNull(section1);
            var section1Data = section1.GetByteArray("Data");

            Assert.NotNull(section1Data);
            Assert.Equal(2048, section1Data.Value.Length);
            var section1SkyLight = section1.GetByteArray("SkyLight");

            Assert.NotNull(section1SkyLight);
            Assert.Equal(2048, section1SkyLight.Value.Length);
            var section1BlockLight = section1.GetByteArray("BlockLight");

            Assert.NotNull(section1BlockLight);
            Assert.Equal(2048, section1BlockLight.Value.Length);
            var section1Y = section1.GetByte("Y");

            Assert.NotNull(section1Y);
            Assert.Equal(1, section1Y.Value);
            var section1Blocks = section1.GetByteArray("Blocks");

            Assert.NotNull(section1Blocks);
            Assert.Equal(4096, section1Blocks.Value.Length);

            var section2 = sectionsTag.Value[2] as TagCompound;

            Assert.NotNull(section2);
            var section2Data = section2.GetByteArray("Data");

            Assert.NotNull(section2Data);
            Assert.Equal(2048, section2Data.Value.Length);
            var section2SkyLight = section2.GetByteArray("SkyLight");

            Assert.NotNull(section2SkyLight);
            Assert.Equal(2048, section2SkyLight.Value.Length);
            var section2BlockLight = section2.GetByteArray("BlockLight");

            Assert.NotNull(section2BlockLight);
            Assert.Equal(2048, section2BlockLight.Value.Length);
            var section2Y = section2.GetByte("Y");

            Assert.NotNull(section2Y);
            Assert.Equal(2, section2Y.Value);
            var section2Blocks = section2.GetByteArray("Blocks");

            Assert.NotNull(section2Blocks);
            Assert.Equal(4096, section2Blocks.Value.Length);

            var section3 = sectionsTag.Value[3] as TagCompound;

            Assert.NotNull(section3);
            var section3Data = section3.GetByteArray("Data");

            Assert.NotNull(section3Data);
            Assert.Equal(2048, section3Data.Value.Length);
            var section3SkyLight = section3.GetByteArray("SkyLight");

            Assert.NotNull(section3SkyLight);
            Assert.Equal(2048, section3SkyLight.Value.Length);
            var section3BlockLight = section3.GetByteArray("BlockLight");

            Assert.NotNull(section3BlockLight);
            Assert.Equal(2048, section3BlockLight.Value.Length);
            var section3Y = section3.GetByte("Y");

            Assert.NotNull(section3Y);
            Assert.Equal(3, section3Y.Value);
            var section3Blocks = section3.GetByteArray("Blocks");

            Assert.NotNull(section3Blocks);
            Assert.Equal(4096, section3Blocks.Value.Length);
        }
    public void TestAnvilRegion()
    {
      string filename = this.AnvilRegionFileName;
      FileStream input = File.OpenRead(filename);
      int[] locations = new int[1024];
      byte[] buffer = new byte[4096];
      input.Read(buffer, 0, 4096);
      for (int i = 0; i < 1024; i++)
        locations[i] = BitConverter.ToInt32(buffer, i * 4);

      int[] timestamps = new int[1024];
      input.Read(buffer, 0, 4096);
      for (int i = 0; i < 1024; i++)
        timestamps[i] = BitConverter.ToInt32(buffer, i * 4);

      input.Read(buffer, 0, 4);
      if (BitConverter.IsLittleEndian)
        BitHelper.SwapBytes(buffer, 0, 4);
      int sizeOfChunkData = BitConverter.ToInt32(buffer, 0) - 1;

      int compressionType = input.ReadByte();
      buffer = new byte[sizeOfChunkData];
      input.Read(buffer, 0, sizeOfChunkData);

      Stream inputStream = null;

      if (compressionType == 1)
        inputStream = new GZipStream(new MemoryStream(buffer), CompressionMode.Decompress);
      else if (compressionType == 2)
        inputStream = new DeflateStream(new MemoryStream(buffer, 2, buffer.Length - 6), CompressionMode.Decompress);

      BinaryTagReader reader;
      reader = new BinaryTagReader(inputStream, NbtOptions.Header);
      TagCompound tag = (TagCompound)reader.Read();
      string strTag = tag.ToString();

      Assert.IsNotNull(tag);

      Assert.AreEqual(TagType.Compound, tag.GetTag("Level").Type);
      TagCompound levelTag = tag.GetCompound("Level");

      ITag aTag = levelTag.GetTag("Entities");
      Assert.AreEqual(TagType.List, aTag.Type);
      TagList entitiesTag = aTag as TagList;
      Assert.AreEqual(0, entitiesTag.Value.Count);

      aTag = levelTag.GetTag("Biomes");
      Assert.AreEqual(TagType.ByteArray, aTag.Type);
      TagByteArray biomesTag = aTag as TagByteArray;
      Assert.AreEqual(256, biomesTag.Value.Length);

      aTag = levelTag.GetTag("LastUpdate");
      Assert.AreEqual(TagType.Long, aTag.Type);
      TagLong lastUpdateTag = aTag as TagLong;
      Assert.AreEqual(2861877, lastUpdateTag.Value);

      aTag = levelTag.GetTag("xPos");
      Assert.AreEqual(TagType.Int, aTag.Type);
      TagInt xPosTag = aTag as TagInt;
      Assert.AreEqual(10, xPosTag.Value);

      aTag = levelTag.GetTag("zPos");
      Assert.AreEqual(TagType.Int, aTag.Type);
      TagInt zPosTag = aTag as TagInt;
      Assert.AreEqual(0, zPosTag.Value);

      aTag = levelTag.GetTag("TileEntities");
      Assert.AreEqual(TagType.List, aTag.Type);
      TagList tileEntitiesTag = aTag as TagList;
      Assert.AreEqual(0, tileEntitiesTag.Value.Count);

      aTag = levelTag.GetTag("TerrainPopulated");
      Assert.AreEqual(TagType.Byte, aTag.Type);
      TagByte terrainPopulatedTag = aTag as TagByte;
      Assert.AreEqual(1, terrainPopulatedTag.Value);

      aTag = levelTag.GetTag("HeightMap");
      Assert.AreEqual(TagType.IntArray, aTag.Type);
      TagIntArray heightmapTag = aTag as TagIntArray;
      Assert.AreEqual(256, heightmapTag.Value.Length);

      aTag = levelTag.GetTag("Sections");
      Assert.AreEqual(TagType.List, aTag.Type);
      TagList sectionsTag = aTag as TagList;
      Assert.AreEqual(4, sectionsTag.Value.Count);

      TagCompound section_0 = sectionsTag.Value[0] as TagCompound;
      Assert.IsNotNull(section_0);
      TagByteArray section_0_data = section_0.GetByteArray("Data");
      Assert.IsNotNull(section_0_data);
      Assert.AreEqual(2048, section_0_data.Value.Length);
      TagByteArray section_0_skyLight = section_0.GetByteArray("SkyLight");
      Assert.IsNotNull(section_0_skyLight);
      Assert.AreEqual(2048, section_0_skyLight.Value.Length);
      TagByteArray section_0_blockLight = section_0.GetByteArray("BlockLight");
      Assert.IsNotNull(section_0_blockLight);
      Assert.AreEqual(2048, section_0_blockLight.Value.Length);
      TagByte section_0_y = section_0.GetByte("Y");
      Assert.IsNotNull(section_0_y);
      Assert.AreEqual(0, section_0_y.Value);
      TagByteArray section_0_blocks = section_0.GetByteArray("Blocks");
      Assert.IsNotNull(section_0_blocks);
      Assert.AreEqual(4096, section_0_blocks.Value.Length);

      TagCompound section_1 = sectionsTag.Value[1] as TagCompound;
      Assert.IsNotNull(section_1);
      TagByteArray section_1_data = section_1.GetByteArray("Data");
      Assert.IsNotNull(section_1_data);
      Assert.AreEqual(2048, section_1_data.Value.Length);
      TagByteArray section_1_skyLight = section_1.GetByteArray("SkyLight");
      Assert.IsNotNull(section_1_skyLight);
      Assert.AreEqual(2048, section_1_skyLight.Value.Length);
      TagByteArray section_1_blockLight = section_1.GetByteArray("BlockLight");
      Assert.IsNotNull(section_1_blockLight);
      Assert.AreEqual(2048, section_1_blockLight.Value.Length);
      TagByte section_1_y = section_1.GetByte("Y");
      Assert.IsNotNull(section_1_y);
      Assert.AreEqual(1, section_1_y.Value);
      TagByteArray section_1_blocks = section_1.GetByteArray("Blocks");
      Assert.IsNotNull(section_1_blocks);
      Assert.AreEqual(4096, section_1_blocks.Value.Length);

      TagCompound section_2 = sectionsTag.Value[2] as TagCompound;
      Assert.IsNotNull(section_2);
      TagByteArray section_2_data = section_2.GetByteArray("Data");
      Assert.IsNotNull(section_2_data);
      Assert.AreEqual(2048, section_2_data.Value.Length);
      TagByteArray section_2_skyLight = section_2.GetByteArray("SkyLight");
      Assert.IsNotNull(section_2_skyLight);
      Assert.AreEqual(2048, section_2_skyLight.Value.Length);
      TagByteArray section_2_blockLight = section_2.GetByteArray("BlockLight");
      Assert.IsNotNull(section_2_blockLight);
      Assert.AreEqual(2048, section_2_blockLight.Value.Length);
      TagByte section_2_y = section_2.GetByte("Y");
      Assert.IsNotNull(section_2_y);
      Assert.AreEqual(2, section_2_y.Value);
      TagByteArray section_2_blocks = section_2.GetByteArray("Blocks");
      Assert.IsNotNull(section_2_blocks);
      Assert.AreEqual(4096, section_2_blocks.Value.Length);

      TagCompound section_3 = sectionsTag.Value[3] as TagCompound;
      Assert.IsNotNull(section_3);
      TagByteArray section_3_data = section_3.GetByteArray("Data");
      Assert.IsNotNull(section_3_data);
      Assert.AreEqual(2048, section_3_data.Value.Length);
      TagByteArray section_3_skyLight = section_3.GetByteArray("SkyLight");
      Assert.IsNotNull(section_3_skyLight);
      Assert.AreEqual(2048, section_3_skyLight.Value.Length);
      TagByteArray section_3_blockLight = section_3.GetByteArray("BlockLight");
      Assert.IsNotNull(section_3_blockLight);
      Assert.AreEqual(2048, section_3_blockLight.Value.Length);
      TagByte section_3_y = section_3.GetByte("Y");
      Assert.IsNotNull(section_3_y);
      Assert.AreEqual(3, section_3_y.Value);
      TagByteArray section_3_blocks = section_3.GetByteArray("Blocks");
      Assert.IsNotNull(section_3_blocks);
      Assert.AreEqual(4096, section_3_blocks.Value.Length);
    }
Exemple #11
0
    public void ReadExceptionTest()
    {
      // arrange
      MemoryStream stream;
      BinaryTagReader reader;

      stream = new MemoryStream();
      stream.WriteByte(255);
      stream.Seek(0, SeekOrigin.Begin);
      reader = new BinaryTagReader(stream, NbtOptions.None);

      // act
      reader.Read();

      // assert
    }