示例#1
0
        protected static NBTBase ReadStream(BinaryReader stream)
        {
            NBTBase tag = CreateTag(stream.ReadByte());

            tag.ReadData(stream);
            return(tag);
        }
示例#2
0
 public static void WriteStream(Stream stream, NBTBase tag)
 {
     using (BinaryWriter writer = new BinaryWriter(stream)) {
         // Guess I'll include a header
         writer.Write(FORMAT_NAME); // Type
         writer.Write((byte)0);     // Version number
         WriteStream(writer, tag);
     }
 }
示例#3
0
        protected override void ReadData(BinaryReader stream)
        {
            NBTBase tag = null;

            while (!(tag is NBTEnd))
            {
                string name = stream.ReadString();
                tag = ReadStream(stream);
            }
        }
示例#4
0
        protected static void WriteStream(BinaryWriter stream, NBTBase tag)
        {
            int id = Array.IndexOf(TAG_IDS, tag.GetType());

            if (id == -1)
            {
                throw new ArgumentException("Unknown type " + tag.GetType().FullName, "tag");
            }
            stream.Write((byte)id);
            tag.WriteData(stream);
        }