/// <summary>Writes the nbt's content to the <see cref="Stream"/></summary> /// <param name="tag">The tag to write to the <see cref="Stream"/></param> /// <param name="Context">The context that provides a buffer, the stream and endianness of the NBT</param> public void WriteContent(ITag tag, SerializationContext Context) { switch (tag.Type) { //Arrays case NBTTagType.ByteArray: Byte[] Bytes = tag.GetValue <Byte[]>(); Context.WriteBytes(Bytes); return; case NBTTagType.IntArray: Int32[] Ints = tag.GetValue <Int32[]>(); Context.WriteInt32Array(Ints); return; case NBTTagType.LongArray: Int64[] Longs = tag.GetValue <Int64[]>(); Context.WriteInt64Array(Longs); return; //Values case NBTTagType.Byte: Context.Stream.WriteByte(tag.GetValue <Byte>()); return; case NBTTagType.Short: Context.WriteInt16(tag.GetValue <Int16>()); return; case NBTTagType.Int: Context.WriteInt32(tag.GetValue <Int32>()); return; case NBTTagType.Long: Context.WriteInt64(tag.GetValue <Int64>()); return; case NBTTagType.Double: Context.WriteDouble(tag.GetValue <Double>()); return; case NBTTagType.Float: Context.WriteFloat(tag.GetValue <Single>()); return; case NBTTagType.String: NBTWriter.WriteString(Context.Stream, tag.GetValue <String>(), Context.Endianness); return; case NBTTagType.End: case NBTTagType.Unknown: default: return; } }
/// <summary>Writes the nbt's header to the <see cref="Stream"/></summary> /// <param name="tag">The tag to write to the <see cref="Stream"/></param> /// <param name="Context">The context to write to</param> public void WriteHeader(NBTTagList tag, SerializationContext Context) { Context.Stream.WriteByte((Byte)tag.Type); NBTWriter.WriteString(Context, tag.Name); Context.Stream.WriteByte((Byte)tag.SubType); Context.WriteInt32((Int32)tag.Count); }
/// <summary>Writes the nbt's header to the <see cref="Stream"/></summary> /// <param name="tag">The tag to write to the <see cref="Stream"/></param> /// <param name="Context">The context to write to</param> public void WriteHeader(ITag tag, SerializationContext Context) { Context.Stream.WriteByte((Byte)tag.Type); NBTWriter.WriteString(Context, tag.Name); Context.Stream.WriteByte((Byte)tag.GetInformation(NBTTagInformation.ListSubtype)); Context.WriteInt32((Int32)tag.GetInformation(NBTTagInformation.ListSize)); }
/// <summary>Writes the nbt's header to the <see cref="Stream"/></summary> /// <param name="tag">The tag to write to the <see cref="Stream"/></param> /// <param name="Context">The context that provides a buffer, the stream and endianness of the NBT</param> public void WriteHeader(ITag tag, SerializationContext Context) { Context.Stream.WriteByte((Byte)tag.Type); NBTWriter.WriteString(Context, tag.Name); }