protected static NBTBase ReadStream(BinaryReader stream) { NBTBase tag = CreateTag(stream.ReadByte()); tag.ReadData(stream); return(tag); }
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); } }
protected override void ReadData(BinaryReader stream) { NBTBase tag = null; while (!(tag is NBTEnd)) { string name = stream.ReadString(); tag = ReadStream(stream); } }
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); }