/// <summary>
 /// Receives the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="version">The version.</param>
 /// <remarks></remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new ArgumentNullException("reader");
     EntityId = reader.ReadInt32();
     InnerData = MetadataInfo.Read(reader, version);
 }
        /// <summary>
        ///   Writes the metadata.
        /// </summary>
        /// <param name="data"> The data. </param>
        /// <param name="writer"> The writer. </param>
        /// <remarks>
        /// </remarks>
        public static void WriteMetadata(MetadataInfo data, BigEndianStream writer)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");
            if (data == null)
            {
                writer.Write((byte) 127);
                return;
            }

            if (data.Data == null) data.Data = new Dictionary<byte, object> ();

            foreach (KeyValuePair<byte, object> item in data.Data)
            {
                if (item.Value is byte)
                {
                    writer.Write(item.Key);
                    writer.Write((byte) item.Value);
                }
                else if (item.Value is short)
                {
                    writer.Write(item.Key);
                    writer.Write((short) item.Value);
                }
                else if (item.Value is int)
                {
                    writer.Write(item.Key);
                    writer.Write((int) item.Value);
                }
                else if (item.Value is float)
                {
                    writer.Write(item.Key);
                    writer.Write((float) item.Value);
                }
                else if (item.Value is string)
                {
                    writer.Write(item.Key);
                    writer.Write((string) item.Value);
                }
                else if (item.Value is ItemStack)
                {
                    writer.Write(item.Key);
                    writer.Write((ItemStack) item.Value);
                }
                else if (item.Value is EntityInformation)
                {
                    writer.Write(item.Key);
                    writer.Write((EntityInformation) item.Value);
                }
            }
            writer.Write((byte) 127);
        }
 /// <summary>
 /// Receives the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="version">The version.</param>
 /// <remarks></remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new System.ArgumentNullException("reader");
     EntityId = reader.ReadInt32();
     Name = reader.ReadString16();
     PositionX = reader.ReadInt32();
     PositionY = reader.ReadInt32();
     PositionZ = reader.ReadInt32();
     Rotation = reader.ReadByte();
     Pitch = reader.ReadByte();
     CurrentItem = reader.ReadInt16();
     if (version >= 38)
         MetaData = reader.ReadMetaData(version);
     else
     {
         MetaData = new MetadataInfo();
         MetaData.Data = new System.Collections.Generic.Dictionary<byte, object>
         {
             {17,(byte)0},
             {0,(byte)0},
             {16,(byte)0},
             {33,(short)300},
             {72,(int)0}
         };
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="NamedEntitySpawn"/> class.
        /// </summary>
        /// <remarks></remarks>
        public NamedEntitySpawn()
        {
            Code = 0x14;

            MetaData = new MetadataInfo();
        }
 /// <summary>
 ///   Writes the specified stream.
 /// </summary>
 /// <param name="stream"> The stream. </param>
 /// <param name="data"> The data. </param>
 /// <remarks>
 /// </remarks>
 public static void Write(this BigEndianStream stream, MetadataInfo data)
 {
     MetadataInfo.WriteMetadata(data, stream);
 }