/// <summary> Writes a NbtTag object, and all of its child tags, to stream. /// Use this method sparingly with NbtWriter -- constructing NbtTag objects defeats the purpose of this class. /// If you already have lots of NbtTag objects, you might as well use NbtFile to write them all at once. </summary> /// <param name="tag"> Tag to write. Must not be null. </param> /// <exception cref="NbtFormatException"> No more tags can be written -OR- given tag is unacceptable at this time. </exception> /// <exception cref="ArgumentNullException"> <paramref name="tag"/> is null </exception> public void WriteTag([NotNull] NbtTag tag) { if (tag == null) { throw new ArgumentNullException("tag"); } EnforceConstraints(tag.Name, tag.TagType); if (tag.Name != null) { tag.WriteTag(writer); } else { tag.WriteData(writer); } }
/// <summary> /// Writes a NbtTag object, and all of its child tags, to stream. /// Use this method sparingly with NbtWriter -- constructing NbtTag objects defeats the purpose of this class. /// If you already have lots of NbtTag objects, you might as well use NbtFile to write them all at once. /// </summary> /// <param name="tag">Tag to write. Must not be null.</param> /// <exception cref="NbtFormatException">No more tags can be written -OR- given tag is unacceptable at this time.</exception> /// <exception cref="ArgumentNullException"><paramref name="tag"/>is null</exception> public void WriteTag(NbtTag tag) { if (tag is null) { throw new ArgumentNullException(nameof(tag)); } EnforceConstraints(tag.Name, tag.TagType); if (tag.Name != null) { tag.WriteTag(_writer); } else { tag.WriteData(_writer); } }