/// <summary> Initializes a new instance of the NbtWriter class. </summary>
 /// <param name="stream"> Stream to write to. </param>
 /// <param name="rootTagName"> Name to give to the root tag (written immediately). </param>
 /// <param name="bigEndian"> Whether NBT data should be in Big-Endian encoding. </param>
 /// <exception cref="ArgumentNullException"> <paramref name="stream"/> or <paramref name="rootTagName"/> is <c>null</c>. </exception>
 /// <exception cref="ArgumentException"> <paramref name="stream"/> is not writable. </exception>
 public NbtWriter([NotNull] Stream stream, [NotNull] String rootTagName, bool bigEndian) {
     if (rootTagName == null) throw new ArgumentNullException("rootTagName");
     writer = new NbtBinaryWriter(stream, bigEndian);
     writer.Write((byte)NbtTagType.Compound);
     writer.Write(rootTagName);
     parentType = NbtTagType.Compound;
 }
 /// <summary> Initializes a new instance of the NbtWriter class. </summary>
 /// <param name="stream"> Stream to write to. </param>
 /// <param name="rootTagName"> Name to give to the root tag (written immediately). </param>
 /// <param name="bigEndian"> Whether NBT data should be in Big-Endian encoding. </param>
 /// <exception cref="ArgumentNullException"> <paramref name="stream"/> or <paramref name="rootTagName"/> is <c>null</c>. </exception>
 /// <exception cref="ArgumentException"> <paramref name="stream"/> is not writable. </exception>
 public NbtWriter([NotNull] Stream stream, [NotNull] String rootTagName, bool bigEndian)
 {
     if (rootTagName == null)
     {
         throw new ArgumentNullException("rootTagName");
     }
     writer = new NbtBinaryWriter(stream, bigEndian);
     writer.Write((byte)NbtTagType.Compound);
     writer.Write(rootTagName);
     parentType = NbtTagType.Compound;
 }
        /// <summary> Begins a named compound tag. </summary>
        /// <param name="tagName"> Name to give to this compound tag. May not be null. </param>
        /// <exception cref="NbtFormatException"> No more tags can be written -OR-
        /// an unnamed compound tag was expected -OR- a tag of a different type was expected. </exception>
        public void BeginCompound([NotNull] String tagName)
        {
            EnforceConstraints(tagName, NbtTagType.Compound);
            GoDown(NbtTagType.Compound);

            writer.Write((byte)NbtTagType.Compound);
            writer.Write(tagName);
        }
 internal override void WriteData(NbtBinaryWriter writeStream) {
     writeStream.Write(Value);
 }
 internal override void WriteTag(NbtBinaryWriter writeStream) {
     writeStream.Write(NbtTagType.Double);
     if (Name == null) throw new NbtFormatException("Name is null");
     writeStream.Write(Name);
     writeStream.Write(Value);
 }
 internal override void WriteData(NbtBinaryWriter writeStream) {
     writeStream.Write(Value.Length);
     for (int i = 0; i < Value.Length; i++) {
         writeStream.Write(Value[i]);
     }
 }
 internal override void WriteTag(NbtBinaryWriter writeStream) {
     writeStream.Write(NbtTagType.IntArray);
     if (Name == null) throw new NbtFormatException("Name is null");
     writeStream.Write(Name);
     WriteData(writeStream);
 }
 internal override void WriteData(NbtBinaryWriter writeStream) {
     writeStream.Write(Value.Length);
     writeStream.Write(Value, 0, Value.Length);
 }