Exemple #1
0
		/// <summary>
		/// Writes out the specified tag.
		/// </summary>
		/// <param name="tag">The tag.</param>
		/// <exception cref="System.ArgumentNullException"><paramref name="tag"/> is <c>null</c>.</exception>
		/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
		/// <exception cref="System.IO.IOException">An I/O error occured.</exception>
		public void Write(NbtTag tag)
		{
			if (tag == null)
				throw new ArgumentNullException("tag", "tag is null.");

			Write(tag, true);
		}
Exemple #2
0
		void Write(NbtTag tag, bool writeHeader)
		{
			switch (tag.Type)
			{
				case NbtTagType.Byte:
					Write((NbtByte)tag, writeHeader);
					break;
				case NbtTagType.Short:
					Write((NbtShort)tag, writeHeader);
					break;
				case NbtTagType.Int:
					Write((NbtInt)tag, writeHeader);
					break;
				case NbtTagType.Long:
					Write((NbtLong)tag, writeHeader);
					break;
				case NbtTagType.Float:
					Write((NbtFloat)tag, writeHeader);
					break;
				case NbtTagType.Double:
					Write((NbtDouble)tag, writeHeader);
					break;
				case NbtTagType.ByteArray:
					Write((NbtByteArray)tag, writeHeader);
					break;
				case NbtTagType.String:
					Write((NbtString)tag, writeHeader);
					break;
				case NbtTagType.List:
					Write((NbtList)tag, writeHeader);
					break;
				case NbtTagType.Compound:
					Write((NbtCompound)tag, writeHeader);
					break;
				case NbtTagType.IntArray:
					Write((NbtIntArray)tag, writeHeader);
					break;
				default:
					break;
			}
		}
Exemple #3
0
		internal void Write(string name, NbtTagType elementType, NbtTag[] value, bool writeHeader)
		{
			if (writeHeader)
				WriteTagHeader(NbtTagType.List, name);

			Write((byte)elementType);

			if (value == null)
			{
				Write((int)0);
			}
			else
			{
				Write((int)value.Length);

				foreach (var element in value)
					Write(element, false);
			}
		}
Exemple #4
0
		void WriteTagHeader(NbtTag tag)
		{
			WriteTagHeader(tag.Type, tag.Name);
		}
Exemple #5
0
		/// <summary>
		/// Writes out a tag containing the specified name and array of values.
		/// </summary>
		/// <param name="name">The tag name.</param>
		/// <param name="elementType">Type of the element in <paramref name="value"/>.</param>
		/// <param name="value">The value.</param>
		/// <exception cref="System.ArgumentException"><paramref name="value"/> contains elements of a type other than that specified by <paramref name="elementType"/>.</exception>
		/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
		/// <exception cref="System.IO.IOException">An I/O error occured.</exception>
		public void Write(string name, NbtTagType elementType, NbtTag[] value)
		{
			Write(name, elementType, value, true);
		}