Пример #1
0
 /// <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;
 }
Пример #2
0
        /// <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);
        }